diff -Nru cargo-0.58.0/benches/benchsuite/benches/resolve.rs cargo-0.60.0ubuntu1/benches/benchsuite/benches/resolve.rs --- cargo-0.58.0/benches/benchsuite/benches/resolve.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/benches/benchsuite/benches/resolve.rs 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,327 @@ +use cargo::core::compiler::{CompileKind, RustcTargetData}; +use cargo::core::resolver::features::{CliFeatures, FeatureOpts, FeatureResolver, ForceAllTargets}; +use cargo::core::resolver::{HasDevUnits, ResolveBehavior}; +use cargo::core::{PackageIdSpec, Workspace}; +use cargo::ops::WorkspaceResolve; +use cargo::Config; +use criterion::{criterion_group, criterion_main, Criterion}; +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::Command; +use url::Url; + +// This is an arbitrary commit that existed when I started. This helps +// ensure consistent results. It can be updated if needed, but that can +// make it harder to compare results with older versions of cargo. +const CRATES_IO_COMMIT: &str = "85f7bfd61ea4fee08ec68c468762e886b2aebec6"; + +fn setup() { + create_home(); + create_target_dir(); + clone_index(); + unpack_workspaces(); +} + +fn root() -> PathBuf { + let mut p = PathBuf::from(env!("CARGO_TARGET_TMPDIR")); + p.push("bench"); + p +} + +fn target_dir() -> PathBuf { + let mut p = root(); + p.push("target"); + p +} + +fn cargo_home() -> PathBuf { + let mut p = root(); + p.push("chome"); + p +} + +fn index() -> PathBuf { + let mut p = root(); + p.push("index"); + p +} + +fn workspaces_path() -> PathBuf { + let mut p = root(); + p.push("workspaces"); + p +} + +fn registry_url() -> Url { + Url::from_file_path(index()).unwrap() +} + +fn create_home() { + let home = cargo_home(); + if !home.exists() { + fs::create_dir_all(&home).unwrap(); + } + fs::write( + home.join("config.toml"), + format!( + r#" + [source.crates-io] + replace-with = 'local-snapshot' + + [source.local-snapshot] + registry = '{}' + "#, + registry_url() + ), + ) + .unwrap(); +} + +fn create_target_dir() { + // This is necessary to ensure the .rustc_info.json file is written. + // Otherwise it won't be written, and it is very expensive to create. + if !target_dir().exists() { + std::fs::create_dir_all(target_dir()).unwrap(); + } +} + +/// This clones crates.io at a specific point in time into tmp/index. +fn clone_index() { + let index = index(); + let maybe_git = |command: &str| { + let status = Command::new("git") + .current_dir(&index) + .args(command.split_whitespace().collect::>()) + .status() + .expect("git should be installed"); + status.success() + }; + let git = |command: &str| { + if !maybe_git(command) { + panic!("failed to run git command: {}", command); + } + }; + if index.exists() { + if maybe_git(&format!( + "rev-parse -q --verify {}^{{commit}}", + CRATES_IO_COMMIT + )) { + // Already fetched. + return; + } + } else { + fs::create_dir_all(&index).unwrap(); + git("init --bare"); + git("remote add origin https://github.com/rust-lang/crates.io-index"); + } + git(&format!("fetch origin {}", CRATES_IO_COMMIT)); + git("branch -f master FETCH_HEAD"); +} + +/// This unpacks the compressed workspace skeletons into tmp/workspaces. +fn unpack_workspaces() { + let ws_dir = Path::new(env!("CARGO_MANIFEST_DIR")) + .parent() + .unwrap() + .join("workspaces"); + let archives = fs::read_dir(ws_dir) + .unwrap() + .map(|e| e.unwrap().path()) + .filter(|p| p.extension() == Some(std::ffi::OsStr::new("tgz"))); + for archive in archives { + let name = archive.file_stem().unwrap(); + let f = fs::File::open(&archive).unwrap(); + let f = flate2::read::GzDecoder::new(f); + let dest = workspaces_path().join(&name); + if dest.exists() { + fs::remove_dir_all(&dest).unwrap(); + } + let mut archive = tar::Archive::new(f); + archive.unpack(workspaces_path()).unwrap(); + } +} + +struct ResolveInfo<'cfg> { + ws: Workspace<'cfg>, + requested_kinds: [CompileKind; 1], + target_data: RustcTargetData<'cfg>, + cli_features: CliFeatures, + specs: Vec, + has_dev_units: HasDevUnits, + force_all_targets: ForceAllTargets, + ws_resolve: WorkspaceResolve<'cfg>, +} + +/// Vec of `(ws_name, ws_root)`. +fn workspaces() -> Vec<(String, PathBuf)> { + // CARGO_BENCH_WORKSPACES can be used to override, otherwise it just uses + // the workspaces in the workspaces directory. + let mut ps: Vec<_> = match std::env::var_os("CARGO_BENCH_WORKSPACES") { + Some(s) => std::env::split_paths(&s).collect(), + None => fs::read_dir(workspaces_path()) + .unwrap() + .map(|e| e.unwrap().path()) + // These currently fail in most cases on Windows due to long + // filenames in the git checkouts. + .filter(|p| { + !(cfg!(windows) + && matches!(p.file_name().unwrap().to_str().unwrap(), "servo" | "tikv")) + }) + .collect(), + }; + // Sort so it is consistent. + ps.sort(); + ps.into_iter() + .map(|p| (p.file_name().unwrap().to_str().unwrap().to_owned(), p)) + .collect() +} + +/// Helper for resolving a workspace. This will run the resolver once to +/// download everything, and returns all the data structures that are used +/// during resolution. +fn do_resolve<'cfg>(config: &'cfg Config, ws_root: &Path) -> ResolveInfo<'cfg> { + let requested_kinds = [CompileKind::Host]; + let ws = cargo::core::Workspace::new(&ws_root.join("Cargo.toml"), config).unwrap(); + let target_data = RustcTargetData::new(&ws, &requested_kinds).unwrap(); + let cli_features = CliFeatures::from_command_line(&[], false, true).unwrap(); + let pkgs = cargo::ops::Packages::Default; + let specs = pkgs.to_package_id_specs(&ws).unwrap(); + let has_dev_units = HasDevUnits::Yes; + let force_all_targets = ForceAllTargets::No; + // Do an initial run to download anything necessary so that it does + // not confuse criterion's warmup. + let ws_resolve = cargo::ops::resolve_ws_with_opts( + &ws, + &target_data, + &requested_kinds, + &cli_features, + &specs, + has_dev_units, + force_all_targets, + ) + .unwrap(); + ResolveInfo { + ws, + requested_kinds, + target_data, + cli_features, + specs, + has_dev_units, + force_all_targets, + ws_resolve, + } +} + +/// Creates a new Config. +/// +/// This is separate from `do_resolve` to deal with the ownership and lifetime. +fn make_config(ws_root: &Path) -> Config { + let shell = cargo::core::Shell::new(); + let mut config = cargo::util::Config::new(shell, ws_root.to_path_buf(), cargo_home()); + // Configure is needed to set the target_dir which is needed to write + // the .rustc_info.json file which is very expensive. + config + .configure( + 0, + false, + None, + false, + false, + false, + &Some(target_dir()), + &[], + &[], + ) + .unwrap(); + config +} + +/// Benchmark of the full `resovle_ws_with_opts` which runs the resolver +/// twice, the feature resolver, and more. This is a major component of a +/// regular cargo build. +fn resolve_ws(c: &mut Criterion) { + setup(); + let mut group = c.benchmark_group("resolve_ws"); + for (ws_name, ws_root) in workspaces() { + let config = make_config(&ws_root); + // The resolver info is initialized only once in a lazy fashion. This + // allows criterion to skip this workspace if the user passes a filter + // on the command-line (like `cargo bench -- resolve_ws/tikv`). + // + // Due to the way criterion works, it tends to only run the inner + // iterator once, and we don't want to call `do_resolve` in every + // "step", since that would just be some useless work. + let mut lazy_info = None; + group.bench_function(&ws_name, |b| { + let ResolveInfo { + ws, + requested_kinds, + target_data, + cli_features, + specs, + has_dev_units, + force_all_targets, + .. + } = lazy_info.get_or_insert_with(|| do_resolve(&config, &ws_root)); + b.iter(|| { + cargo::ops::resolve_ws_with_opts( + ws, + target_data, + requested_kinds, + cli_features, + specs, + *has_dev_units, + *force_all_targets, + ) + .unwrap(); + }) + }); + } + group.finish(); +} + +/// Benchmark of the feature resolver. +fn feature_resolver(c: &mut Criterion) { + setup(); + let mut group = c.benchmark_group("feature_resolver"); + for (ws_name, ws_root) in workspaces() { + let config = make_config(&ws_root); + let mut lazy_info = None; + group.bench_function(&ws_name, |b| { + let ResolveInfo { + ws, + requested_kinds, + target_data, + cli_features, + specs, + has_dev_units, + ws_resolve, + .. + } = lazy_info.get_or_insert_with(|| do_resolve(&config, &ws_root)); + b.iter(|| { + let feature_opts = FeatureOpts::new_behavior(ResolveBehavior::V2, *has_dev_units); + FeatureResolver::resolve( + ws, + target_data, + &ws_resolve.targeted_resolve, + &ws_resolve.pkg_set, + cli_features, + specs, + requested_kinds, + feature_opts, + ) + .unwrap(); + }) + }); + } + group.finish(); +} + +// Criterion complains about the measurement time being too small, but the +// measurement time doesn't seem important to me, what is more important is +// the number of iterations which defaults to 100, which seems like a +// reasonable default. Otherwise, the measurement time would need to be +// changed per workspace. We wouldn't want to spend 60s on every workspace, +// that would take too long and isn't necessary for the smaller workspaces. +criterion_group!(benches, resolve_ws, feature_resolver); +criterion_main!(benches); diff -Nru cargo-0.58.0/benches/benchsuite/Cargo.toml cargo-0.60.0ubuntu1/benches/benchsuite/Cargo.toml --- cargo-0.58.0/benches/benchsuite/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/benches/benchsuite/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,21 @@ +[package] +name = "benchsuite" +version = "0.1.0" +edition = "2021" +license = "MIT OR Apache-2.0" +homepage = "https://github.com/rust-lang/cargo" +repository = "https://github.com/rust-lang/cargo" +documentation = "https://docs.rs/cargo-platform" +description = "Benchmarking suite for Cargo." + +[dependencies] +cargo = { path = "../.." } +# Consider removing html_reports in 0.4 and switching to `cargo criterion`. +criterion = { version = "0.3.5", features = ["html_reports"] } +flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] } +tar = { version = "0.4.35", default-features = false } +url = "2.2.2" + +[[bench]] +name = "resolve" +harness = false diff -Nru cargo-0.58.0/benches/capture/Cargo.toml cargo-0.60.0ubuntu1/benches/capture/Cargo.toml --- cargo-0.58.0/benches/capture/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/benches/capture/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,12 @@ +[package] +name = "capture" +version = "0.1.0" +edition = "2021" +license = "MIT OR Apache-2.0" +description = "Tool for capturing a real-world workspace for benchmarking." + +[dependencies] +cargo_metadata = "0.14.0" +flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] } +tar = { version = "0.4.35", default-features = false } +toml = "0.5.8" diff -Nru cargo-0.58.0/benches/capture/src/main.rs cargo-0.60.0ubuntu1/benches/capture/src/main.rs --- cargo-0.58.0/benches/capture/src/main.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/benches/capture/src/main.rs 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,164 @@ +//! This tool helps to capture the `Cargo.toml` files of a workspace. +//! +//! Run it by passing a list of workspaces to capture. +//! Use the `-f` flag to allow it to overwrite existing captures. +//! The workspace will be saved in a `.tgz` file in the `../workspaces` directory. + +use flate2::{Compression, GzBuilder}; +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::Command; + +fn main() { + let force = std::env::args().any(|arg| arg == "-f"); + let dest = Path::new(env!("CARGO_MANIFEST_DIR")) + .parent() + .unwrap() + .join("workspaces"); + if !dest.exists() { + panic!("expected {} to exist", dest.display()); + } + for arg in std::env::args().skip(1).filter(|arg| !arg.starts_with("-")) { + let source_root = fs::canonicalize(arg).unwrap(); + capture(&source_root, &dest, force); + } +} + +fn capture(source_root: &Path, dest: &Path, force: bool) { + let name = Path::new(source_root.file_name().unwrap()); + let mut dest_gz = PathBuf::from(dest); + dest_gz.push(name); + dest_gz.set_extension("tgz"); + if dest_gz.exists() { + if !force { + panic!( + "dest {:?} already exists, use -f to force overwriting", + dest_gz + ); + } + fs::remove_file(&dest_gz).unwrap(); + } + let vcs_info = capture_vcs_info(source_root, force); + let dst = fs::File::create(&dest_gz).unwrap(); + let encoder = GzBuilder::new() + .filename(format!("{}.tar", name.to_str().unwrap())) + .write(dst, Compression::best()); + let mut ar = tar::Builder::new(encoder); + ar.mode(tar::HeaderMode::Deterministic); + if let Some(info) = &vcs_info { + add_ar_file(&mut ar, &name.join(".cargo_vcs_info.json"), info); + } + + // Gather all local packages. + let metadata = cargo_metadata::MetadataCommand::new() + .manifest_path(source_root.join("Cargo.toml")) + .features(cargo_metadata::CargoOpt::AllFeatures) + .exec() + .expect("cargo_metadata failed"); + let mut found_root = false; + for package in &metadata.packages { + if package.source.is_some() { + continue; + } + let manifest_path = package.manifest_path.as_std_path(); + copy_manifest(&manifest_path, &mut ar, name, &source_root); + found_root |= manifest_path == source_root.join("Cargo.toml"); + } + if !found_root { + // A virtual workspace. + let contents = fs::read_to_string(source_root.join("Cargo.toml")).unwrap(); + assert!(!contents.contains("[package]")); + add_ar_file(&mut ar, &name.join("Cargo.toml"), &contents); + } + let lock = fs::read_to_string(source_root.join("Cargo.lock")).unwrap(); + add_ar_file(&mut ar, &name.join("Cargo.lock"), &lock); + let encoder = ar.into_inner().unwrap(); + encoder.finish().unwrap(); + eprintln!("created {}", dest_gz.display()); +} + +fn copy_manifest( + manifest_path: &Path, + ar: &mut tar::Builder, + name: &Path, + source_root: &Path, +) { + let relative_path = manifest_path + .parent() + .unwrap() + .strip_prefix(source_root) + .expect("workspace member should be under workspace root"); + let relative_path = name.join(relative_path); + let contents = fs::read_to_string(&manifest_path).unwrap(); + let mut manifest: toml::Value = toml::from_str(&contents).unwrap(); + let remove = |obj: &mut toml::Value, name| { + let table = obj.as_table_mut().unwrap(); + if table.contains_key(name) { + table.remove(name); + } + }; + remove(&mut manifest, "lib"); + remove(&mut manifest, "bin"); + remove(&mut manifest, "example"); + remove(&mut manifest, "test"); + remove(&mut manifest, "bench"); + remove(&mut manifest, "profile"); + if let Some(package) = manifest.get_mut("package") { + remove(package, "default-run"); + } + let contents = toml::to_string(&manifest).unwrap(); + add_ar_file(ar, &relative_path.join("Cargo.toml"), &contents); + add_ar_file(ar, &relative_path.join("src").join("lib.rs"), ""); +} + +fn add_ar_file(ar: &mut tar::Builder, path: &Path, contents: &str) { + let mut header = tar::Header::new_gnu(); + header.set_entry_type(tar::EntryType::file()); + header.set_mode(0o644); + header.set_size(contents.len() as u64); + header.set_mtime(123456789); + header.set_cksum(); + ar.append_data(&mut header, path, contents.as_bytes()) + .unwrap(); +} + +fn capture_vcs_info(ws_root: &Path, force: bool) -> Option { + let maybe_git = |command: &str| { + Command::new("git") + .current_dir(ws_root) + .args(command.split_whitespace().collect::>()) + .output() + .expect("git should be installed") + }; + assert!(ws_root.join("Cargo.toml").exists()); + let relative = maybe_git("ls-files --full-name Cargo.toml"); + if !relative.status.success() { + if !force { + panic!("git repository not detected, use -f to force"); + } + return None; + } + let p = Path::new(std::str::from_utf8(&relative.stdout).unwrap().trim()); + let relative = p.parent().unwrap(); + if !force { + let has_changes = !maybe_git("diff-index --quiet HEAD .").status.success(); + if has_changes { + panic!("git repo appears to have changes, use -f to force, or clean the repo"); + } + } + let commit = maybe_git("rev-parse HEAD"); + assert!(commit.status.success()); + let commit = std::str::from_utf8(&commit.stdout).unwrap().trim(); + let remote = maybe_git("remote get-url origin"); + assert!(remote.status.success()); + let remote = std::str::from_utf8(&remote.stdout).unwrap().trim(); + let info = format!( + "{{\n \"git\": {{\n \"sha1\": \"{}\",\n \"remote\": \"{}\"\n }},\ + \n \"path_in_vcs\": \"{}\"\n}}\n", + commit, + remote, + relative.display() + ); + eprintln!("recording vcs info:\n{}", info); + Some(info) +} diff -Nru cargo-0.58.0/benches/README.md cargo-0.60.0ubuntu1/benches/README.md --- cargo-0.58.0/benches/README.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/benches/README.md 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,124 @@ +# Cargo Benchmarking + +This directory contains some benchmarks for cargo itself. This uses +[Criterion] for running benchmarks. It is recommended to read the Criterion +book to get familiar with how to use it. A basic usage would be: + +```sh +cd benches/benchsuite +cargo bench +``` + +The tests involve downloading the index and benchmarking against some +real-world and artificial workspaces located in the [`workspaces`](workspaces) +directory. + +**Beware** that the initial download can take a fairly long amount of time (10 +minutes minimum on an extremely fast network) and require significant disk +space (around 4.5GB). The benchsuite will cache the index and downloaded +crates in the `target/tmp/bench` directory, so subsequent runs should be +faster. You can (and probably should) specify individual benchmarks to run to +narrow it down to a more reasonable set, for example: + +```sh +cargo bench -- resolve_ws/rust +``` + +This will only download what's necessary for the rust-lang/rust workspace +(which is about 330MB) and run the benchmarks against it (which should take +about a minute). To get a list of all the benchmarks, run: + +```sh +cargo bench -- --list +``` + +## Viewing reports + +The benchmarks display some basic information on the command-line while they +run. A more complete HTML report can be found at +`target/criterion/report/index.html` which contains links to all the +benchmarks and summaries. Check out the Criterion book for more information on +the extensive reporting capabilities. + +## Comparing implementations + +Knowing the raw numbers can be useful, but what you're probably most +interested in is checking if your changes help or hurt performance. To do +that, you need to run the benchmarks multiple times. + +First, run the benchmarks from the master branch of cargo without any changes. +To make it easier to compare, Criterion supports naming the baseline so that +you can iterate on your code and compare against it multiple times. + +```sh +cargo bench -- --save-baseline master +``` + +Now you can switch to your branch with your changes. Re-run the benchmarks +compared against the baseline: + +```sh +cargo bench -- --baseline master +``` + +You can repeat the last command as you make changes to re-compare against the +master baseline. + +Without the baseline arguments, it will compare against the last run, which +can be helpful for comparing incremental changes. + +## Capturing workspaces + +The [`workspaces`](workspaces) directory contains several workspaces that +provide a variety of different workspaces intended to provide good exercises +for benchmarks. Some of these are shadow copies of real-world workspaces. This +is done with the tool in the [`capture`](capture) directory. The tool will +copy `Cargo.lock` and all of the `Cargo.toml` files of the workspace members. +It also adds an empty `lib.rs` so Cargo won't error, and sanitizes the +`Cargo.toml` to some degree, removing unwanted elements. Finally, it +compresses everything into a `tgz`. + +To run it, do: + +```sh +cd benches/capture +cargo run -- /path/to/workspace/foo +``` + +The resolver benchmarks also support the `CARGO_BENCH_WORKSPACES` environment +variable, which you can point to a Cargo workspace if you want to try +different workspaces. For example: + +```sh +CARGO_BENCH_WORKSPACES=/path/to/some/workspace cargo bench +``` + +## TODO + +This is just a start for establishing a benchmarking suite for Cargo. There's +a lot that can be added. Some ideas: + +* Fix the benchmarks so that the resolver setup doesn't run every iteration. +* Benchmark [this section of + code](https://github.com/rust-lang/cargo/blob/a821e2cb24d7b6013433f069ab3bad53d160e100/src/cargo/ops/cargo_compile.rs#L470-L549) + which builds the unit graph. The performance there isn't great, and it would + be good to keep an eye on it. Unfortunately that would mean doing a bit of + work to make `generate_targets` publicly visible, and there is a bunch of + setup code that may need to be duplicated. +* Benchmark the fingerprinting code. +* Benchmark running the `cargo` executable. Running something like `cargo + build` or `cargo check` with everything "Fresh" would be a good end-to-end + exercise to measure the overall overhead of Cargo. +* Benchmark pathological resolver scenarios. There might be some cases where + the resolver can spend a significant amount of time. It would be good to + identify if these exist, and create benchmarks for them. This may require + creating an artificial index, similar to the `resolver-tests`. This should + also consider scenarios where the resolver ultimately fails. +* Benchmark without `Cargo.lock`. I'm not sure if this is particularly + valuable, since we are mostly concerned with incremental builds which will + always have a lock file. +* Benchmark just + [`resolve::resolve`](https://github.com/rust-lang/cargo/blob/a821e2cb24d7b6013433f069ab3bad53d160e100/src/cargo/core/resolver/mod.rs#L122) + without anything else. This can help focus on just the resolver. + +[Criterion]: https://bheisler.github.io/criterion.rs/book/ diff -Nru cargo-0.58.0/Cargo.toml cargo-0.60.0ubuntu1/Cargo.toml --- cargo-0.58.0/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,10 +1,7 @@ [package] name = "cargo" -version = "0.58.0" -edition = "2018" -authors = ["Yehuda Katz ", - "Carl Lerche ", - "Alex Crichton "] +version = "0.60.0" +edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://crates.io" repository = "https://github.com/rust-lang/cargo" @@ -22,11 +19,11 @@ atty = "0.2" bytesize = "1.0" cargo-platform = { path = "crates/cargo-platform", version = "0.1.2" } -cargo-util = { path = "crates/cargo-util", version = "0.1.1" } -crates-io = { path = "crates/crates-io", version = "0.33.0" } +cargo-util = { path = "crates/cargo-util", version = "0.1.2" } +crates-io = { path = "crates/crates-io", version = "0.33.1" } crossbeam-utils = "0.8" -curl = { version = "0.4.39", features = ["http2"] } -curl-sys = "0.4.49" +curl = { version = "0.4.41", features = ["http2"] } +curl-sys = "0.4.50" env_logger = "0.9.0" pretty_env_logger = { version = "0.4", optional = true } anyhow = "1.0" @@ -57,14 +54,14 @@ serde_json = { version = "1.0.30", features = ["raw_value"] } shell-escape = "0.1.4" strip-ansi-escapes = "0.1.0" -tar = { version = "0.4.35", default-features = false } +tar = { version = "0.4.36", default-features = false } tempfile = "3.0" termcolor = "1.1" toml = "0.5.7" unicode-xid = "0.2.0" url = "2.2.2" walkdir = "2.2" -clap = "2.31.2" +clap = "2.34.0" unicode-width = "0.1.5" openssl = { version = '0.10.11', optional = true } im-rc = "15.0.0" diff -Nru cargo-0.58.0/CHANGELOG.md cargo-0.60.0ubuntu1/CHANGELOG.md --- cargo-0.58.0/CHANGELOG.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/CHANGELOG.md 2022-02-10 02:58:21.000000000 +0000 @@ -1,21 +1,118 @@ # Changelog +## Cargo 1.59 (2022-02-24) +[7f08ace4...HEAD](https://github.com/rust-lang/cargo/compare/7f08ace4...HEAD) + +### Added + +### Changed + +### Fixed + +### Nightly only +- Added the `--crate-type` flag to `cargo rustc`. + [#10093](https://github.com/rust-lang/cargo/pull/10093) + + +## Cargo 1.58 (2022-01-13) +[b2e52d7c...rust-1.58.0](https://github.com/rust-lang/cargo/compare/b2e52d7c...rust-1.58.0) + +### Added + +- Added `rust_version` field to package data in `cargo metadata`. + [#9967](https://github.com/rust-lang/cargo/pull/9967) +- Added `--message-format` option to `cargo install`. + [#10107](https://github.com/rust-lang/cargo/pull/10107) + +### Changed + +- A warning is now shown when an alias shadows an external command. + [#10082](https://github.com/rust-lang/cargo/pull/10082) +- Updated curl to 7.80.0. + [#10040](https://github.com/rust-lang/cargo/pull/10040) + [#10106](https://github.com/rust-lang/cargo/pull/10106) + +### Fixed + +- Doctests now include rustc-link-args from build scripts. + [#9916](https://github.com/rust-lang/cargo/pull/9916) +- Fixed `cargo tree` entering an infinite loop with cyclical dev-dependencies. + Fixed an edge case where the resolver would fail to handle a cyclical dev-dependency with a feature. + [#10103](https://github.com/rust-lang/cargo/pull/10103) +- Fixed `cargo clean -p` when the directory path contains glob characters. + [#10072](https://github.com/rust-lang/cargo/pull/10072) +- Fixed debug builds of `cargo` which could panic when downloading a crate + when the server has a redirect with a non-empty body. + [#10048](https://github.com/rust-lang/cargo/pull/10048) + +### Nightly only + +- Make future-incompat-report output more user-friendly. + [#9953](https://github.com/rust-lang/cargo/pull/9953) +- Added support to scrape code examples from the `examples` directory to be included in the documentation. + [docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#scrape-examples) + [#9525](https://github.com/rust-lang/cargo/pull/9525) + [#10037](https://github.com/rust-lang/cargo/pull/10037) + [#10017](https://github.com/rust-lang/cargo/pull/10017) +- Fixed `cargo report future-incompatibilities` to check stdout if it supports color. + [#10024](https://github.com/rust-lang/cargo/pull/10024) + ## Cargo 1.57 (2021-12-02) -[18751dd3...HEAD](https://github.com/rust-lang/cargo/compare/18751dd3...HEAD) +[18751dd3...rust-1.57.0](https://github.com/rust-lang/cargo/compare/18751dd3...rust-1.57.0) ### Added +- 🎉 Added custom named profiles. This also changes the `test` and `bench` + profiles to inherit their settings from `dev` and `release`, and Cargo will + now only use a single profile during a given command instead of using + different profiles for dependencies and cargo-targets. + [docs](https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#custom-profiles) + [#9943](https://github.com/rust-lang/cargo/pull/9943) - 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) +- Added `path_in_vcs` field to the `.cargo_vcs_info.json` file. + [docs](https://doc.rust-lang.org/nightly/cargo/commands/cargo-package.html#cargo_vcs_infojson-format) + [#9866](https://github.com/rust-lang/cargo/pull/9866) ### Changed +- ❗ `RUSTFLAGS` is no longer set for build scripts. This change was made in + 1.55, but the release notes did not highlight this change. Build scripts + should use `CARGO_ENCODED_RUSTFLAGS` instead. See the + [documentation](https://doc.rust-lang.org/nightly/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts) + for more details. +- The `cargo version` command now includes some extra information. + [#9968](https://github.com/rust-lang/cargo/pull/9968) +- Updated libgit2 to 1.3 which brings in a number of fixes and changes to git + handling. + [#9963](https://github.com/rust-lang/cargo/pull/9963) + [#9988](https://github.com/rust-lang/cargo/pull/9988) +- Shell completions now include shorthand b/r/c/d subcommands. + [#9951](https://github.com/rust-lang/cargo/pull/9951) +- `cargo update --precise` now allows specifying a version without semver + metadata (stuff after `+` in the version number). + [#9945](https://github.com/rust-lang/cargo/pull/9945) +- zsh completions now complete `--example` names. + [#9939](https://github.com/rust-lang/cargo/pull/9939) +- The progress bar now differentiates when building unittests. + [#9934](https://github.com/rust-lang/cargo/pull/9934) +- Some backwards-compatibility support for invalid TOML syntax has been removed. + [#9932](https://github.com/rust-lang/cargo/pull/9932) +- Reverted the change from 1.55 that triggered an error for dependency + specifications that did not include any fields. + [#9911](https://github.com/rust-lang/cargo/pull/9911) + ### Fixed - Removed a log message (from `CARGO_LOG`) that may leak tokens. [#9873](https://github.com/rust-lang/cargo/pull/9873) +- `cargo fix` will now avoid writing fixes to the global registry cache. + [#9938](https://github.com/rust-lang/cargo/pull/9938) +- Fixed `-Z help` CLI option when used with a shorthand alias (b/c/r/d). + [#9933](https://github.com/rust-lang/cargo/pull/9933) + ### Nightly only @@ -105,6 +202,8 @@ [#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) +- Updated to curl 7.79.1, which will hopefully fix intermittent http2 errors. + [#9937](https://github.com/rust-lang/cargo/pull/9937) ### Nightly only @@ -129,8 +228,10 @@ - The package definition in `cargo metadata` now includes the `"default_run"` field from the manifest. [#9550](https://github.com/rust-lang/cargo/pull/9550) -- Build scripts now have access to the following environment variables: +- ❗ Build scripts now have access to the following environment variables: `RUSTC_WRAPPER`, `RUSTC_WORKSPACE_WRAPPER`, `CARGO_ENCODED_RUSTFLAGS`. + `RUSTFLAGS` is no longer set for build scripts; they should use + `CARGO_ENCODED_RUSTFLAGS` instead. [docs](https://doc.rust-lang.org/nightly/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts) [#9601](https://github.com/rust-lang/cargo/pull/9601) - Added `cargo d` as an alias for `cargo doc`. diff -Nru cargo-0.58.0/crates/cargo-platform/Cargo.toml cargo-0.60.0ubuntu1/crates/cargo-platform/Cargo.toml --- cargo-0.58.0/crates/cargo-platform/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/cargo-platform/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,7 @@ [package] name = "cargo-platform" version = "0.1.2" -authors = ["The Cargo Project Developers"] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/rust-lang/cargo" repository = "https://github.com/rust-lang/cargo" diff -Nru cargo-0.58.0/crates/cargo-test-macro/Cargo.toml cargo-0.60.0ubuntu1/crates/cargo-test-macro/Cargo.toml --- cargo-0.58.0/crates/cargo-test-macro/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/cargo-test-macro/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,7 @@ [package] name = "cargo-test-macro" version = "0.1.0" -authors = ["Jethro Beekman "] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/rust-lang/cargo" repository = "https://github.com/rust-lang/cargo" diff -Nru cargo-0.58.0/crates/cargo-test-support/Cargo.toml cargo-0.60.0ubuntu1/crates/cargo-test-support/Cargo.toml --- cargo-0.58.0/crates/cargo-test-support/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/cargo-test-support/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,9 +1,8 @@ [package] name = "cargo-test-support" version = "0.1.0" -authors = ["Alex Crichton "] license = "MIT OR Apache-2.0" -edition = "2018" +edition = "2021" [lib] doctest = false @@ -24,3 +23,6 @@ termcolor = "1.1.2" toml = "0.5.7" url = "2.2.2" + +[features] +deny-warnings = [] diff -Nru cargo-0.58.0/crates/cargo-test-support/src/lib.rs cargo-0.60.0ubuntu1/crates/cargo-test-support/src/lib.rs --- cargo-0.58.0/crates/cargo-test-support/src/lib.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/cargo-test-support/src/lib.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,6 +5,7 @@ #![allow(clippy::all)] #![warn(clippy::needless_borrow)] #![warn(clippy::redundant_clone)] +#![cfg_attr(feature = "deny-warnings", deny(warnings))] use std::env; use std::ffi::OsStr; @@ -445,6 +446,11 @@ ProjectBuilder::new(paths::root().join("foo")) } +// Generates a project layout in given directory +pub fn project_in(dir: &str) -> ProjectBuilder { + ProjectBuilder::new(paths::root().join(dir).join("foo")) +} + // Generates a project layout inside our fake home dir pub fn project_in_home(name: &str) -> ProjectBuilder { ProjectBuilder::new(paths::home().join(name)) @@ -797,6 +803,15 @@ } } + #[track_caller] + pub fn run_expect_error(&mut self) { + self.ran = true; + let p = (&self.process_builder).clone().unwrap(); + if self.match_process(&p).is_ok() { + panic!("test was expected to fail, but succeeded running {}", p); + } + } + /// Runs the process, checks the expected output, and returns the first /// JSON object on stdout. #[track_caller] diff -Nru cargo-0.58.0/crates/cargo-util/Cargo.toml cargo-0.60.0ubuntu1/crates/cargo-util/Cargo.toml --- cargo-0.58.0/crates/cargo-util/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/cargo-util/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,7 @@ [package] name = "cargo-util" -version = "0.1.1" -authors = ["The Cargo Project Developers"] -edition = "2018" +version = "0.1.2" +edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/rust-lang/cargo" repository = "https://github.com/rust-lang/cargo" diff -Nru cargo-0.58.0/crates/cargo-util/src/paths.rs cargo-0.60.0ubuntu1/crates/cargo-util/src/paths.rs --- cargo-0.58.0/crates/cargo-util/src/paths.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/cargo-util/src/paths.rs 2022-02-10 02:58:21.000000000 +0000 @@ -123,15 +123,13 @@ }); for candidate in candidates { if candidate.is_file() { - // PATH may have a component like "." in it, so we still need to - // canonicalize. - return Ok(candidate.canonicalize()?); + return Ok(candidate); } } anyhow::bail!("no executable for `{}` found in PATH", exec.display()) } else { - Ok(exec.canonicalize()?) + Ok(exec.into()) } } @@ -541,7 +539,18 @@ // gory details. fs::copy(src, dst).map(|_| ()) } else { - fs::hard_link(src, dst) + if cfg!(target_os = "macos") { + // This is a work-around for a bug on macos. There seems to be a race condition + // with APFS when hard-linking binaries. Gatekeeper does not have signing or + // hash informations stored in kernel when running the process. Therefore killing it. + // This problem does not appear when copying files as kernel has time to process it. + // Note that: fs::copy on macos is using CopyOnWrite (syscall fclonefileat) which should be + // as fast as hardlinking. + // See https://github.com/rust-lang/cargo/issues/10060 for the details + fs::copy(src, dst).map(|_| ()) + } else { + fs::hard_link(src, dst) + } }; link_result .or_else(|err| { diff -Nru cargo-0.58.0/crates/crates-io/Cargo.toml cargo-0.60.0ubuntu1/crates/crates-io/Cargo.toml --- cargo-0.58.0/crates/crates-io/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/crates-io/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,7 @@ [package] name = "crates-io" -version = "0.33.0" -edition = "2018" -authors = ["Alex Crichton "] +version = "0.33.1" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/cargo" description = """ diff -Nru cargo-0.58.0/crates/credential/cargo-credential/Cargo.toml cargo-0.60.0ubuntu1/crates/credential/cargo-credential/Cargo.toml --- cargo-0.58.0/crates/credential/cargo-credential/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/credential/cargo-credential/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,7 @@ [package] name = "cargo-credential" version = "0.1.0" -authors = ["The Rust Project Developers"] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/cargo" description = "A library to assist writing Cargo credential helpers." diff -Nru cargo-0.58.0/crates/credential/cargo-credential-1password/Cargo.toml cargo-0.60.0ubuntu1/crates/credential/cargo-credential-1password/Cargo.toml --- cargo-0.58.0/crates/credential/cargo-credential-1password/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/credential/cargo-credential-1password/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,7 @@ [package] name = "cargo-credential-1password" version = "0.1.0" -authors = ["The Rust Project Developers"] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/cargo" description = "A Cargo credential process that stores tokens in a 1password vault." diff -Nru cargo-0.58.0/crates/credential/cargo-credential-gnome-secret/Cargo.toml cargo-0.60.0ubuntu1/crates/credential/cargo-credential-gnome-secret/Cargo.toml --- cargo-0.58.0/crates/credential/cargo-credential-gnome-secret/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/credential/cargo-credential-gnome-secret/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,7 @@ [package] name = "cargo-credential-gnome-secret" version = "0.1.0" -authors = ["The Rust Project Developers"] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/cargo" description = "A Cargo credential process that stores tokens with GNOME libsecret." diff -Nru cargo-0.58.0/crates/credential/cargo-credential-macos-keychain/Cargo.toml cargo-0.60.0ubuntu1/crates/credential/cargo-credential-macos-keychain/Cargo.toml --- cargo-0.58.0/crates/credential/cargo-credential-macos-keychain/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/credential/cargo-credential-macos-keychain/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,7 @@ [package] name = "cargo-credential-macos-keychain" version = "0.1.0" -authors = ["The Rust Project Developers"] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/cargo" description = "A Cargo credential process that stores tokens in a macOS keychain." diff -Nru cargo-0.58.0/crates/credential/cargo-credential-wincred/Cargo.toml cargo-0.60.0ubuntu1/crates/credential/cargo-credential-wincred/Cargo.toml --- cargo-0.58.0/crates/credential/cargo-credential-wincred/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/credential/cargo-credential-wincred/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,7 @@ [package] name = "cargo-credential-wincred" version = "0.1.0" -authors = ["The Rust Project Developers"] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/cargo" description = "A Cargo credential process that stores tokens with Windows Credential Manager." diff -Nru cargo-0.58.0/crates/mdman/Cargo.toml cargo-0.60.0ubuntu1/crates/mdman/Cargo.toml --- cargo-0.58.0/crates/mdman/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/mdman/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,7 @@ [package] name = "mdman" version = "0.1.0" -authors = ["Eric Huss"] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" description = "Creates a man page page from markdown." diff -Nru cargo-0.58.0/crates/resolver-tests/Cargo.toml cargo-0.60.0ubuntu1/crates/resolver-tests/Cargo.toml --- cargo-0.58.0/crates/resolver-tests/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/crates/resolver-tests/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -1,7 +1,6 @@ [package] name = "resolver-tests" version = "0.1.0" -authors = ["Alex Crichton "] edition = "2018" [dependencies] diff -Nru cargo-0.58.0/debian/changelog cargo-0.60.0ubuntu1/debian/changelog --- cargo-0.58.0/debian/changelog 2022-01-25 06:45:44.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/changelog 2022-06-08 08:57:35.000000000 +0000 @@ -1,8 +1,18 @@ -cargo (0.58.0-0ubuntu1~21.10.1) impish; urgency=medium +cargo (0.60.0ubuntu1-0ubuntu1~21.10.1) impish; urgency=medium - * Backport to Impish. (LP: #1952104) + * Backport to impish (LP: #1968345) - -- Michael Hudson-Doyle Tue, 25 Jan 2022 19:45:44 +1300 + -- Simon Chopin Wed, 08 Jun 2022 10:57:35 +0200 + +cargo (0.60.0ubuntu1-0ubuntu1) kinetic; urgency=medium + + * Add an explicit mechanism to customize the vendoring process + * New upstream release: + - d/copyright: exclude the vendored benchmark workspaces + - d/copyright: Document new vendored crates + - d/p/{filetime-pr-75, libc-pr-2642}.patch: deleted, merged upstream + + -- Simon Chopin Wed, 08 Jun 2022 10:41:56 +0200 cargo (0.58.0-0ubuntu1) jammy; urgency=medium diff -Nru cargo-0.58.0/debian/copyright cargo-0.60.0ubuntu1/debian/copyright --- cargo-0.58.0/debian/copyright 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/copyright 2022-06-08 08:41:49.000000000 +0000 @@ -1,6 +1,10 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: cargo Source: https://github.com/rust-lang/cargo +Files-Excluded: +# We exclude the bench workspaces as they are full projects with their own +# copyright issues + benches/workspaces/* Files: crates/* @@ -266,6 +270,10 @@ * see https://github.com/withoutboats/failure * see https://github.com/withoutboats/failure_derive +Files: vendor/fastrand/* +Copyright: 2020 Stjepan Glavina +License: MIT or Apache-2.0 + Files: vendor/fuchsia-cprng/* Copyright: 2018 The Fuchsia Authors @@ -406,6 +414,12 @@ License: MIT Comment: see https://github.com/sfackler/rust-openssl +Files: vendor/os_info/* +Copyright: + 2017-2020 Jan Schulte + 2017-2022 Stanislav Tkach +License: MIT + Files: vendor/pretty_env_logger/* Copyright: 2016-2019 Sean McArthur License: MIT or Apache-2.0 diff -Nru cargo-0.58.0/debian/debcargo-ubuntu/0001-libgit2-re-enable-the-C-library-vendoring.patch cargo-0.60.0ubuntu1/debian/debcargo-ubuntu/0001-libgit2-re-enable-the-C-library-vendoring.patch --- cargo-0.58.0/debian/debcargo-ubuntu/0001-libgit2-re-enable-the-C-library-vendoring.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/debcargo-ubuntu/0001-libgit2-re-enable-the-C-library-vendoring.patch 2022-06-01 13:24:10.000000000 +0000 @@ -0,0 +1,37 @@ +From 81f1ea4eca200c53ec89fc07dea9f21fd3702432 Mon Sep 17 00:00:00 2001 +From: Simon Chopin +Date: Wed, 20 Apr 2022 11:28:48 +0200 +Subject: [PATCH] libgit2: re-enable the C library vendoring + +This crate follows the C library very closely, which makes backporting +cargo to older releases pretty much impossible as libgit2 in those +releases doesn't have many of the APIs exposed in this crate, leading to +linker errors. Bundling the C lib is the path of least resistance. +--- + src/libgit2-sys/debian/debcargo.toml | 2 +- + src/libgit2-sys/debian/patches/series | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/libgit2-sys/debian/debcargo.toml b/src/libgit2-sys/debian/debcargo.toml +index 75f4d6ae1..9cb954489 100644 +--- a/src/libgit2-sys/debian/debcargo.toml ++++ b/src/libgit2-sys/debian/debcargo.toml +@@ -1,6 +1,5 @@ + overlay = "." + uploaders = ["Ximin Luo "] +-excludes = ["libgit2/**"] + collapse_features = true + + [packages.lib] +diff --git a/src/libgit2-sys/debian/patches/series b/src/libgit2-sys/debian/patches/series +index 6eaa45026..f1b8f3d85 100644 +--- a/src/libgit2-sys/debian/patches/series ++++ b/src/libgit2-sys/debian/patches/series +@@ -1,3 +1,3 @@ + no-special-snowflake-env.patch + remove-zlib-ng-compat.patch +-disable-vendor.patch ++# disable-vendor.patch +-- +2.34.1 + diff -Nru cargo-0.58.0/debian/debcargo-ubuntu/README cargo-0.60.0ubuntu1/debian/debcargo-ubuntu/README --- cargo-0.58.0/debian/debcargo-ubuntu/README 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/debcargo-ubuntu/README 2022-06-01 13:24:10.000000000 +0000 @@ -0,0 +1,2 @@ +This directory is to store patches to the debcargo conf that are applied when +generating the vendor tarball for the Ubuntu release. diff -Nru cargo-0.58.0/debian/debcargo-ubuntu/series cargo-0.60.0ubuntu1/debian/debcargo-ubuntu/series --- cargo-0.58.0/debian/debcargo-ubuntu/series 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/debcargo-ubuntu/series 2022-06-01 13:24:10.000000000 +0000 @@ -0,0 +1 @@ +0001-libgit2-re-enable-the-C-library-vendoring.patch diff -Nru cargo-0.58.0/debian/gbp.conf cargo-0.60.0ubuntu1/debian/gbp.conf --- cargo-0.58.0/debian/gbp.conf 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/gbp.conf 2022-06-08 08:41:49.000000000 +0000 @@ -10,6 +10,6 @@ ignore-branch = True sign-tags = True -[import-orig] -upstream-vcs-tag = %(version)s -debian-branch = debian/experimental +# [import-orig] +# upstream-vcs-tag = %(version)s +# debian-branch = debian/experimental diff -Nru cargo-0.58.0/debian/patches/2111-curl-no-rebuild.patch cargo-0.60.0ubuntu1/debian/patches/2111-curl-no-rebuild.patch --- cargo-0.58.0/debian/patches/2111-curl-no-rebuild.patch 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/patches/2111-curl-no-rebuild.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -Already in debcargo-conf.git, can be deleted for next source import. - ---- a/vendor/curl-sys/build.rs -+++ b/vendor/curl-sys/build.rs -@@ -4,7 +4,6 @@ - use std::process::Command; - - fn main() { -- println!("cargo:rerun-if-changed=curl"); - let host = env::var("HOST").unwrap(); - let target = env::var("TARGET").unwrap(); - let windows = target.contains("windows"); diff -Nru cargo-0.58.0/debian/patches/filetime-pr-75.patch cargo-0.60.0ubuntu1/debian/patches/filetime-pr-75.patch --- cargo-0.58.0/debian/patches/filetime-pr-75.patch 2022-01-24 21:24:43.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/patches/filetime-pr-75.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -From 4bf69e074b288cd99965884c4501aa198efe9e3c Mon Sep 17 00:00:00 2001 -From: Alain Zscheile -Date: Mon, 13 Dec 2021 16:34:28 +0100 -Subject: [PATCH] mark some functions as `const fn`, and some fix compiler - warnings (#75) - -* mark fixed init functions and getters as const - -* fix compiler warnings ---- - src/lib.rs | 14 +++++++------- - src/unix/utimes.rs | 1 + - 2 files changed, 8 insertions(+), 7 deletions(-) - -diff --git a/vendor/filetime/src/lib.rs b/vendor/filetime/src/lib.rs -index e29050e..817915c 100644 ---- a/vendor/filetime/src/lib.rs -+++ b/vendor/filetime/src/lib.rs -@@ -71,14 +71,14 @@ impl FileTime { - /// Creates a new timestamp representing a 0 time. - /// - /// Useful for creating the base of a cmp::max chain of times. -- pub fn zero() -> FileTime { -+ pub const fn zero() -> FileTime { - FileTime { - seconds: 0, - nanos: 0, - } - } - -- fn emulate_second_only_system(self) -> FileTime { -+ const fn emulate_second_only_system(self) -> FileTime { - if cfg!(emulate_second_only_system) { - FileTime { - seconds: self.seconds, -@@ -118,7 +118,7 @@ impl FileTime { - /// from, but on Windows the native time stamp is relative to January 1, - /// 1601 so the return value of `seconds` from the returned `FileTime` - /// instance may not be the same as that passed in. -- pub fn from_unix_time(seconds: i64, nanos: u32) -> FileTime { -+ pub const fn from_unix_time(seconds: i64, nanos: u32) -> FileTime { - FileTime { - seconds: seconds + if cfg!(windows) { 11644473600 } else { 0 }, - nanos, -@@ -193,7 +193,7 @@ impl FileTime { - /// Note that this value's meaning is **platform specific**. On Unix - /// platform time stamps are typically relative to January 1, 1970, but on - /// Windows platforms time stamps are relative to January 1, 1601. -- pub fn seconds(&self) -> i64 { -+ pub const fn seconds(&self) -> i64 { - self.seconds - } - -@@ -202,7 +202,7 @@ impl FileTime { - /// - /// Note that this does not return the same value as `seconds` for Windows - /// platforms as seconds are relative to a different date there. -- pub fn unix_seconds(&self) -> i64 { -+ pub const fn unix_seconds(&self) -> i64 { - self.seconds - if cfg!(windows) { 11644473600 } else { 0 } - } - -@@ -211,7 +211,7 @@ impl FileTime { - /// The returned value is always less than one billion and represents a - /// portion of a second forward from the seconds returned by the `seconds` - /// method. -- pub fn nanoseconds(&self) -> u32 { -+ pub const fn nanoseconds(&self) -> u32 { - self.nanos - } - } -@@ -630,7 +630,7 @@ mod tests { - fn set_symlink_dir_times_test() { - let td = Builder::new().prefix("filetime").tempdir().unwrap(); - let path = td.path().join("foo"); -- fs::create_dir(&path); -+ fs::create_dir(&path).unwrap(); - - let metadata = fs::metadata(&path).unwrap(); - let mtime = FileTime::from_last_modification_time(&metadata); -diff --git a/vendor/filetime/src/unix/utimes.rs b/vendor/filetime/src/unix/utimes.rs -index 9926921..34bb882 100644 ---- a/vendor/filetime/src/unix/utimes.rs -+++ b/vendor/filetime/src/unix/utimes.rs -@@ -118,6 +118,7 @@ fn to_timeval(ft: &FileTime) -> libc::timeval { - } - } - -+#[cfg(target_env = "uclibc")] - fn to_timespec(ft: &FileTime) -> libc::timespec { - libc::timespec { - tv_sec: ft.seconds() as libc::time_t, diff -Nru cargo-0.58.0/debian/patches/libc-pr-2642.patch cargo-0.60.0ubuntu1/debian/patches/libc-pr-2642.patch --- cargo-0.58.0/debian/patches/libc-pr-2642.patch 2022-01-24 22:18:20.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/patches/libc-pr-2642.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ -From da84eefd712167bac47c904de3ac6056521c7f18 Mon Sep 17 00:00:00 2001 -From: Tamir Duberstein -Date: Sat, 22 Jan 2022 08:13:30 -0500 -Subject: [PATCH] Define ip_mreqn on all Linux platforms - -Updates #1558. ---- - libc-test/build.rs | 5 +++++ - libc-test/semver/linux-aarch64.txt | 1 - - libc-test/semver/linux-i686.txt | 1 - - libc-test/semver/linux-mips.txt | 1 - - libc-test/semver/linux-powerpc.txt | 1 - - libc-test/semver/linux-powerpc64.txt | 1 - - libc-test/semver/linux-powerpc64le.txt | 1 - - libc-test/semver/linux-riscv64gc.txt | 1 - - libc-test/semver/linux-x86_64.txt | 1 - - libc-test/semver/linux.txt | 1 + - src/unix/linux_like/android/mod.rs | 6 ------ - src/unix/linux_like/linux/gnu/b32/mod.rs | 6 ------ - src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs | 6 ------ - src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs | 6 ------ - src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs | 6 ------ - src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 6 ------ - src/unix/linux_like/linux/musl/mod.rs | 6 ------ - src/unix/linux_like/mod.rs | 6 ++++++ - 18 files changed, 12 insertions(+), 50 deletions(-) - ---- a/vendor/libc/src/unix/linux_like/android/mod.rs -+++ b/vendor/libc/src/unix/linux_like/android/mod.rs -@@ -73,12 +73,6 @@ - pub cmsg_type: ::c_int, - } - -- pub struct ip_mreqn { -- pub imr_multiaddr: ::in_addr, -- pub imr_address: ::in_addr, -- pub imr_ifindex: ::c_int, -- } -- - pub struct termios { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, ---- a/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs -+++ b/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs -@@ -135,12 +135,6 @@ - pub _f: [::c_char; 8], - } - -- pub struct ip_mreqn { -- pub imr_multiaddr: ::in_addr, -- pub imr_address: ::in_addr, -- pub imr_ifindex: ::c_int, -- } -- - pub struct semid_ds { - pub sem_perm: ipc_perm, - #[cfg(target_arch = "powerpc")] ---- a/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs -+++ b/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs -@@ -197,12 +197,6 @@ - pub ss_size: ::size_t - } - -- pub struct ip_mreqn { -- pub imr_multiaddr: ::in_addr, -- pub imr_address: ::in_addr, -- pub imr_ifindex: ::c_int, -- } -- - pub struct seccomp_notif_sizes { - pub seccomp_notif: ::__u16, - pub seccomp_notif_resp: ::__u16, ---- a/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs -+++ b/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs -@@ -191,12 +191,6 @@ - pub ss_flags: ::c_int, - pub ss_size: ::size_t - } -- -- pub struct ip_mreqn { -- pub imr_multiaddr: ::in_addr, -- pub imr_address: ::in_addr, -- pub imr_ifindex: ::c_int, -- } - } - - pub const POSIX_FADV_DONTNEED: ::c_int = 4; ---- a/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs -+++ b/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs -@@ -192,12 +192,6 @@ - pub l_len: ::off64_t, - pub l_pid: ::pid_t, - } -- -- pub struct ip_mreqn { -- pub imr_multiaddr: ::in_addr, -- pub imr_address: ::in_addr, -- pub imr_ifindex: ::c_int, -- } - } - - pub const POSIX_FADV_DONTNEED: ::c_int = 4; ---- a/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs -+++ b/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs -@@ -260,12 +260,6 @@ - __unused5: u64 - } - -- pub struct ip_mreqn { -- pub imr_multiaddr: ::in_addr, -- pub imr_address: ::in_addr, -- pub imr_ifindex: ::c_int, -- } -- - pub struct seccomp_notif_sizes { - pub seccomp_notif: ::__u16, - pub seccomp_notif_resp: ::__u16, ---- a/vendor/libc/src/unix/linux_like/linux/musl/mod.rs -+++ b/vendor/libc/src/unix/linux_like/linux/musl/mod.rs -@@ -218,12 +218,6 @@ - pub rt_irtt: ::c_ushort, - } - -- pub struct ip_mreqn { -- pub imr_multiaddr: ::in_addr, -- pub imr_address: ::in_addr, -- pub imr_ifindex: ::c_int, -- } -- - pub struct __exit_status { - pub e_termination: ::c_short, - pub e_exit: ::c_short, ---- a/vendor/libc/src/unix/linux_like/mod.rs -+++ b/vendor/libc/src/unix/linux_like/mod.rs -@@ -25,6 +25,12 @@ - pub imr_interface: in_addr, - } - -+ pub struct ip_mreqn { -+ pub imr_multiaddr: in_addr, -+ pub imr_address: in_addr, -+ pub imr_ifindex: ::c_int, -+ } -+ - pub struct ip_mreq_source { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, diff -Nru cargo-0.58.0/debian/patches/series cargo-0.60.0ubuntu1/debian/patches/series --- cargo-0.58.0/debian/patches/series 2022-01-24 22:18:20.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/patches/series 2022-06-08 08:41:49.000000000 +0000 @@ -1,5 +1,2 @@ 2002_disable-net-tests.patch -2111-curl-no-rebuild.patch 2112-handle-4-siphasher-algorithms.patch -filetime-pr-75.patch -libc-pr-2642.patch diff -Nru cargo-0.58.0/debian/scripts/audit-vendor-source cargo-0.60.0ubuntu1/debian/scripts/audit-vendor-source --- cargo-0.58.0/debian/scripts/audit-vendor-source 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/scripts/audit-vendor-source 2022-06-01 13:24:10.000000000 +0000 @@ -14,7 +14,7 @@ shift 2 # everything else is args to suspicious-source # Remove tiny files 4 bytes or less -find . -size -4c -delete +find . -type f -size -4c -delete # Remove non-suspicious files, warning on patterns that match nothing echo "Excluding (i.e. removing) whitelisted files..." grep -v '^#' "$whitelist" | xargs -I% sh -c 'rm -r ./% || true' diff -Nru cargo-0.58.0/debian/scripts/debian-cargo-vendor cargo-0.60.0ubuntu1/debian/scripts/debian-cargo-vendor --- cargo-0.58.0/debian/scripts/debian-cargo-vendor 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/debian/scripts/debian-cargo-vendor 2022-06-01 13:24:10.000000000 +0000 @@ -58,6 +58,12 @@ if [ -d debcargo-conf ]; then ( cd debcargo-conf && git pull ); else git clone "${DEBCARGO_CONF:-https://salsa.debian.org/rust-team/debcargo-conf}"; fi +cd debcargo-conf +# quilt returns 2 if no series is detected +QUILT_PATCHES=$SRCDIR/debian/debcargo-ubuntu quilt pop -vaf || if [ "$?" -ne 2 ]; then exit 1; fi +QUILT_PATCHES=$SRCDIR/debian/debcargo-ubuntu quilt push -va || if [ "$?" -ne 2 ]; then exit 1; fi +cd .. + # keep applying patches, and drop to a subshell for manual fixing, until it succeeds while ! ( cd vendor x=true diff -Nru cargo-0.58.0/.github/ISSUE_TEMPLATE/bug_report.md cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/bug_report.md --- cargo-0.58.0/.github/ISSUE_TEMPLATE/bug_report.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/bug_report.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -labels: C-bug ---- - - - -**Problem** - - - -**Steps** - -1. -2. -3. - -**Possible Solution(s)** - - - -**Notes** - -Output of `cargo version --verbose`: - - - diff -Nru cargo-0.58.0/.github/ISSUE_TEMPLATE/bug_report.yml cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/bug_report.yml --- cargo-0.58.0/.github/ISSUE_TEMPLATE/bug_report.yml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/bug_report.yml 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,43 @@ +name: Bug Report +description: Create a report to help us improve +labels: ["C-bug"] +body: + - type: markdown + attributes: + value: Thanks for filing a 🐛 bug report 😄! + - type: textarea + id: problem + attributes: + label: Problem + description: > + Please provide a clear and concise description of what the bug is, + including what currently happens and what you expected to happen. + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps + description: Please list the steps to reproduce the bug. + placeholder: | + 1. + 2. + 3. + - type: textarea + id: possible-solutions + attributes: + label: Possible Solution(s) + description: > + Not obligatory, but suggest a fix/reason for the bug, + or ideas how to implement the addition or change. + - type: textarea + id: notes + attributes: + label: Notes + description: Provide any additional notes that might be helpful. + - type: textarea + id: version + attributes: + label: Version + description: Please paste the output of running `cargo version --verbose`. + render: text diff -Nru cargo-0.58.0/.github/ISSUE_TEMPLATE/config.yml cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/config.yml --- cargo-0.58.0/.github/ISSUE_TEMPLATE/config.yml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/config.yml 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,10 @@ +contact_links: + - name: Question + url: https://users.rust-lang.org + about: > + Got a question about Cargo? Ask the community on the user forum. + - name: Inspiring Idea + url: https://internals.rust-lang.org/c/tools-and-infrastructure/cargo + about: > + Need more discussions with your next big idea? + Reach out the coummunity on the internals forum. diff -Nru cargo-0.58.0/.github/ISSUE_TEMPLATE/feature_request.md cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/feature_request.md --- cargo-0.58.0/.github/ISSUE_TEMPLATE/feature_request.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/feature_request.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -labels: C-feature-request ---- - - - -**Describe the problem you are trying to solve** - - -**Describe the solution you'd like** - - -**Notes** - diff -Nru cargo-0.58.0/.github/ISSUE_TEMPLATE/feature_request.yml cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/feature_request.yml --- cargo-0.58.0/.github/ISSUE_TEMPLATE/feature_request.yml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/feature_request.yml 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,35 @@ +name: Feature Request +description: Suggest an idea for enhancing Cargo +labels: ["C-feature-request"] +body: + - type: markdown + attributes: + value: | + Thanks for filing a 🙋 feature request 😄! + + If the feature request is relatively small and already with a possible solution, this might be the place for you. + + If you are brewing a big feature that needs feedback from the community, [the internal forum] is the best fit, especially for pre-RFC. You can also talk the idea over with other developers in [#t-cargo Zulip stream]. + + [the internal forum]: https://internals.rust-lang.org/c/tools-and-infrastructure/cargo/15 + [#t-cargo Zulip stream]: https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo + - type: textarea + id: problem + attributes: + label: Problem + description: > + Please provide a clear description of your use case and the problem + this feature request is trying to solve. + validations: + required: true + - type: textarea + id: solution + attributes: + label: Proposed Solution + description: > + Please provide a clear and concise description of what you want to happen. + - type: textarea + id: notes + attributes: + label: Notes + description: Provide any additional context or information that might be helpful. diff -Nru cargo-0.58.0/.github/ISSUE_TEMPLATE/tracking_issue.md cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/tracking_issue.md --- cargo-0.58.0/.github/ISSUE_TEMPLATE/tracking_issue.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/tracking_issue.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ ---- -name: Tracking Issue -about: A tracking issue for an accepted feature or RFC in Cargo. -title: Tracking Issue for XXX -labels: C-tracking-issue ---- - - -**Summary** - -RFC: [#NNNN](https://github.com/rust-lang/rfcs/pull/NNNN) -Original issue: #NNNN -Implementation: #NNNN -Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#my-feature - - - -**Unresolved issues** - -* [ ] Make a list of any known implementation or design issues. - -**Future extensions** - - - -**About tracking issues** - -Tracking issues are used to record the overall progress of implementation. -They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. -A tracking issue is however *not* meant for large scale discussion, questions, or bug reports about a feature. -Instead, open a dedicated issue for the specific matter and add the relevant feature gate label. diff -Nru cargo-0.58.0/.github/ISSUE_TEMPLATE/tracking_issue.yml cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/tracking_issue.yml --- cargo-0.58.0/.github/ISSUE_TEMPLATE/tracking_issue.yml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/.github/ISSUE_TEMPLATE/tracking_issue.yml 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,50 @@ +name: Tracking Issue +description: A tracking issue for an accepted feature or RFC in Cargo. +title: "Tracking Issue for _FEATURE_NAME_" +labels: ["C-tracking-issue"] +body: + - type: markdown + attributes: + value: > + Thank you for creating a tracking issue! Tracking issues are for tracking an + accepted feature or RFC from implementation to stabilization. Please do not + file a tracking issue until the feature or RFC has been approved. + - type: textarea + id: summary + attributes: + label: Summary + description: Please provide a very brief summary of the feature. + value: | + RFC: [#NNNN](https://github.com/rust-lang/rfcs/pull/NNNN) + Original issue: #NNNN + Implementation: #NNNN + Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#my-feature + + Please enter a short, one-sentence description here. + validations: + required: true + - type: textarea + id: unresolved + attributes: + label: Unresolved Issues + description: List issues that have not yet been resolved. + placeholder: | + * [ ] Make a list of any known implementation or design issues. + - type: textarea + id: future + attributes: + label: Future Extensions + description: > + An optional section where you can mention where the feature may be + extended in the future, but is explicitly not intended to + address. + - type: textarea + id: about + attributes: + label: About tracking issues + description: Please include this notice in the issue. + value: | + Tracking issues are used to record the overall progress of implementation. + They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. + A tracking issue is however *not* meant for large scale discussion, questions, or bug reports about a feature. + Instead, open a dedicated issue for the specific matter and add the relevant feature gate label. diff -Nru cargo-0.58.0/.github/PULL_REQUEST_TEMPLATE.md cargo-0.60.0ubuntu1/.github/PULL_REQUEST_TEMPLATE.md --- cargo-0.58.0/.github/PULL_REQUEST_TEMPLATE.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/.github/PULL_REQUEST_TEMPLATE.md 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,36 @@ + diff -Nru cargo-0.58.0/.github/workflows/main.yml cargo-0.60.0ubuntu1/.github/workflows/main.yml --- cargo-0.58.0/.github/workflows/main.yml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/.github/workflows/main.yml 2022-02-10 02:58:21.000000000 +0000 @@ -19,7 +19,7 @@ - run: rustup component add rustfmt - run: cargo fmt --all -- --check - run: | - for manifest in `find crates -name Cargo.toml` + for manifest in `find crates benches/benchsuite benches/capture -name Cargo.toml` do echo check fmt for $manifest cargo fmt --all --manifest-path $manifest -- --check @@ -68,7 +68,9 @@ # Deny warnings on CI to avoid warnings getting into the codebase. - run: cargo test --features 'deny-warnings' - - run: cargo test --features 'deny-warnings' -p cargo-test-support + - run: cargo test --features 'deny-warnings' --manifest-path crates/cargo-test-support/Cargo.toml + env: + CARGO_TARGET_DIR: target - run: cargo test -p cargo-platform - run: cargo test -p cargo-util - run: cargo test --manifest-path crates/mdman/Cargo.toml @@ -79,6 +81,15 @@ if: matrix.os == 'macos-latest' - run: cargo build --manifest-path crates/credential/cargo-credential-wincred/Cargo.toml if: matrix.os == 'windows-latest' + - name: Check benchmarks + env: + # Share the target dir to try to cache a few build-time deps. + CARGO_TARGET_DIR: target + run: | + # This only tests one benchmark since it can take over 10 minutes to + # download all workspaces. + cargo test --manifest-path benches/benchsuite/Cargo.toml --all-targets -- cargo + cargo check --manifest-path benches/capture/Cargo.toml - name: Fetch smoke test run: ci/fetch-smoke-test.sh @@ -104,6 +115,7 @@ steps: - uses: actions/checkout@v2 - run: rustup update nightly && rustup default nightly + - run: rustup update stable - run: rustup component add rust-docs - run: ci/validate-man.sh # This requires rustfmt, use stable. diff -Nru cargo-0.58.0/src/bin/cargo/cli.rs cargo-0.60.0ubuntu1/src/bin/cargo/cli.rs --- cargo-0.58.0/src/bin/cargo/cli.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/cli.rs 2022-02-10 02:58:21.000000000 +0000 @@ -15,10 +15,10 @@ // Maps from commonly known external commands (not builtin to cargo) to their // description, for the help page. Reserved for external subcommands that are // core within the rust ecosystem (esp ones that might become internal in the future). - static ref KNOWN_EXTERNAL_COMMAND_DESCRIPTIONS: HashMap<&'static str, &'static str> = vec![ + static ref KNOWN_EXTERNAL_COMMAND_DESCRIPTIONS: HashMap<&'static str, &'static str> = HashMap::from([ ("clippy", "Checks a package to catch common mistakes and improve your Rust code."), ("fmt", "Formats all bin and lib files of the current crate using rustfmt."), - ].into_iter().collect(); + ]); } pub fn main(config: &mut Config) -> CliResult { @@ -65,7 +65,7 @@ .iter() .map(|(option_name, option_help_message)| { let option_name_kebab_case = option_name.replace("_", "-"); - let padding = " ".repeat(longest_option - option_name.len()); // safe to substract + let padding = " ".repeat(longest_option - option_name.len()); // safe to subtract format!( " -Z {}{} -- {}", option_name_kebab_case, padding, option_help_message @@ -139,7 +139,12 @@ } } CommandInfo::Alias { target } => { - drop_println!(config, " {:<20} {}", name, target.iter().join(" ")); + drop_println!( + config, + " {:<20} alias: {}", + name, + target.iter().join(" ") + ); } } } @@ -164,10 +169,7 @@ let version = cargo::version(); let mut version_string = format!("cargo {}\n", version); if is_verbose { - version_string.push_str(&format!( - "release: {}.{}.{}\n", - version.major, version.minor, version.patch - )); + version_string.push_str(&format!("release: {}\n", version.version,)); if let Some(ref cfg) = version.cfg_info { if let Some(ref ci) = cfg.commit_info { version_string.push_str(&format!("commit-hash: {}\n", ci.commit_hash)); @@ -261,6 +263,21 @@ } (None, None) => {} (_, Some(mut alias)) => { + // Check if this alias is shadowing an external subcommand + // (binary of the form `cargo-`) + // Currently this is only a warning, but after a transition period this will become + // a hard error. + if let Some(path) = super::find_external_subcommand(config, cmd) { + config.shell().warn(format!( + "\ +user-defined alias `{}` is shadowing an external subcommand found at: `{}` +This was previously accepted but is being phased out; it will become a hard error in a future release. +For more information, see issue #10049 .", + cmd, + path.display(), + ))?; + } + alias.extend( args.values_of("") .unwrap_or_default() @@ -438,7 +455,7 @@ .multiple(true) .global(true), ) - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg( opt("color", "Coloring: auto, always, never") .value_name("WHEN") diff -Nru cargo-0.58.0/src/bin/cargo/commands/bench.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/bench.rs --- cargo-0.58.0/src/bin/cargo/commands/bench.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/bench.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ subcommand("bench") .setting(AppSettings::TrailingVarArg) .about("Execute all benchmarks of a local package") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg( Arg::with_name("BENCHNAME") .help("If specified, only run benches containing this string in their names"), diff -Nru cargo-0.58.0/src/bin/cargo/commands/build.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/build.rs --- cargo-0.58.0/src/bin/cargo/commands/build.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/build.rs 2022-02-10 02:58:21.000000000 +0000 @@ -7,7 +7,7 @@ // subcommand aliases are handled in aliased_command() // .alias("b") .about("Compile a local package and all of its dependencies") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_package_spec( "Package to build (see `cargo help pkgid`)", "Build all packages in the workspace", diff -Nru cargo-0.58.0/src/bin/cargo/commands/check.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/check.rs --- cargo-0.58.0/src/bin/cargo/commands/check.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/check.rs 2022-02-10 02:58:21.000000000 +0000 @@ -7,7 +7,7 @@ // subcommand aliases are handled in aliased_command() // .alias("c") .about("Check a local package and all of its dependencies for errors") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_package_spec( "Package(s) to check", "Check all packages in the workspace", diff -Nru cargo-0.58.0/src/bin/cargo/commands/clean.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/clean.rs --- cargo-0.58.0/src/bin/cargo/commands/clean.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/clean.rs 2022-02-10 02:58:21.000000000 +0000 @@ -6,7 +6,7 @@ pub fn cli() -> App { subcommand("clean") .about("Remove artifacts that cargo has generated in the past") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_package_spec_simple("Package to clean artifacts for") .arg_manifest_path() .arg_target_triple("Target triple to clean output for") diff -Nru cargo-0.58.0/src/bin/cargo/commands/doc.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/doc.rs --- cargo-0.58.0/src/bin/cargo/commands/doc.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/doc.rs 2022-02-10 02:58:21.000000000 +0000 @@ -7,7 +7,7 @@ // subcommand aliases are handled in aliased_command() // .alias("d") .about("Build a package's documentation") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(opt( "open", "Opens the docs in a browser after the operation", diff -Nru cargo-0.58.0/src/bin/cargo/commands/fetch.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/fetch.rs --- cargo-0.58.0/src/bin/cargo/commands/fetch.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/fetch.rs 2022-02-10 02:58:21.000000000 +0000 @@ -6,7 +6,7 @@ pub fn cli() -> App { subcommand("fetch") .about("Fetch dependencies of a package from the network") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_manifest_path() .arg_target_triple("Fetch dependencies for the target triple") .after_help("Run `cargo help fetch` for more detailed information.\n") diff -Nru cargo-0.58.0/src/bin/cargo/commands/fix.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/fix.rs --- cargo-0.58.0/src/bin/cargo/commands/fix.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/fix.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("fix") .about("Automatically fix lint warnings reported by rustc") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_package_spec( "Package(s) to fix", "Fix all packages in the workspace", diff -Nru cargo-0.58.0/src/bin/cargo/commands/generate_lockfile.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/generate_lockfile.rs --- cargo-0.58.0/src/bin/cargo/commands/generate_lockfile.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/generate_lockfile.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("generate-lockfile") .about("Generate the lockfile for a package") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_manifest_path() .after_help("Run `cargo help generate-lockfile` for more detailed information.\n") } diff -Nru cargo-0.58.0/src/bin/cargo/commands/help.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/help.rs --- cargo-0.58.0/src/bin/cargo/commands/help.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/help.rs 2022-02-10 02:58:21.000000000 +0000 @@ -1,6 +1,6 @@ use crate::aliased_command; use cargo::util::errors::CargoResult; -use cargo::Config; +use cargo::{drop_println, Config}; use cargo_util::paths::resolve_executable; use flate2::read::GzDecoder; use std::ffi::OsString; @@ -15,14 +15,14 @@ /// This runs before clap processing, because it needs to intercept the `help` /// command if a man page is available. /// -/// Returns `true` if a man page was displayed. In this case, Cargo should -/// exit. +/// Returns `true` if help information was successfully displayed to the user. +/// In this case, Cargo should exit. pub fn handle_embedded_help(config: &Config) -> bool { match try_help(config) { Ok(true) => true, Ok(false) => false, Err(e) => { - log::warn!("man failed: {:?}", e); + log::warn!("help failed: {:?}", e); false } } @@ -46,26 +46,43 @@ Some(s) => s, None => return Ok(false), }; - // Check if this is a built-in command (or alias); + let subcommand = match check_alias(config, subcommand) { + // If this alias is more than a simple subcommand pass-through, show the alias. + Some(argv) if argv.len() > 1 => { + let alias = argv.join(" "); + drop_println!(config, "`{}` is aliased to `{}`", subcommand, alias); + return Ok(true); + } + // Otherwise, resolve the alias into its subcommand. + Some(argv) => { + // An alias with an empty argv can be created via `"empty-alias" = ""`. + let first = argv.get(0).map(String::as_str).unwrap_or(subcommand); + first.to_string() + } + None => subcommand.to_string(), + }; + + let subcommand = match check_builtin(&subcommand) { Some(s) => s, None => return Ok(false), }; + if resolve_executable(Path::new("man")).is_ok() { - let man = match extract_man(&subcommand, "1") { + let man = match extract_man(subcommand, "1") { Some(man) => man, None => return Ok(false), }; - write_and_spawn(&subcommand, &man, "man")?; + write_and_spawn(subcommand, &man, "man")?; } else { - let txt = match extract_man(&subcommand, "txt") { + let txt = match extract_man(subcommand, "txt") { Some(txt) => txt, None => return Ok(false), }; if resolve_executable(Path::new("less")).is_ok() { - write_and_spawn(&subcommand, &txt, "less")?; + write_and_spawn(subcommand, &txt, "less")?; } else if resolve_executable(Path::new("more")).is_ok() { - write_and_spawn(&subcommand, &txt, "more")?; + write_and_spawn(subcommand, &txt, "more")?; } else { drop(std::io::stdout().write_all(&txt)); } @@ -73,24 +90,18 @@ Ok(true) } -/// Checks if the given subcommand is a built-in command (possibly via an alias). +/// Checks if the given subcommand is an alias. +/// +/// Returns None if it is not an alias. +fn check_alias(config: &Config, subcommand: &str) -> Option> { + aliased_command(config, subcommand).ok().flatten() +} + +/// Checks if the given subcommand is a built-in command (not via an alias). /// /// Returns None if it is not a built-in command. -fn check_alias(config: &Config, subcommand: &str) -> Option { - if super::builtin_exec(subcommand).is_some() { - return Some(subcommand.to_string()); - } - match aliased_command(config, subcommand) { - Ok(Some(alias)) => { - let alias = alias.into_iter().next()?; - if super::builtin_exec(&alias).is_some() { - Some(alias) - } else { - None - } - } - _ => None, - } +fn check_builtin(subcommand: &str) -> Option<&str> { + super::builtin_exec(subcommand).map(|_| subcommand) } /// Extracts the given man page from the compressed archive. diff -Nru cargo-0.58.0/src/bin/cargo/commands/init.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/init.rs --- cargo-0.58.0/src/bin/cargo/commands/init.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/init.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("init") .about("Create a new cargo package in an existing directory") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("path").default_value(".")) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_new_opts() diff -Nru cargo-0.58.0/src/bin/cargo/commands/install.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/install.rs --- cargo-0.58.0/src/bin/cargo/commands/install.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/install.rs 2022-02-10 02:58:21.000000000 +0000 @@ -7,7 +7,7 @@ pub fn cli() -> App { subcommand("install") .about("Install a Rust binary. Default location is $HOME/.cargo/bin") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("crate").empty_values(false).multiple(true)) .arg( opt("version", "Specify a version to install") @@ -71,6 +71,7 @@ .requires("crate") .conflicts_with_all(&["git", "path", "index"]), ) + .arg_message_format() .after_help("Run `cargo help install` for more detailed information.\n") } diff -Nru cargo-0.58.0/src/bin/cargo/commands/locate_project.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/locate_project.rs --- cargo-0.58.0/src/bin/cargo/commands/locate_project.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/locate_project.rs 2022-02-10 02:58:21.000000000 +0000 @@ -6,7 +6,7 @@ pub fn cli() -> App { subcommand("locate-project") .about("Print a JSON representation of a Cargo.toml file's location") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_manifest_path() .arg( opt( diff -Nru cargo-0.58.0/src/bin/cargo/commands/login.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/login.rs --- cargo-0.58.0/src/bin/cargo/commands/login.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/login.rs 2022-02-10 02:58:21.000000000 +0000 @@ -8,14 +8,8 @@ "Save an api token from the registry locally. \ If token is not specified, it will be read from stdin.", ) - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("token")) - // --host is deprecated (use --registry instead) - .arg( - opt("host", "Host to set the token for") - .value_name("HOST") - .hidden(true), - ) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .after_help("Run `cargo help login` for more detailed information.\n") } diff -Nru cargo-0.58.0/src/bin/cargo/commands/logout.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/logout.rs --- cargo-0.58.0/src/bin/cargo/commands/logout.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/logout.rs 2022-02-10 02:58:21.000000000 +0000 @@ -4,7 +4,7 @@ pub fn cli() -> App { subcommand("logout") .about("Remove an API token from the registry locally") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .after_help("Run `cargo help logout` for more detailed information.\n") } diff -Nru cargo-0.58.0/src/bin/cargo/commands/metadata.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/metadata.rs --- cargo-0.58.0/src/bin/cargo/commands/metadata.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/metadata.rs 2022-02-10 02:58:21.000000000 +0000 @@ -8,7 +8,7 @@ the concrete used versions including overrides, \ in machine-readable format", ) - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_features() .arg(multi_opt( "filter-platform", diff -Nru cargo-0.58.0/src/bin/cargo/commands/new.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/new.rs --- cargo-0.58.0/src/bin/cargo/commands/new.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/new.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("new") .about("Create a new cargo package at ") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("path").required(true)) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_new_opts() diff -Nru cargo-0.58.0/src/bin/cargo/commands/owner.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/owner.rs --- cargo-0.58.0/src/bin/cargo/commands/owner.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/owner.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("owner") .about("Manage the owners of a crate on the registry") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("crate")) .arg( multi_opt( diff -Nru cargo-0.58.0/src/bin/cargo/commands/package.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/package.rs --- cargo-0.58.0/src/bin/cargo/commands/package.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/package.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("package") .about("Assemble the local package into a distributable tarball") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg( opt( "list", diff -Nru cargo-0.58.0/src/bin/cargo/commands/pkgid.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/pkgid.rs --- cargo-0.58.0/src/bin/cargo/commands/pkgid.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/pkgid.rs 2022-02-10 02:58:21.000000000 +0000 @@ -6,7 +6,7 @@ pub fn cli() -> App { subcommand("pkgid") .about("Print a fully qualified package specification") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("spec")) .arg_package("Argument to get the package ID specifier for") .arg_manifest_path() diff -Nru cargo-0.58.0/src/bin/cargo/commands/publish.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/publish.rs --- cargo-0.58.0/src/bin/cargo/commands/publish.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/publish.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("publish") .about("Upload a package to the registry") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_index() .arg(opt("token", "Token to use when uploading").value_name("TOKEN")) .arg(opt( @@ -32,7 +32,7 @@ let registry = args.registry(config)?; let ws = args.workspace(config)?; - let index = args.index(config)?; + let index = args.index()?; ops::publish( &ws, diff -Nru cargo-0.58.0/src/bin/cargo/commands/read_manifest.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/read_manifest.rs --- cargo-0.58.0/src/bin/cargo/commands/read_manifest.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/read_manifest.rs 2022-02-10 02:58:21.000000000 +0000 @@ -9,7 +9,7 @@ Deprecated, use `cargo metadata --no-deps` instead.\ ", ) - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_manifest_path() } diff -Nru cargo-0.58.0/src/bin/cargo/commands/report.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/report.rs --- cargo-0.58.0/src/bin/cargo/commands/report.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/report.rs 2022-02-10 02:58:21.000000000 +0000 @@ -1,5 +1,4 @@ use crate::command_prelude::*; -use anyhow::anyhow; use cargo::core::compiler::future_incompat::{OnDiskReports, REPORT_PREAMBLE}; use cargo::drop_println; @@ -18,14 +17,12 @@ "identifier of the report generated by a Cargo command invocation", ) .value_name("id"), - ), + ) + .arg_package("Package to display a report for"), ) } pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { - if !config.nightly_features_allowed { - return Err(anyhow!("`cargo report` can only be used on the nightly channel").into()); - } match args.subcommand() { ("future-incompatibilities", Some(args)) => report_future_incompatibilies(config, args), (cmd, _) => panic!("unexpected command `{}`", cmd), @@ -38,7 +35,8 @@ let id = args .value_of_u32("id")? .unwrap_or_else(|| reports.last_id()); - let report = reports.get_report(id, config)?; + let krate = args.value_of("package"); + let report = reports.get_report(id, config, krate)?; drop_println!(config, "{}", REPORT_PREAMBLE); drop(config.shell().print_ansi_stdout(report.as_bytes())); Ok(()) diff -Nru cargo-0.58.0/src/bin/cargo/commands/run.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/run.rs --- cargo-0.58.0/src/bin/cargo/commands/run.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/run.rs 2022-02-10 02:58:21.000000000 +0000 @@ -10,7 +10,7 @@ // .alias("r") .setting(AppSettings::TrailingVarArg) .about("Run a binary or example of the local package") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("args").multiple(true)) .arg_targets_bin_example( "Name of the bin target to run", diff -Nru cargo-0.58.0/src/bin/cargo/commands/rustc.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/rustc.rs --- cargo-0.58.0/src/bin/cargo/commands/rustc.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/rustc.rs 2022-02-10 02:58:21.000000000 +0000 @@ -3,12 +3,13 @@ use cargo::util::interning::InternedString; const PRINT_ARG_NAME: &str = "print"; +const CRATE_TYPE_ARG_NAME: &str = "crate-type"; pub fn cli() -> App { subcommand("rustc") .setting(AppSettings::TrailingVarArg) .about("Compile a package, and pass extra options to the compiler") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("args").multiple(true).help("Rustc flags")) .arg_package("Package to build") .arg_jobs() @@ -35,6 +36,11 @@ ) .value_name("INFO"), ) + .arg(multi_opt( + CRATE_TYPE_ARG_NAME, + "CRATE-TYPE", + "Comma separated list of types of crates for the compiler to emit (unstable)", + )) .arg_target_dir() .arg_manifest_path() .arg_message_format() @@ -75,8 +81,18 @@ .cli_unstable() .fail_if_stable_opt(PRINT_ARG_NAME, 9357)?; ops::print(&ws, &compile_opts, opt_value)?; - } else { - ops::compile(&ws, &compile_opts)?; + return Ok(()); } + let crate_types = values(args, CRATE_TYPE_ARG_NAME); + compile_opts.target_rustc_crate_types = if crate_types.is_empty() { + None + } else { + config + .cli_unstable() + .fail_if_stable_opt(CRATE_TYPE_ARG_NAME, 10083)?; + Some(crate_types) + }; + ops::compile(&ws, &compile_opts)?; + Ok(()) } diff -Nru cargo-0.58.0/src/bin/cargo/commands/rustdoc.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/rustdoc.rs --- cargo-0.58.0/src/bin/cargo/commands/rustdoc.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/rustdoc.rs 2022-02-10 02:58:21.000000000 +0000 @@ -6,7 +6,7 @@ subcommand("rustdoc") .setting(AppSettings::TrailingVarArg) .about("Build a package's documentation, using specified custom flags.") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("args").multiple(true)) .arg(opt( "open", diff -Nru cargo-0.58.0/src/bin/cargo/commands/search.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/search.rs --- cargo-0.58.0/src/bin/cargo/commands/search.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/search.rs 2022-02-10 02:58:21.000000000 +0000 @@ -7,7 +7,7 @@ pub fn cli() -> App { subcommand("search") .about("Search packages in crates.io") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("query").multiple(true)) .arg_index() .arg( @@ -23,7 +23,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let registry = args.registry(config)?; - let index = args.index(config)?; + let index = args.index()?; let limit = args.value_of_u32("limit")?; let limit = min(100, limit.unwrap_or(10)); let query: Vec<&str> = args.values_of("query").unwrap_or_default().collect(); diff -Nru cargo-0.58.0/src/bin/cargo/commands/test.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/test.rs --- cargo-0.58.0/src/bin/cargo/commands/test.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/test.rs 2022-02-10 02:58:21.000000000 +0000 @@ -56,7 +56,10 @@ .arg_message_format() .arg_unit_graph() .arg_future_incompat_report() - .after_help("Run `cargo help test` for more detailed information.\n") + .after_help( + "Run `cargo help test` for more detailed information.\n\ + Run `cargo test -- --help` for test binary options.\n", + ) } pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { diff -Nru cargo-0.58.0/src/bin/cargo/commands/tree.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/tree.rs --- cargo-0.58.0/src/bin/cargo/commands/tree.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/tree.rs 2022-02-10 02:58:21.000000000 +0000 @@ -12,7 +12,7 @@ pub fn cli() -> App { subcommand("tree") .about("Display a tree visualization of a dependency graph") - .arg(opt("quiet", "Suppress status messages").short("q")) + .arg_quiet() .arg_manifest_path() .arg_package_spec_no_all( "Package to be used as the root of the tree", diff -Nru cargo-0.58.0/src/bin/cargo/commands/uninstall.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/uninstall.rs --- cargo-0.58.0/src/bin/cargo/commands/uninstall.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/uninstall.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("uninstall") .about("Remove a Rust binary") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("spec").multiple(true)) .arg_package_spec_simple("Package to uninstall") .arg(multi_opt("bin", "NAME", "Only uninstall the binary NAME")) diff -Nru cargo-0.58.0/src/bin/cargo/commands/update.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/update.rs --- cargo-0.58.0/src/bin/cargo/commands/update.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/update.rs 2022-02-10 02:58:21.000000000 +0000 @@ -6,7 +6,7 @@ pub fn cli() -> App { subcommand("update") .about("Update dependencies as recorded in the local lock file") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(opt("workspace", "Only update the workspace packages").short("w")) .arg_package_spec_simple("Package to update") .arg(opt( diff -Nru cargo-0.58.0/src/bin/cargo/commands/vendor.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/vendor.rs --- cargo-0.58.0/src/bin/cargo/commands/vendor.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/vendor.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("vendor") .about("Vendor all dependencies for a project locally") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_manifest_path() .arg(Arg::with_name("path").help("Where to vendor crates (`vendor` by default)")) .arg( diff -Nru cargo-0.58.0/src/bin/cargo/commands/verify_project.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/verify_project.rs --- cargo-0.58.0/src/bin/cargo/commands/verify_project.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/verify_project.rs 2022-02-10 02:58:21.000000000 +0000 @@ -6,7 +6,7 @@ pub fn cli() -> App { subcommand("verify-project") .about("Check correctness of crate manifest") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg_manifest_path() .after_help("Run `cargo help verify-project` for more detailed information.\n") } diff -Nru cargo-0.58.0/src/bin/cargo/commands/version.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/version.rs --- cargo-0.58.0/src/bin/cargo/commands/version.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/version.rs 2022-02-10 02:58:21.000000000 +0000 @@ -4,7 +4,7 @@ pub fn cli() -> App { subcommand("version") .about("Show version information") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .after_help("Run `cargo help version` for more detailed information.\n") } diff -Nru cargo-0.58.0/src/bin/cargo/commands/yank.rs cargo-0.60.0ubuntu1/src/bin/cargo/commands/yank.rs --- cargo-0.58.0/src/bin/cargo/commands/yank.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/commands/yank.rs 2022-02-10 02:58:21.000000000 +0000 @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("yank") .about("Remove a pushed crate from the index") - .arg(opt("quiet", "No output printed to stdout").short("q")) + .arg_quiet() .arg(Arg::with_name("crate")) .arg( opt("vers", "The version to yank or un-yank") diff -Nru cargo-0.58.0/src/bin/cargo/main.rs cargo-0.60.0ubuntu1/src/bin/cargo/main.rs --- cargo-0.58.0/src/bin/cargo/main.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/bin/cargo/main.rs 2022-02-10 02:58:21.000000000 +0000 @@ -147,12 +147,16 @@ commands } -fn execute_external_subcommand(config: &Config, cmd: &str, args: &[&str]) -> CliResult { +fn find_external_subcommand(config: &Config, cmd: &str) -> Option { let command_exe = format!("cargo-{}{}", cmd, env::consts::EXE_SUFFIX); - let path = search_directories(config) + search_directories(config) .iter() .map(|dir| dir.join(&command_exe)) - .find(|file| is_executable(file)); + .find(|file| is_executable(file)) +} + +fn execute_external_subcommand(config: &Config, cmd: &str, args: &[&str]) -> CliResult { + let path = find_external_subcommand(config, cmd); let command = match path { Some(command) => command, None => { diff -Nru cargo-0.58.0/src/cargo/core/compiler/build_config.rs cargo-0.60.0ubuntu1/src/cargo/core/compiler/build_config.rs --- cargo-0.58.0/src/cargo/core/compiler/build_config.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/build_config.rs 2022-02-10 02:58:21.000000000 +0000 @@ -149,6 +149,8 @@ Doc { deps: bool }, /// A target that will be tested with `rustdoc`. Doctest, + /// An example or library that will be scraped for function calls by `rustdoc`. + Docscrape, /// A marker for Units that represent the execution of a `build.rs` script. RunCustomBuild, } @@ -166,6 +168,7 @@ Bench => "bench".serialize(s), Doc { .. } => "doc".serialize(s), Doctest => "doctest".serialize(s), + Docscrape => "docscrape".serialize(s), RunCustomBuild => "run-custom-build".serialize(s), } } @@ -187,6 +190,11 @@ self == CompileMode::Doctest } + /// Returns `true` if this is scraping examples for documentation. + pub fn is_doc_scrape(self) -> bool { + self == CompileMode::Docscrape + } + /// Returns `true` if this is any type of test (test, benchmark, doc test, or /// check test). pub fn is_any_test(self) -> bool { @@ -211,4 +219,15 @@ pub fn is_run_custom_build(self) -> bool { self == CompileMode::RunCustomBuild } + + /// Returns `true` if this mode may generate an executable. + /// + /// Note that this also returns `true` for building libraries, so you also + /// have to check the target. + pub fn generates_executable(self) -> bool { + matches!( + self, + CompileMode::Test | CompileMode::Bench | CompileMode::Build + ) + } } diff -Nru cargo-0.58.0/src/cargo/core/compiler/build_context/mod.rs cargo-0.60.0ubuntu1/src/cargo/core/compiler/build_context/mod.rs --- cargo-0.58.0/src/cargo/core/compiler/build_context/mod.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/build_context/mod.rs 2022-02-10 02:58:21.000000000 +0000 @@ -33,6 +33,9 @@ /// Extra compiler args for either `rustc` or `rustdoc`. pub extra_compiler_args: HashMap>, + // Crate types for `rustc`. + pub target_rustc_crate_types: HashMap>, + /// Package downloader. /// /// This holds ownership of the `Package` objects. @@ -47,6 +50,9 @@ /// The dependency graph of units to compile. pub unit_graph: UnitGraph, + /// Reverse-dependencies of documented units, used by the rustdoc --scrape-examples flag. + pub scrape_units: Vec, + /// The list of all kinds that are involved in this build pub all_kinds: HashSet, } @@ -58,9 +64,11 @@ build_config: &'a BuildConfig, profiles: Profiles, extra_compiler_args: HashMap>, + target_rustc_crate_types: HashMap>, target_data: RustcTargetData<'cfg>, roots: Vec, unit_graph: UnitGraph, + scrape_units: Vec, ) -> CargoResult> { let all_kinds = unit_graph .keys() @@ -76,9 +84,11 @@ build_config, profiles, extra_compiler_args, + target_rustc_crate_types, target_data, roots, unit_graph, + scrape_units, all_kinds, }) } @@ -122,4 +132,8 @@ pub fn extra_args_for(&self, unit: &Unit) -> Option<&Vec> { self.extra_compiler_args.get(unit) } + + pub fn rustc_crate_types_args_for(&self, unit: &Unit) -> Option<&Vec> { + self.target_rustc_crate_types.get(unit) + } } diff -Nru cargo-0.58.0/src/cargo/core/compiler/build_context/target_info.rs cargo-0.60.0ubuntu1/src/cargo/core/compiler/build_context/target_info.rs --- cargo-0.58.0/src/cargo/core/compiler/build_context/target_info.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/build_context/target_info.rs 2022-02-10 02:58:21.000000000 +0000 @@ -47,8 +47,8 @@ pub rustdocflags: Vec, /// Whether or not rustc supports the `-Csplit-debuginfo` flag. pub supports_split_debuginfo: bool, - /// Whether or not rustc supports the `--force-warn` flag. Remove after 1.56 is stable. - pub supports_force_warn: bool, + /// Whether or not rustc supports the `--json future-incompat` flag. + pub supports_json_future_incompat: bool, } /// Kind of each file generated by a Unit, part of `FileType`. @@ -180,9 +180,12 @@ extra_fingerprint, ) .is_ok(); - let supports_force_warn = rustc + + let supports_json_future_incompat = rustc .cached_output( - process.clone().arg("--force-warn=rust-2021-compatibility"), + process + .clone() + .args(&["--error-format", "json", "--json", "future-incompat"]), extra_fingerprint, ) .is_ok(); @@ -261,7 +264,7 @@ )?, cfg, supports_split_debuginfo, - supports_force_warn, + supports_json_future_incompat, }) } @@ -461,7 +464,10 @@ } } CompileMode::Check { .. } => Ok((vec![FileType::new_rmeta()], Vec::new())), - CompileMode::Doc { .. } | CompileMode::Doctest | CompileMode::RunCustomBuild => { + CompileMode::Doc { .. } + | CompileMode::Doctest + | CompileMode::Docscrape + | CompileMode::RunCustomBuild => { panic!("asked for rustc output for non-rustc mode") } } diff -Nru cargo-0.58.0/src/cargo/core/compiler/context/compilation_files.rs cargo-0.60.0ubuntu1/src/cargo/core/compiler/context/compilation_files.rs --- cargo-0.58.0/src/cargo/core/compiler/context/compilation_files.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/context/compilation_files.rs 2022-02-10 02:58:21.000000000 +0000 @@ -191,7 +191,9 @@ /// Returns the directory where the artifacts for the given unit are /// initially created. pub fn out_dir(&self, unit: &Unit) -> PathBuf { - if unit.mode.is_doc() { + // Docscrape units need to have doc/ set as the out_dir so sources for reverse-dependencies + // will be put into doc/ and not into deps/ where the *.examples files are stored. + if unit.mode.is_doc() || unit.mode.is_doc_scrape() { self.layout(unit.kind).doc().to_path_buf() } else if unit.mode.is_doc_test() { panic!("doc tests do not have an out dir"); @@ -417,6 +419,17 @@ // but Cargo does not know about that. vec![] } + CompileMode::Docscrape => { + let path = self + .deps_dir(unit) + .join(format!("{}.examples", unit.buildkey())); + vec![OutputFile { + path, + hardlink: None, + export_path: None, + flavor: FileFlavor::Normal, + }] + } CompileMode::Test | CompileMode::Build | CompileMode::Bench diff -Nru cargo-0.58.0/src/cargo/core/compiler/context/mod.rs cargo-0.60.0ubuntu1/src/cargo/core/compiler/context/mod.rs --- cargo-0.58.0/src/cargo/core/compiler/context/mod.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/context/mod.rs 2022-02-10 02:58:21.000000000 +0000 @@ -2,15 +2,14 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; -use anyhow::{bail, Context as _}; -use filetime::FileTime; -use jobserver::Client; - use crate::core::compiler::compilation::{self, UnitOutput}; use crate::core::compiler::{self, Unit}; use crate::core::PackageId; use crate::util::errors::CargoResult; use crate::util::profile; +use anyhow::{bail, Context as _}; +use filetime::FileTime; +use jobserver::Client; use super::build_plan::BuildPlan; use super::custom_build::{self, BuildDeps, BuildScriptOutputs, BuildScripts}; @@ -81,6 +80,10 @@ /// compilation is happening (only object, only bitcode, both, etc), and is /// precalculated early on. pub lto: HashMap, + + /// Map of Doc/Docscrape units to metadata for their -Cmetadata flag. + /// See Context::find_metadata_units for more details. + pub metadata_for_doc_units: HashMap, } impl<'a, 'cfg> Context<'a, 'cfg> { @@ -121,6 +124,7 @@ rustc_clients: HashMap::new(), pipelining, lto: HashMap::new(), + metadata_for_doc_units: HashMap::new(), }) } @@ -135,6 +139,7 @@ self.prepare()?; custom_build::build_map(&mut self)?; self.check_collisions()?; + self.compute_metadata_for_doc_units(); // We need to make sure that if there were any previous docs // already compiled, they were compiled with the same Rustc version that we're currently @@ -241,6 +246,13 @@ args.push("--cfg".into()); args.push(cfg.into()); } + + for (lt, arg) in &output.linker_args { + if lt.applies_to(&unit.target) { + args.push("-C".into()); + args.push(format!("link-arg={}", arg).into()); + } + } } } args.extend(self.bcx.rustdocflags_args(unit).iter().map(Into::into)); @@ -282,19 +294,16 @@ /// Returns the executable for the specified unit (if any). pub fn get_executable(&mut self, unit: &Unit) -> CargoResult> { - for output in self.outputs(unit)?.iter() { - if output.flavor != FileFlavor::Normal { - continue; - } - - let is_binary = unit.target.is_executable(); - let is_test = unit.mode.is_any_test() && !unit.mode.is_check(); - - if is_binary || is_test { - return Ok(Option::Some(output.bin_dst().clone())); - } + let is_binary = unit.target.is_executable(); + let is_test = unit.mode.is_any_test(); + if !unit.mode.generates_executable() || !(is_binary || is_test) { + return Ok(None); } - Ok(None) + Ok(self + .outputs(unit)? + .iter() + .find(|o| o.flavor == FileFlavor::Normal) + .map(|output| output.bin_dst().clone())) } pub fn prepare_units(&mut self) -> CargoResult<()> { @@ -595,7 +604,7 @@ /// Returns whether when `unit` is built whether it should emit metadata as /// well because some compilations rely on that. pub fn rmeta_required(&self, unit: &Unit) -> bool { - self.rmeta_required.contains(unit) || self.bcx.config.cli_unstable().timings.is_some() + self.rmeta_required.contains(unit) } pub fn new_jobserver(&mut self) -> CargoResult { @@ -614,4 +623,40 @@ Ok(client) } + + /// Finds metadata for Doc/Docscrape units. + /// + /// rustdoc needs a -Cmetadata flag in order to recognize StableCrateIds that refer to + /// items in the crate being documented. The -Cmetadata flag used by reverse-dependencies + /// will be the metadata of the Cargo unit that generated the current library's rmeta file, + /// which should be a Check unit. + /// + /// If the current crate has reverse-dependencies, such a Check unit should exist, and so + /// we use that crate's metadata. If not, we use the crate's Doc unit so at least examples + /// scraped from the current crate can be used when documenting the current crate. + pub fn compute_metadata_for_doc_units(&mut self) { + for unit in self.bcx.unit_graph.keys() { + if !unit.mode.is_doc() && !unit.mode.is_doc_scrape() { + continue; + } + + let matching_units = self + .bcx + .unit_graph + .keys() + .filter(|other| { + unit.pkg == other.pkg + && unit.target == other.target + && !other.mode.is_doc_scrape() + }) + .collect::>(); + let metadata_unit = matching_units + .iter() + .find(|other| other.mode.is_check()) + .or_else(|| matching_units.iter().find(|other| other.mode.is_doc())) + .unwrap_or(&unit); + self.metadata_for_doc_units + .insert(unit.clone(), self.files().metadata(metadata_unit)); + } + } } diff -Nru cargo-0.58.0/src/cargo/core/compiler/fingerprint.rs cargo-0.60.0ubuntu1/src/cargo/core/compiler/fingerprint.rs --- cargo-0.58.0/src/cargo/core/compiler/fingerprint.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/fingerprint.rs 2022-02-10 02:58:21.000000000 +0000 @@ -316,6 +316,7 @@ use std::convert::TryInto; use std::env; use std::hash::{self, Hash, Hasher}; +use std::io; use std::path::{Path, PathBuf}; use std::str; use std::sync::{Arc, Mutex}; @@ -1366,11 +1367,19 @@ let local = (gen_local)( deps, Some(&|| { - pkg_fingerprint(cx.bcx, &unit.pkg).with_context(|| { - format!( - "failed to determine package fingerprint for build script for {}", - unit.pkg - ) + const IO_ERR_MESSAGE: &str = "\ +An I/O error happened. Please make sure you can access the file. + +By default, if your project contains a build script, cargo scans all files in +it to determine whether a rebuild is needed. If you don't expect to access the +file, specify `rerun-if-changed` in your build script. +See https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed for more information."; + pkg_fingerprint(cx.bcx, &unit.pkg).map_err(|err| { + let mut message = format!("failed to determine package fingerprint for build script for {}", unit.pkg); + if err.root_cause().is::() { + message = format!("{}\n{}", message, IO_ERR_MESSAGE) + } + err.context(message) }) }), )? diff -Nru cargo-0.58.0/src/cargo/core/compiler/future_incompat.rs cargo-0.60.0ubuntu1/src/cargo/core/compiler/future_incompat.rs --- cargo-0.58.0/src/cargo/core/compiler/future_incompat.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/future_incompat.rs 2022-02-10 02:58:21.000000000 +0000 @@ -1,11 +1,12 @@ //! Support for future-incompatible warning reporting. +use crate::core::compiler::BuildContext; use crate::core::{Dependency, PackageId, Workspace}; use crate::sources::SourceConfigMap; use crate::util::{iter_join, CargoResult, Config}; use anyhow::{bail, format_err, Context}; use serde::{Deserialize, Serialize}; -use std::collections::{BTreeSet, HashMap, HashSet}; +use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::fmt::Write as _; use std::io::{Read, Write}; @@ -77,8 +78,14 @@ struct OnDiskReport { /// Unique reference to the report for the `--id` CLI flag. id: u32, + /// A message describing suggestions for fixing the + /// reported issues + suggestion_message: String, /// Report, suitable for printing to the console. - report: String, + /// Maps package names to the corresponding report + /// We use a `BTreeMap` so that the iteration order + /// is stable across multiple runs of `cargo` + per_package: BTreeMap, } impl Default for OnDiskReports { @@ -94,29 +101,22 @@ impl OnDiskReports { /// Saves a new report. pub fn save_report( + mut self, ws: &Workspace<'_>, + suggestion_message: String, per_package_reports: &[FutureIncompatReportPackage], - ) -> OnDiskReports { - let mut current_reports = match Self::load(ws) { - Ok(r) => r, - Err(e) => { - log::debug!( - "saving future-incompatible reports failed to load current reports: {:?}", - e - ); - OnDiskReports::default() - } - }; + ) { let report = OnDiskReport { - id: current_reports.next_id, - report: render_report(ws, per_package_reports), + id: self.next_id, + suggestion_message, + per_package: render_report(per_package_reports), }; - current_reports.next_id += 1; - current_reports.reports.push(report); - if current_reports.reports.len() > MAX_REPORTS { - current_reports.reports.remove(0); + self.next_id += 1; + self.reports.push(report); + if self.reports.len() > MAX_REPORTS { + self.reports.remove(0); } - let on_disk = serde_json::to_vec(¤t_reports).unwrap(); + let on_disk = serde_json::to_vec(&self).unwrap(); if let Err(e) = ws .target_dir() .open_rw( @@ -137,7 +137,6 @@ &mut ws.config().shell(), ); } - current_reports } /// Loads the on-disk reports. @@ -176,7 +175,12 @@ self.reports.last().map(|r| r.id).unwrap() } - pub fn get_report(&self, id: u32, config: &Config) -> CargoResult { + pub fn get_report( + &self, + id: u32, + config: &Config, + package: Option<&str>, + ) -> CargoResult { let report = self.reports.iter().find(|r| r.id == id).ok_or_else(|| { let available = iter_join(self.reports.iter().map(|r| r.id.to_string()), ", "); format_err!( @@ -186,28 +190,58 @@ available ) })?; - let report = if config.shell().err_supports_color() { - report.report.clone() + + let mut to_display = report.suggestion_message.clone(); + to_display += "\n"; + + let package_report = if let Some(package) = package { + report + .per_package + .get(package) + .ok_or_else(|| { + format_err!( + "could not find package with ID `{}`\n + Available packages are: {}\n + Omit the `--package` flag to display a report for all packages", + package, + iter_join(report.per_package.keys(), ", ") + ) + })? + .to_string() + } else { + report + .per_package + .values() + .cloned() + .collect::>() + .join("\n") + }; + to_display += &package_report; + + let shell = config.shell(); + + let to_display = if shell.err_supports_color() && shell.out_supports_color() { + to_display } else { - strip_ansi_escapes::strip(&report.report) + strip_ansi_escapes::strip(&to_display) .map(|v| String::from_utf8(v).expect("utf8")) .expect("strip should never fail") }; - Ok(report) + Ok(to_display) } } -fn render_report( - ws: &Workspace<'_>, - per_package_reports: &[FutureIncompatReportPackage], -) -> String { - let mut per_package_reports: Vec<_> = per_package_reports.iter().collect(); - per_package_reports.sort_by_key(|r| r.package_id); - let mut rendered = String::new(); - for per_package in &per_package_reports { +fn render_report(per_package_reports: &[FutureIncompatReportPackage]) -> BTreeMap { + let mut report: BTreeMap = BTreeMap::new(); + for per_package in per_package_reports { + let package_spec = format!( + "{}:{}", + per_package.package_id.name(), + per_package.package_id.version() + ); + let rendered = report.entry(package_spec).or_default(); rendered.push_str(&format!( - "The package `{}` currently triggers the following future \ - incompatibility lints:\n", + "The package `{}` currently triggers the following future incompatibility lints:\n", per_package.package_id )); for item in &per_package.items { @@ -218,25 +252,20 @@ .map(|l| format!("> {}\n", l)), ); } - rendered.push('\n'); - } - if let Some(s) = render_suggestions(ws, &per_package_reports) { - rendered.push_str(&s); } - rendered + report } -fn render_suggestions( - ws: &Workspace<'_>, - per_package_reports: &[&FutureIncompatReportPackage], -) -> Option { +/// Returns a user-readable message explaining which of +/// the packages in `package_ids` have updates available. +/// This is best-effort - if an error occurs, `None` will be returned. +fn get_updates(ws: &Workspace<'_>, package_ids: &BTreeSet) -> Option { // This in general ignores all errors since this is opportunistic. let _lock = ws.config().acquire_package_cache_lock().ok()?; // Create a set of updated registry sources. let map = SourceConfigMap::new(ws.config()).ok()?; - let package_ids: BTreeSet<_> = per_package_reports + let package_ids: BTreeSet<_> = package_ids .iter() - .map(|r| r.package_id) .filter(|pkg_id| pkg_id.source_id().is_registry()) .collect(); let source_ids: HashSet<_> = package_ids @@ -251,7 +280,7 @@ }) .collect(); // Query the sources for new versions. - let mut suggestions = String::new(); + let mut updates = String::new(); for pkg_id in package_ids { let source = match sources.get_mut(&pkg_id.source_id()) { Some(s) => s, @@ -259,31 +288,166 @@ }; let dep = Dependency::parse(pkg_id.name(), None, pkg_id.source_id()).ok()?; let summaries = source.query_vec(&dep).ok()?; - let versions = itertools::sorted( - summaries - .iter() - .map(|summary| summary.version()) - .filter(|version| *version > pkg_id.version()), + let mut updated_versions: Vec<_> = summaries + .iter() + .map(|summary| summary.version()) + .filter(|version| *version > pkg_id.version()) + .collect(); + updated_versions.sort(); + + let updated_versions = iter_join( + updated_versions + .into_iter() + .map(|version| version.to_string()), + ", ", ); - let versions = versions.map(|version| version.to_string()); - let versions = iter_join(versions, ", "); - if !versions.is_empty() { + + if !updated_versions.is_empty() { writeln!( - suggestions, + updates, "{} has the following newer versions available: {}", - pkg_id, versions + pkg_id, updated_versions ) .unwrap(); } } - if suggestions.is_empty() { - None + Some(updates) +} + +/// Writes a future-incompat report to disk, using the per-package +/// reports gathered during the build. If requested by the user, +/// a message is also displayed in the build output. +pub fn save_and_display_report( + bcx: &BuildContext<'_, '_>, + per_package_future_incompat_reports: &[FutureIncompatReportPackage], +) { + let should_display_message = match bcx.config.future_incompat_config() { + Ok(config) => config.should_display_message(), + Err(e) => { + crate::display_warning_with_error( + "failed to read future-incompat config from disk", + &e, + &mut bcx.config.shell(), + ); + true + } + }; + + if per_package_future_incompat_reports.is_empty() { + // Explicitly passing a command-line flag overrides + // `should_display_message` from the config file + if bcx.build_config.future_incompat_report { + drop( + bcx.config + .shell() + .note("0 dependencies had future-incompatible warnings"), + ); + } + return; + } + + let current_reports = match OnDiskReports::load(bcx.ws) { + Ok(r) => r, + Err(e) => { + log::debug!( + "saving future-incompatible reports failed to load current reports: {:?}", + e + ); + OnDiskReports::default() + } + }; + let report_id = current_reports.next_id; + + // Get a list of unique and sorted package name/versions. + let package_ids: BTreeSet<_> = per_package_future_incompat_reports + .iter() + .map(|r| r.package_id) + .collect(); + let package_vers: Vec<_> = package_ids.iter().map(|pid| pid.to_string()).collect(); + + if should_display_message || bcx.build_config.future_incompat_report { + drop(bcx.config.shell().warn(&format!( + "the following packages contain code that will be rejected by a future \ + version of Rust: {}", + package_vers.join(", ") + ))); + } + + let updated_versions = get_updates(bcx.ws, &package_ids).unwrap_or(String::new()); + + let update_message = if !updated_versions.is_empty() { + format!( + " +- Some affected dependencies have newer versions available. +You may want to consider updating them to a newer version to see if the issue has been fixed. + +{updated_versions}\n", + updated_versions = updated_versions + ) } else { - Some(format!( - "The following packages appear to have newer versions available.\n\ - You may want to consider updating them to a newer version to see if the \ - issue has been fixed.\n\n{}", - suggestions - )) + String::new() + }; + + let upstream_info = package_ids + .iter() + .map(|package_id| { + let manifest = bcx.packages.get_one(*package_id).unwrap().manifest(); + format!( + " + - {name} + - Repository: {url} + - Detailed warning command: `cargo report future-incompatibilities --id {id} --package {name}`", + name = format!("{}:{}", package_id.name(), package_id.version()), + url = manifest + .metadata() + .repository + .as_deref() + .unwrap_or(""), + id = report_id, + ) + }) + .collect::>() + .join("\n"); + + let suggestion_message = format!( + " +To solve this problem, you can try the following approaches: + +{update_message} +- If the issue is not solved by updating the dependencies, a fix has to be +implemented by those dependencies. You can help with that by notifying the +maintainers of this problem (e.g. by creating a bug report) or by proposing a +fix to the maintainers (e.g. by creating a pull request): +{upstream_info} + +- If waiting for an upstream fix is not an option, you can use the `[patch]` +section in `Cargo.toml` to use your own version of the dependency. For more +information, see: +https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section + ", + upstream_info = upstream_info, + update_message = update_message, + ); + + current_reports.save_report( + bcx.ws, + suggestion_message.clone(), + per_package_future_incompat_reports, + ); + + if bcx.build_config.future_incompat_report { + drop(bcx.config.shell().note(&suggestion_message)); + drop(bcx.config.shell().note(&format!( + "this report can be shown with `cargo report \ + future-incompatibilities --id {}`", + report_id + ))); + } else if should_display_message { + drop(bcx.config.shell().note(&format!( + "to see what the problems were, use the option \ + `--future-incompat-report`, or run `cargo report \ + future-incompatibilities --id {}`", + report_id + ))); } } diff -Nru cargo-0.58.0/src/cargo/core/compiler/job_queue.rs cargo-0.60.0ubuntu1/src/cargo/core/compiler/job_queue.rs --- cargo-0.58.0/src/cargo/core/compiler/job_queue.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/job_queue.rs 2022-02-10 02:58:21.000000000 +0000 @@ -50,7 +50,7 @@ //! improved. use std::cell::{Cell, RefCell}; -use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; +use std::collections::{BTreeMap, HashMap, HashSet}; use std::fmt::Write as _; use std::io; use std::marker; @@ -72,7 +72,7 @@ use super::timings::Timings; use super::{BuildContext, BuildPlan, CompileMode, Context, Unit}; use crate::core::compiler::future_incompat::{ - FutureBreakageItem, FutureIncompatReportPackage, OnDiskReports, + self, FutureBreakageItem, FutureIncompatReportPackage, }; use crate::core::resolver::ResolveBehavior; use crate::core::{PackageId, Shell, TargetKind}; @@ -871,7 +871,10 @@ if !cx.bcx.build_config.build_plan { // It doesn't really matter if this fails. drop(cx.bcx.config.shell().status("Finished", message)); - self.emit_future_incompat(cx.bcx); + future_incompat::save_and_display_report( + cx.bcx, + &self.per_package_future_incompat_reports, + ); } None @@ -881,76 +884,6 @@ } } - fn emit_future_incompat(&mut self, bcx: &BuildContext<'_, '_>) { - if !bcx.config.cli_unstable().future_incompat_report { - return; - } - let should_display_message = match bcx.config.future_incompat_config() { - Ok(config) => config.should_display_message(), - Err(e) => { - crate::display_warning_with_error( - "failed to read future-incompat config from disk", - &e, - &mut bcx.config.shell(), - ); - true - } - }; - - if self.per_package_future_incompat_reports.is_empty() { - // Explicitly passing a command-line flag overrides - // `should_display_message` from the config file - if bcx.build_config.future_incompat_report { - drop( - bcx.config - .shell() - .note("0 dependencies had future-incompatible warnings"), - ); - } - return; - } - - // Get a list of unique and sorted package name/versions. - let package_vers: BTreeSet<_> = self - .per_package_future_incompat_reports - .iter() - .map(|r| r.package_id) - .collect(); - let package_vers: Vec<_> = package_vers - .into_iter() - .map(|pid| pid.to_string()) - .collect(); - - if should_display_message || bcx.build_config.future_incompat_report { - drop(bcx.config.shell().warn(&format!( - "the following packages contain code that will be rejected by a future \ - version of Rust: {}", - package_vers.join(", ") - ))); - } - - let on_disk_reports = - OnDiskReports::save_report(bcx.ws, &self.per_package_future_incompat_reports); - let report_id = on_disk_reports.last_id(); - - if bcx.build_config.future_incompat_report { - let rendered = on_disk_reports.get_report(report_id, bcx.config).unwrap(); - drop(bcx.config.shell().print_ansi_stderr(rendered.as_bytes())); - drop(bcx.config.shell().note(&format!( - "this report can be shown with `cargo report \ - future-incompatibilities -Z future-incompat-report --id {}`", - report_id - ))); - } else if should_display_message { - drop(bcx.config.shell().note(&format!( - "to see what the problems were, use the option \ - `--future-incompat-report`, or run `cargo report \ - future-incompatibilities --id {}`", - report_id - ))); - } - } - fn handle_error( &self, shell: &mut Shell, diff -Nru cargo-0.58.0/src/cargo/core/compiler/mod.rs cargo-0.60.0ubuntu1/src/cargo/core/compiler/mod.rs --- cargo-0.58.0/src/cargo/core/compiler/mod.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/mod.rs 2022-02-10 02:58:21.000000000 +0000 @@ -21,6 +21,7 @@ pub mod unit_dependencies; pub mod unit_graph; +use std::collections::HashSet; use std::env; use std::ffi::{OsStr, OsString}; use std::fs::{self, File}; @@ -165,7 +166,7 @@ let force = exec.force_rebuild(unit) || force_rebuild; let mut job = fingerprint::prepare_target(cx, unit, force)?; job.before(if job.freshness() == Freshness::Dirty { - let work = if unit.mode.is_doc() { + let work = if unit.mode.is_doc() || unit.mode.is_doc_scrape() { rustdoc(cx, unit)? } else { rustc(cx, unit, exec)? @@ -640,13 +641,54 @@ rustdoc.arg("--cfg").arg(&format!("feature=\"{}\"", feat)); } - add_error_format_and_color(cx, &mut rustdoc, false); + add_error_format_and_color(cx, &mut rustdoc, unit, false); add_allow_features(cx, &mut rustdoc); if let Some(args) = cx.bcx.extra_args_for(unit) { rustdoc.args(args); } + let metadata = cx.metadata_for_doc_units[unit]; + rustdoc.arg("-C").arg(format!("metadata={}", metadata)); + + let scrape_output_path = |unit: &Unit| -> CargoResult { + let output_dir = cx.files().deps_dir(unit); + Ok(output_dir.join(format!("{}.examples", unit.buildkey()))) + }; + + if unit.mode.is_doc_scrape() { + debug_assert!(cx.bcx.scrape_units.contains(unit)); + + rustdoc.arg("-Zunstable-options"); + + rustdoc + .arg("--scrape-examples-output-path") + .arg(scrape_output_path(unit)?); + + // Only scrape example for items from crates in the workspace, to reduce generated file size + for pkg in cx.bcx.ws.members() { + let names = pkg + .targets() + .iter() + .map(|target| target.crate_name()) + .collect::>(); + for name in names { + rustdoc.arg("--scrape-examples-target-crate").arg(name); + } + } + } else if cx.bcx.scrape_units.len() > 0 && cx.bcx.ws.is_member(&unit.pkg) { + // We only pass scraped examples to packages in the workspace + // since examples are only coming from reverse-dependencies of workspace packages + + rustdoc.arg("-Zunstable-options"); + + for scrape_unit in &cx.bcx.scrape_units { + rustdoc + .arg("--with-examples") + .arg(scrape_output_path(scrape_unit)?); + } + } + build_deps_args(&mut rustdoc, cx, unit)?; rustdoc::add_root_urls(cx, unit, &mut rustdoc)?; @@ -748,7 +790,12 @@ /// intercepting messages like rmeta artifacts, etc. rustc includes a /// "rendered" field in the JSON message with the message properly formatted, /// which Cargo will extract and display to the user. -fn add_error_format_and_color(cx: &Context<'_, '_>, cmd: &mut ProcessBuilder, pipelined: bool) { +fn add_error_format_and_color( + cx: &Context<'_, '_>, + cmd: &mut ProcessBuilder, + unit: &Unit, + pipelined: bool, +) { cmd.arg("--error-format=json"); let mut json = String::from("--json=diagnostic-rendered-ansi"); if pipelined { @@ -756,6 +803,16 @@ // to emit a message that cargo will intercept. json.push_str(",artifacts"); } + if cx + .bcx + .target_data + .info(unit.kind) + .supports_json_future_incompat + { + // Emit a future-incompat report (when supported by rustc), so we can report + // future-incompat dependencies to the user + json.push_str(",future-incompat"); + } match cx.bcx.build_config.message_format { MessageFormat::Short | MessageFormat::Json { short: true, .. } => { @@ -816,12 +873,23 @@ edition.cmd_edition_arg(cmd); add_path_args(bcx.ws, unit, cmd); - add_error_format_and_color(cx, cmd, cx.rmeta_required(unit)); + add_error_format_and_color(cx, cmd, unit, cx.rmeta_required(unit)); add_allow_features(cx, cmd); + let mut contains_dy_lib = false; if !test { + let mut crate_types = &crate_types + .iter() + .map(|t| t.as_str().to_string()) + .collect::>(); + if let Some(types) = cx.bcx.rustc_crate_types_args_for(unit) { + crate_types = types; + } for crate_type in crate_types.iter() { - cmd.arg("--crate-type").arg(crate_type.as_str()); + cmd.arg("--crate-type").arg(crate_type); + if crate_type == CrateType::Dylib.as_str() { + contains_dy_lib = true; + } } } @@ -837,7 +905,7 @@ } let prefer_dynamic = (unit.target.for_host() && !unit.target.is_custom_build()) - || (crate_types.contains(&CrateType::Dylib) && !cx.is_primary_package(unit)); + || (contains_dy_lib && !cx.is_primary_package(unit)); if prefer_dynamic { cmd.arg("-C").arg("prefer-dynamic"); } @@ -955,7 +1023,7 @@ } if strip != Strip::None { - cmd.arg("-Z").arg(format!("strip={}", strip)); + cmd.arg("-C").arg(format!("strip={}", strip)); } if unit.is_std { @@ -969,10 +1037,6 @@ .env("RUSTC_BOOTSTRAP", "1"); } - if bcx.config.cli_unstable().future_incompat_report { - cmd.arg("-Z").arg("emit-future-incompat-report"); - } - // Add `CARGO_BIN_` environment variables for building tests. if unit.target.is_test() || unit.target.is_bench() { for bin_target in unit diff -Nru cargo-0.58.0/src/cargo/core/compiler/timings.js cargo-0.60.0ubuntu1/src/cargo/core/compiler/timings.js --- cargo-0.58.0/src/cargo/core/compiler/timings.js 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/timings.js 2022-02-10 02:58:21.000000000 +0000 @@ -55,7 +55,7 @@ // Draw Y tick marks. for (let n=1; n target.push_str(" (bench)"), CompileMode::Doc { .. } => target.push_str(" (doc)"), CompileMode::Doctest => target.push_str(" (doc test)"), + CompileMode::Docscrape => target.push_str(" (doc scrape)"), CompileMode::RunCustomBuild => target.push_str(" (run)"), } let unit_time = UnitTime { diff -Nru cargo-0.58.0/src/cargo/core/compiler/unit_dependencies.rs cargo-0.60.0ubuntu1/src/cargo/core/compiler/unit_dependencies.rs --- cargo-0.58.0/src/cargo/core/compiler/unit_dependencies.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/compiler/unit_dependencies.rs 2022-02-10 02:58:21.000000000 +0000 @@ -47,6 +47,7 @@ target_data: &'a RustcTargetData<'cfg>, profiles: &'a Profiles, interner: &'a UnitInterner, + scrape_units: &'a [Unit], /// A set of edges in `unit_dependencies` where (a, b) means that the /// dependency from a to b was added purely because it was a dev-dependency. @@ -61,6 +62,7 @@ features: &'a ResolvedFeatures, std_resolve: Option<&'a (Resolve, ResolvedFeatures)>, roots: &[Unit], + scrape_units: &[Unit], std_roots: &HashMap>, global_mode: CompileMode, target_data: &'a RustcTargetData<'cfg>, @@ -91,6 +93,7 @@ target_data, profiles, interner, + scrape_units, dev_dependency_edges: HashSet::new(), }; @@ -129,7 +132,7 @@ // Compute dependencies for the standard library. state.is_std = true; for roots in std_roots.values() { - deps_of_roots(roots, &mut state)?; + deps_of_roots(roots, state)?; } state.is_std = false; Ok(Some(std::mem::take(&mut state.unit_dependencies))) @@ -169,7 +172,7 @@ /// Compute all the dependencies of the given root units. /// The result is stored in state.unit_dependencies. -fn deps_of_roots(roots: &[Unit], mut state: &mut State<'_, '_>) -> CargoResult<()> { +fn deps_of_roots(roots: &[Unit], state: &mut State<'_, '_>) -> CargoResult<()> { for unit in roots.iter() { // Dependencies of tests/benches should not have `panic` set. // We check the global test mode to see if we are running in `cargo @@ -197,7 +200,7 @@ } else { UnitFor::new_normal() }; - deps_of(unit, &mut state, unit_for)?; + deps_of(unit, state, unit_for)?; } Ok(()) @@ -253,6 +256,7 @@ if !dep.is_transitive() && !unit.target.is_test() && !unit.target.is_example() + && !unit.mode.is_doc_scrape() && !unit.mode.is_any_test() { return false; @@ -445,28 +449,69 @@ mode, )?; ret.push(lib_unit_dep); - if let CompileMode::Doc { deps: true } = unit.mode { - // Document this lib as well. - let doc_unit_dep = new_unit_dep( + if lib.documented() { + if let CompileMode::Doc { deps: true } = unit.mode { + // Document this lib as well. + let doc_unit_dep = new_unit_dep( + state, + unit, + dep, + lib, + dep_unit_for, + unit.kind.for_target(lib), + unit.mode, + )?; + ret.push(doc_unit_dep); + } + } + } + + // Be sure to build/run the build script for documented libraries. + ret.extend(dep_build_script(unit, unit_for, state)?); + + // If we document a binary/example, we need the library available. + if unit.target.is_bin() || unit.target.is_example() { + // build the lib + ret.extend(maybe_lib(unit, state, unit_for)?); + // and also the lib docs for intra-doc links + if let Some(lib) = unit + .pkg + .targets() + .iter() + .find(|t| t.is_linkable() && t.documented()) + { + let dep_unit_for = unit_for.with_dependency(unit, lib); + let lib_doc_unit = new_unit_dep( state, unit, - dep, + &unit.pkg, lib, dep_unit_for, unit.kind.for_target(lib), unit.mode, )?; - ret.push(doc_unit_dep); + ret.push(lib_doc_unit); } } - // Be sure to build/run the build script for documented libraries. - ret.extend(dep_build_script(unit, unit_for, state)?); - - // If we document a binary/example, we need the library available. - if unit.target.is_bin() || unit.target.is_example() { - ret.extend(maybe_lib(unit, state, unit_for)?); + // Add all units being scraped for examples as a dependency of Doc units. + if state.ws.is_member(&unit.pkg) { + for scrape_unit in state.scrape_units.iter() { + // This needs to match the FeaturesFor used in cargo_compile::generate_targets. + let unit_for = UnitFor::new_host(scrape_unit.target.proc_macro()); + deps_of(scrape_unit, state, unit_for)?; + ret.push(new_unit_dep( + state, + scrape_unit, + &scrape_unit.pkg, + &scrape_unit.target, + unit_for, + scrape_unit.kind, + scrape_unit.mode, + )?); + } } + Ok(ret) } @@ -558,7 +603,7 @@ /// Choose the correct mode for dependencies. fn check_or_build_mode(mode: CompileMode, target: &Target) -> CompileMode { match mode { - CompileMode::Check { .. } | CompileMode::Doc { .. } => { + CompileMode::Check { .. } | CompileMode::Doc { .. } | CompileMode::Docscrape => { if target.for_host() { // Plugin and proc macro targets should be compiled like // normal. @@ -695,6 +740,14 @@ && other.unit.target.is_linkable() && other.unit.pkg.manifest().links().is_some() }) + // Avoid cycles when using the doc --scrape-examples feature: + // Say a workspace has crates A and B where A has a build-dependency on B. + // The Doc units for A and B will have a dependency on the Docscrape for both A and B. + // So this would add a dependency from B-build to A-build, causing a cycle: + // B (build) -> A (build) -> B(build) + // See the test scrape_examples_avoid_build_script_cycle for a concrete example. + // To avoid this cycle, we filter out the B -> A (docscrape) dependency. + .filter(|(_parent, other)| !other.unit.mode.is_doc_scrape()) // Skip dependencies induced via dev-dependencies since // connections between `links` and build scripts only happens // via normal dependencies. Otherwise since dev-dependencies can diff -Nru cargo-0.58.0/src/cargo/core/features.rs cargo-0.60.0ubuntu1/src/cargo/core/features.rs --- cargo-0.58.0/src/cargo/core/features.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/features.rs 2022-02-10 02:58:21.000000000 +0000 @@ -393,7 +393,7 @@ (stable, resolver, "1.51", "reference/resolver.html#resolver-versions"), // Allow to specify whether binaries should be stripped. - (unstable, strip, "", "reference/unstable.html#profile-strip-option"), + (stable, strip, "1.58", "reference/profiles.html#strip-option"), // Specifying a minimal 'rust-version' attribute for crates (stable, rust_version, "1.56", "reference/manifest.html#the-rust-version-field"), @@ -637,7 +637,6 @@ doctest_in_workspace: bool = ("Compile doctests with paths relative to the workspace root"), doctest_xcompile: bool = ("Compile and run doctests for non-host target using runner config"), dual_proc_macros: bool = ("Build proc-macros for both the host and the target"), - future_incompat_report: bool = ("Enable creation of a future-incompat report for all dependencies"), features: Option> = (HIDDEN), jobserver_per_rustc: bool = (HIDDEN), minimal_versions: bool = ("Resolve minimal dependency versions instead of maximum"), @@ -654,6 +653,9 @@ timings: Option> = ("Display concurrency information"), unstable_options: bool = ("Allow the usage of unstable options"), weak_dep_features: bool = ("Allow `dep_name?/feature` feature syntax"), + // TODO(wcrichto): move scrape example configuration into Cargo.toml before stabilization + // See: https://github.com/rust-lang/cargo/pull/9525#discussion_r728470927 + rustdoc_scrape_examples: Option = ("Allow rustdoc to scrape examples from reverse-dependencies for documentation"), skip_rustdoc_fingerprint: bool = (HIDDEN), ); @@ -702,6 +704,9 @@ See https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#custom-profiles \ for more information"; +const STABILIZED_FUTURE_INCOMPAT_REPORT: &str = + "The future-incompat-report feature is now always enabled."; + fn deserialize_build_std<'de, D>(deserializer: D) -> Result>, D::Error> where D: serde::Deserializer<'de>, @@ -871,6 +876,15 @@ "namespaced-features" => self.namespaced_features = parse_empty(k, v)?, "weak-dep-features" => self.weak_dep_features = parse_empty(k, v)?, "credential-process" => self.credential_process = parse_empty(k, v)?, + "rustdoc-scrape-examples" => { + if let Some(s) = v { + self.rustdoc_scrape_examples = Some(s.to_string()) + } else { + bail!( + r#"-Z rustdoc-scrape-examples must take "all" or "examples" as an argument"# + ) + } + } "skip-rustdoc-fingerprint" => self.skip_rustdoc_fingerprint = parse_empty(k, v)?, "compile-progress" => stabilized_warn(k, "1.30", STABILIZED_COMPILE_PROGRESS), "offline" => stabilized_err(k, "1.36", STABILIZED_OFFLINE)?, @@ -882,7 +896,9 @@ "extra-link-arg" => stabilized_warn(k, "1.56", STABILIZED_EXTRA_LINK_ARG), "configurable-env" => stabilized_warn(k, "1.56", STABILIZED_CONFIGURABLE_ENV), "patch-in-config" => stabilized_warn(k, "1.56", STABILIZED_PATCH_IN_CONFIG), - "future-incompat-report" => self.future_incompat_report = parse_empty(k, v)?, + "future-incompat-report" => { + stabilized_warn(k, "1.59.0", STABILIZED_FUTURE_INCOMPAT_REPORT) + } _ => bail!("unknown `-Z` flag specified: {}", k), } diff -Nru cargo-0.58.0/src/cargo/core/package.rs cargo-0.60.0ubuntu1/src/cargo/core/package.rs --- cargo-0.58.0/src/cargo/core/package.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/package.rs 2022-02-10 02:58:21.000000000 +0000 @@ -102,6 +102,7 @@ #[serde(skip_serializing_if = "Option::is_none")] metabuild: Option>, default_run: Option, + rust_version: Option, } impl Package { @@ -268,6 +269,7 @@ metabuild: self.manifest().metabuild().cloned(), publish: self.publish().as_ref().cloned(), default_run: self.manifest().default_run().map(|s| s.to_owned()), + rust_version: self.rust_version().map(|s| s.to_owned()), } } } @@ -1004,7 +1006,7 @@ let dl = &self.pending[&token].0; dl.total.set(total); let now = Instant::now(); - if cur != dl.current.get() { + if cur > dl.current.get() { let delta = cur - dl.current.get(); let threshold = self.next_speed_check_bytes_threshold.get(); diff -Nru cargo-0.58.0/src/cargo/core/profiles.rs cargo-0.60.0ubuntu1/src/cargo/core/profiles.rs --- cargo-0.58.0/src/cargo/core/profiles.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/profiles.rs 2022-02-10 02:58:21.000000000 +0000 @@ -323,7 +323,9 @@ (InternedString::new("dev"), None) } } - CompileMode::Doc { .. } => (InternedString::new("doc"), None), + CompileMode::Doc { .. } | CompileMode::Docscrape => { + (InternedString::new("doc"), None) + } } } else { (self.requested_profile, None) @@ -627,7 +629,7 @@ profile.strip = match toml.strip { Some(StringOrBool::Bool(true)) => Strip::Named(InternedString::new("symbols")), None | Some(StringOrBool::Bool(false)) => Strip::None, - Some(StringOrBool::String(ref n)) if is_off(n.as_str()) => Strip::None, + Some(StringOrBool::String(ref n)) if n.as_str() == "none" => Strip::None, Some(StringOrBool::String(ref n)) => Strip::Named(InternedString::new(n)), }; } diff -Nru cargo-0.58.0/src/cargo/core/registry.rs cargo-0.60.0ubuntu1/src/cargo/core/registry.rs --- cargo-0.58.0/src/cargo/core/registry.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/registry.rs 2022-02-10 02:58:21.000000000 +0000 @@ -413,11 +413,12 @@ self.patches_locked = true; } - pub fn patches(&self) -> Vec { - self.patches - .values() - .flat_map(|v| v.iter().cloned()) - .collect() + /// Gets all patches grouped by the source URLS they are going to patch. + /// + /// These patches are mainly collected from [`patch`](Self::patch). + /// They might not be the same as patches actually used during dependency resolving. + pub fn patches(&self) -> &HashMap> { + &self.patches } fn load(&mut self, source_id: SourceId, kind: Kind) -> CargoResult<()> { diff -Nru cargo-0.58.0/src/cargo/core/resolver/dep_cache.rs cargo-0.60.0ubuntu1/src/cargo/core/resolver/dep_cache.rs --- cargo-0.58.0/src/cargo/core/resolver/dep_cache.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/resolver/dep_cache.rs 2022-02-10 02:58:21.000000000 +0000 @@ -280,10 +280,12 @@ // dep_name/feat_name` where `dep_name` does not exist. All other // validation is done either in `build_requirements` or // `build_feature_map`. - for dep_name in reqs.deps.keys() { - if !valid_dep_names.contains(dep_name) { - let e = RequirementError::MissingDependency(*dep_name); - return Err(e.into_activate_error(parent, s)); + if parent.is_none() { + for dep_name in reqs.deps.keys() { + if !valid_dep_names.contains(dep_name) { + let e = RequirementError::MissingDependency(*dep_name); + return Err(e.into_activate_error(parent, s)); + } } } diff -Nru cargo-0.58.0/src/cargo/core/resolver/encode.rs cargo-0.60.0ubuntu1/src/cargo/core/resolver/encode.rs --- cargo-0.58.0/src/cargo/core/resolver/encode.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/resolver/encode.rs 2022-02-10 02:58:21.000000000 +0000 @@ -554,7 +554,7 @@ } } -impl<'a> ser::Serialize for Resolve { +impl ser::Serialize for Resolve { fn serialize(&self, s: S) -> Result where S: ser::Serializer, diff -Nru cargo-0.58.0/src/cargo/core/resolver/resolve.rs cargo-0.60.0ubuntu1/src/cargo/core/resolver/resolve.rs --- cargo-0.58.0/src/cargo/core/resolver/resolve.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/resolver/resolve.rs 2022-02-10 02:58:21.000000000 +0000 @@ -22,10 +22,6 @@ replacements: HashMap, /// Inverted version of `replacements`. reverse_replacements: HashMap, - /// An empty `Vec` to avoid creating a new `Vec` for every package - /// that does not have any features, and to avoid using `Option` to - /// simplify the API. - empty_features: Vec, /// Features enabled for a given package. features: HashMap>, /// Checksum for each package. A SHA256 hash of the `.crate` file used to @@ -107,7 +103,6 @@ checksums, metadata, unused_patches, - empty_features: Vec::new(), reverse_replacements, public_dependencies, version, @@ -264,7 +259,7 @@ } pub fn features(&self, pkg: PackageId) -> &[InternedString] { - self.features.get(&pkg).unwrap_or(&self.empty_features) + self.features.get(&pkg).map(|v| &**v).unwrap_or(&[]) } /// This is only here for legacy support, it will be removed when @@ -377,7 +372,7 @@ } compare! { // fields to compare - graph replacements reverse_replacements empty_features features + graph replacements reverse_replacements features checksums metadata unused_patches public_dependencies summaries | // fields to ignore diff -Nru cargo-0.58.0/src/cargo/core/shell.rs cargo-0.60.0ubuntu1/src/cargo/core/shell.rs --- cargo-0.58.0/src/cargo/core/shell.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/shell.rs 2022-02-10 02:58:21.000000000 +0000 @@ -96,11 +96,15 @@ /// Creates a new shell (color choice and verbosity), defaulting to 'auto' color and verbose /// output. pub fn new() -> Shell { - let auto = ColorChoice::CargoAuto.to_termcolor_color_choice(); + let auto_clr = ColorChoice::CargoAuto; Shell { output: ShellOut::Stream { - stdout: StandardStream::stdout(auto), - stderr: StandardStream::stderr(auto), + stdout: StandardStream::stdout( + auto_clr.to_termcolor_color_choice(atty::Stream::Stdout), + ), + stderr: StandardStream::stderr( + auto_clr.to_termcolor_color_choice(atty::Stream::Stderr), + ), color_choice: ColorChoice::CargoAuto, stderr_tty: atty::is(atty::Stream::Stderr), }, @@ -297,9 +301,8 @@ ), }; *color_choice = cfg; - let choice = cfg.to_termcolor_color_choice(); - *stdout = StandardStream::stdout(choice); - *stderr = StandardStream::stderr(choice); + *stdout = StandardStream::stdout(cfg.to_termcolor_color_choice(atty::Stream::Stdout)); + *stderr = StandardStream::stderr(cfg.to_termcolor_color_choice(atty::Stream::Stderr)); } Ok(()) } @@ -323,6 +326,13 @@ } } + pub fn out_supports_color(&self) -> bool { + match &self.output { + ShellOut::Write(_) => false, + ShellOut::Stream { stdout, .. } => stdout.supports_color(), + } + } + /// Prints a message to stderr and translates ANSI escape code into console colors. pub fn print_ansi_stderr(&mut self, message: &[u8]) -> CargoResult<()> { if self.needs_clear { @@ -432,12 +442,12 @@ impl ColorChoice { /// Converts our color choice to termcolor's version. - fn to_termcolor_color_choice(self) -> termcolor::ColorChoice { + fn to_termcolor_color_choice(self, stream: atty::Stream) -> termcolor::ColorChoice { match self { ColorChoice::Always => termcolor::ColorChoice::Always, ColorChoice::Never => termcolor::ColorChoice::Never, ColorChoice::CargoAuto => { - if atty::is(atty::Stream::Stderr) { + if atty::is(stream) { termcolor::ColorChoice::Auto } else { termcolor::ColorChoice::Never diff -Nru cargo-0.58.0/src/cargo/core/source/source_id.rs cargo-0.60.0ubuntu1/src/cargo/core/source/source_id.rs --- cargo-0.58.0/src/cargo/core/source/source_id.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/source/source_id.rs 2022-02-10 02:58:21.000000000 +0000 @@ -617,7 +617,12 @@ // you're able to restore the hash to its original value, please do so! // Otherwise please just leave a comment in your PR as to why the hash value is // changing and why the old value can't be easily preserved. +// +// The hash value depends on endianness and bit-width, so we only run this test on +// little-endian 64-bit CPUs (such as x86-64 and ARM64) where it matches the +// well-known value. #[test] +#[cfg(all(target_endian = "little", target_pointer_width = "64"))] fn test_cratesio_hash() { let config = Config::default().unwrap(); let crates_io = SourceId::crates_io(&config).unwrap(); diff -Nru cargo-0.58.0/src/cargo/core/workspace.rs cargo-0.60.0ubuntu1/src/cargo/core/workspace.rs --- cargo-0.58.0/src/cargo/core/workspace.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/core/workspace.rs 2022-02-10 02:58:21.000000000 +0000 @@ -431,7 +431,7 @@ // but that's not quite right as it won't deal with overlaps. let mut combined = from_config; for (url, deps_from_manifest) in from_manifest { - if let Some(deps_from_config) = combined.get_mut(&url) { + if let Some(deps_from_config) = combined.get_mut(url) { // We want from_config to take precedence for each patched name. // NOTE: This is inefficient if the number of patches is large! let mut from_manifest_pruned = deps_from_manifest.clone(); diff -Nru cargo-0.58.0/src/cargo/lib.rs cargo-0.60.0ubuntu1/src/cargo/lib.rs --- cargo-0.58.0/src/cargo/lib.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/lib.rs 2022-02-10 02:58:21.000000000 +0000 @@ -12,10 +12,10 @@ use crate::core::Shell; use anyhow::Error; use log::debug; -use std::fmt; pub use crate::util::errors::{InternalError, VerboseError}; pub use crate::util::{indented_lines, CargoResult, CliError, CliResult, Config}; +pub use crate::version::version; pub const CARGO_ENV: &str = "CARGO"; @@ -26,49 +26,7 @@ pub mod ops; pub mod sources; pub mod util; - -pub struct CommitInfo { - pub short_commit_hash: String, - pub commit_hash: String, - pub commit_date: String, -} - -pub struct CfgInfo { - // Information about the Git repository we may have been built from. - pub commit_info: Option, - // The release channel we were built for. - pub release_channel: String, -} - -pub struct VersionInfo { - pub major: u8, - pub minor: u8, - pub patch: u8, - pub pre_release: Option, - // Information that's only available when we were built with - // configure/make, rather than Cargo itself. - pub cfg_info: Option, -} - -impl fmt::Display for VersionInfo { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}.{}.{}", self.major, self.minor, self.patch)?; - if let Some(channel) = self.cfg_info.as_ref().map(|ci| &ci.release_channel) { - if channel != "stable" { - write!(f, "-{}", channel)?; - let empty = String::new(); - write!(f, "{}", self.pre_release.as_ref().unwrap_or(&empty))?; - } - }; - - if let Some(ref cfg) = self.cfg_info { - if let Some(ref ci) = cfg.commit_info { - write!(f, " ({} {})", ci.short_commit_hash, ci.commit_date)?; - } - }; - Ok(()) - } -} +mod version; pub fn exit_with_error(err: CliError, shell: &mut Shell) -> ! { debug!("exit_with_error; err={:?}", err); @@ -143,58 +101,3 @@ } false } - -pub fn version() -> VersionInfo { - macro_rules! option_env_str { - ($name:expr) => { - option_env!($name).map(|s| s.to_string()) - }; - } - - // So this is pretty horrible... - // There are two versions at play here: - // - version of cargo-the-binary, which you see when you type `cargo --version` - // - version of cargo-the-library, which you download from crates.io for use - // in your packages. - // - // We want to make the `binary` version the same as the corresponding Rust/rustc release. - // At the same time, we want to keep the library version at `0.x`, because Cargo as - // a library is (and probably will always be) unstable. - // - // Historically, Cargo used the same version number for both the binary and the library. - // Specifically, rustc 1.x.z was paired with cargo 0.x+1.w. - // We continue to use this scheme for the library, but transform it to 1.x.w for the purposes - // of `cargo --version`. - let major = 1; - let minor = env!("CARGO_PKG_VERSION_MINOR").parse::().unwrap() - 1; - let patch = env!("CARGO_PKG_VERSION_PATCH").parse::().unwrap(); - - match option_env!("CFG_RELEASE_CHANNEL") { - // We have environment variables set up from configure/make. - Some(_) => { - let commit_info = option_env!("CFG_COMMIT_HASH").map(|s| CommitInfo { - commit_hash: s.to_string(), - short_commit_hash: option_env_str!("CFG_SHORT_COMMIT_HASH").unwrap(), - commit_date: option_env_str!("CFG_COMMIT_DATE").unwrap(), - }); - VersionInfo { - major, - minor, - patch, - pre_release: option_env_str!("CARGO_PKG_VERSION_PRE"), - cfg_info: Some(CfgInfo { - release_channel: option_env_str!("CFG_RELEASE_CHANNEL").unwrap(), - commit_info, - }), - } - } - // We are being compiled by Cargo itself. - None => VersionInfo { - major, - minor, - patch, - pre_release: option_env_str!("CARGO_PKG_VERSION_PRE"), - cfg_info: None, - }, - } -} diff -Nru cargo-0.58.0/src/cargo/ops/cargo_clean.rs cargo-0.60.0ubuntu1/src/cargo/ops/cargo_clean.rs --- cargo-0.58.0/src/cargo/ops/cargo_clean.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/ops/cargo_clean.rs 2022-02-10 02:58:21.000000000 +0000 @@ -138,14 +138,16 @@ // Clean fingerprints. for (_, layout) in &layouts_with_host { - rm_rf_glob(&layout.fingerprint().join(&pkg_dir), config)?; + let dir = escape_glob_path(layout.fingerprint())?; + rm_rf_glob(&Path::new(&dir).join(&pkg_dir), config)?; } for target in pkg.targets() { if target.is_custom_build() { // Get both the build_script_build and the output directory. for (_, layout) in &layouts_with_host { - rm_rf_glob(&layout.build().join(&pkg_dir), config)?; + let dir = escape_glob_path(layout.build())?; + rm_rf_glob(&Path::new(&dir).join(&pkg_dir), config)?; } continue; } @@ -173,18 +175,21 @@ // Some files include a hash in the filename, some don't. let hashed_name = file_type.output_filename(target, Some("*")); let unhashed_name = file_type.output_filename(target, None); - rm_rf_glob(&dir.join(&hashed_name), config)?; + let dir_glob = escape_glob_path(dir)?; + let dir_glob = Path::new(&dir_glob); + + rm_rf_glob(&dir_glob.join(&hashed_name), config)?; rm_rf(&dir.join(&unhashed_name), config)?; // Remove dep-info file generated by rustc. It is not tracked in // file_types. It does not have a prefix. - let hashed_dep_info = dir.join(format!("{}-*.d", crate_name)); + let hashed_dep_info = dir_glob.join(format!("{}-*.d", crate_name)); rm_rf_glob(&hashed_dep_info, config)?; let unhashed_dep_info = dir.join(format!("{}.d", crate_name)); rm_rf(&unhashed_dep_info, config)?; // Remove split-debuginfo files generated by rustc. - let split_debuginfo_obj = dir.join(format!("{}.*.o", crate_name)); + let split_debuginfo_obj = dir_glob.join(format!("{}.*.o", crate_name)); rm_rf_glob(&split_debuginfo_obj, config)?; - let split_debuginfo_dwo = dir.join(format!("{}.*.dwo", crate_name)); + let split_debuginfo_dwo = dir_glob.join(format!("{}.*.dwo", crate_name)); rm_rf_glob(&split_debuginfo_dwo, config)?; // Remove the uplifted copy. @@ -197,7 +202,8 @@ } } // TODO: what to do about build_script_build? - let incremental = layout.incremental().join(format!("{}-*", crate_name)); + let dir = escape_glob_path(layout.incremental())?; + let incremental = Path::new(&dir).join(format!("{}-*", crate_name)); rm_rf_glob(&incremental, config)?; } } @@ -207,6 +213,13 @@ Ok(()) } +fn escape_glob_path(pattern: &Path) -> CargoResult { + let pattern = pattern + .to_str() + .ok_or_else(|| anyhow::anyhow!("expected utf-8 path"))?; + Ok(glob::Pattern::escape(pattern)) +} + fn rm_rf_glob(pattern: &Path, config: &Config) -> CargoResult<()> { // TODO: Display utf8 warning to user? Or switch to globset? let pattern = pattern diff -Nru cargo-0.58.0/src/cargo/ops/cargo_compile.rs cargo-0.60.0ubuntu1/src/cargo/ops/cargo_compile.rs --- cargo-0.58.0/src/cargo/ops/cargo_compile.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/ops/cargo_compile.rs 2022-02-10 02:58:21.000000000 +0000 @@ -45,7 +45,7 @@ use crate::util::restricted_names::is_glob_pattern; use crate::util::{closest_msg, profile, CargoResult, StableHasher}; -use anyhow::Context as _; +use anyhow::{bail, Context as _}; /// Contains information about how a package should be compiled. /// @@ -71,6 +71,8 @@ /// The specified target will be compiled with all the available arguments, /// note that this only accounts for the *final* invocation of rustc pub target_rustc_args: Option>, + /// Crate types to be passed to rustc (single target only) + pub target_rustc_crate_types: Option>, /// Extra arguments passed to all selected targets for rustdoc. pub local_rustdoc_args: Option>, /// Whether the `--document-private-items` flags was specified and should @@ -81,7 +83,7 @@ pub honor_rust_version: bool, } -impl<'a> CompileOptions { +impl CompileOptions { pub fn new(config: &Config, mode: CompileMode) -> CargoResult { Ok(CompileOptions { build_config: BuildConfig::new(config, None, &[], mode)?, @@ -92,6 +94,7 @@ }, target_rustdoc_args: None, target_rustc_args: None, + target_rustc_crate_types: None, local_rustdoc_args: None, rustdoc_document_private_items: false, honor_rust_version: true, @@ -99,7 +102,7 @@ } } -#[derive(Clone, PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub enum Packages { Default, All, @@ -332,6 +335,7 @@ ref filter, ref target_rustdoc_args, ref target_rustc_args, + ref target_rustc_crate_types, ref local_rustdoc_args, rustdoc_document_private_items, honor_rust_version, @@ -351,7 +355,7 @@ )?; } } - CompileMode::Doc { .. } | CompileMode::Doctest => { + CompileMode::Doc { .. } | CompileMode::Doctest | CompileMode::Docscrape => { if std::env::var("RUSTDOC_FLAGS").is_ok() { config.shell().warn( "Cargo does not read `RUSTDOC_FLAGS` environment variable. Did you mean `RUSTDOCFLAGS`?" @@ -363,8 +367,17 @@ let target_data = RustcTargetData::new(ws, &build_config.requested_kinds)?; - let specs = spec.to_package_id_specs(ws)?; - let has_dev_units = if filter.need_dev_deps(build_config.mode) { + let all_packages = &Packages::All; + let rustdoc_scrape_examples = &config.cli_unstable().rustdoc_scrape_examples; + let need_reverse_dependencies = rustdoc_scrape_examples.is_some(); + let full_specs = if need_reverse_dependencies { + all_packages + } else { + spec + }; + + let resolve_specs = full_specs.to_package_id_specs(ws)?; + let has_dev_units = if filter.need_dev_deps(build_config.mode) || need_reverse_dependencies { HasDevUnits::Yes } else { HasDevUnits::No @@ -374,7 +387,7 @@ &target_data, &build_config.requested_kinds, cli_features, - &specs, + &resolve_specs, has_dev_units, crate::core::resolver::features::ForceAllTargets::No, )?; @@ -408,6 +421,11 @@ // Find the packages in the resolver that the user wants to build (those // passed in with `-p` or the defaults from the workspace), and convert // Vec to a Vec. + let specs = if need_reverse_dependencies { + spec.to_package_id_specs(ws)? + } else { + resolve_specs.clone() + }; let to_build_ids = resolve.specs_to_ids(&specs)?; // Now get the `Package` for each `PackageId`. This may trigger a download // if the user specified `-p` for a dependency that is not downloaded. @@ -487,6 +505,45 @@ interner, )?; + let mut scrape_units = match rustdoc_scrape_examples { + Some(arg) => { + let filter = match arg.as_str() { + "all" => CompileFilter::new_all_targets(), + "examples" => CompileFilter::new( + LibRule::False, + FilterRule::none(), + FilterRule::none(), + FilterRule::All, + FilterRule::none(), + ), + _ => { + bail!( + r#"-Z rustdoc-scrape-examples must take "all" or "examples" as an argument"# + ) + } + }; + let to_build_ids = resolve.specs_to_ids(&resolve_specs)?; + let to_builds = pkg_set.get_many(to_build_ids)?; + let mode = CompileMode::Docscrape; + + generate_targets( + ws, + &to_builds, + &filter, + &build_config.requested_kinds, + explicit_host_kind, + mode, + &resolve, + &workspace_resolve, + &resolved_features, + &pkg_set, + &profiles, + interner, + )? + } + None => Vec::new(), + }; + let std_roots = if let Some(crates) = &config.cli_unstable().build_std { // Only build libtest if it looks like it is needed. let mut crates = crates.clone(); @@ -521,6 +578,7 @@ &resolved_features, std_resolve_features.as_ref(), &units, + &scrape_units, &std_roots, build_config.mode, &target_data, @@ -542,10 +600,17 @@ // Rebuild the unit graph, replacing the explicit host targets with // CompileKind::Host, merging any dependencies shared with build // dependencies. - let new_graph = rebuild_unit_graph_shared(interner, unit_graph, &units, explicit_host_kind); + let new_graph = rebuild_unit_graph_shared( + interner, + unit_graph, + &units, + &scrape_units, + explicit_host_kind, + ); // This would be nicer with destructuring assignment. units = new_graph.0; - unit_graph = new_graph.1; + scrape_units = new_graph.1; + unit_graph = new_graph.2; } let mut extra_compiler_args = HashMap::new(); @@ -560,6 +625,7 @@ } extra_compiler_args.insert(units[0].clone(), args); } + for unit in &units { if unit.mode.is_doc() || unit.mode.is_doc_test() { let mut extra_args = local_rustdoc_args.clone(); @@ -582,6 +648,28 @@ } } + let mut crate_types = HashMap::new(); + if let Some(args) = target_rustc_crate_types { + if units.len() != 1 { + anyhow::bail!( + "crate types to rustc can only be passed to one \ + target, consider filtering\nthe package by passing, \ + e.g., `--lib` or `--example` to specify a single target" + ); + } + match units[0].target.kind() { + TargetKind::Lib(_) | TargetKind::ExampleLib(_) => { + crate_types.insert(units[0].clone(), args.clone()); + } + _ => { + anyhow::bail!( + "crate types can only be specified for libraries and example libraries.\n\ + Binaries, tests, and benchmarks are always the `bin` crate type" + ); + } + } + } + if honor_rust_version { // Remove any pre-release identifiers for easier comparison let current_version = &target_data.rustc.version; @@ -618,9 +706,11 @@ build_config, profiles, extra_compiler_args, + crate_types, target_data, units, unit_graph, + scrape_units, )?; Ok(bcx) @@ -742,17 +832,18 @@ match mode { CompileMode::Test | CompileMode::Doctest | CompileMode::Bench => true, CompileMode::Check { test: true } => true, - CompileMode::Build | CompileMode::Doc { .. } | CompileMode::Check { test: false } => { - match *self { - CompileFilter::Default { .. } => false, - CompileFilter::Only { - ref examples, - ref tests, - ref benches, - .. - } => examples.is_specific() || tests.is_specific() || benches.is_specific(), - } - } + CompileMode::Build + | CompileMode::Doc { .. } + | CompileMode::Docscrape + | CompileMode::Check { test: false } => match *self { + CompileFilter::Default { .. } => false, + CompileFilter::Only { + ref examples, + ref tests, + ref benches, + .. + } => examples.is_specific() || tests.is_specific() || benches.is_specific(), + }, CompileMode::RunCustomBuild => panic!("Invalid mode"), } } @@ -1342,7 +1433,9 @@ }) .collect() } - CompileMode::Doctest | CompileMode::RunCustomBuild => panic!("Invalid mode {:?}", mode), + CompileMode::Doctest | CompileMode::Docscrape | CompileMode::RunCustomBuild => { + panic!("Invalid mode {:?}", mode) + } } } @@ -1454,8 +1547,9 @@ interner: &UnitInterner, unit_graph: UnitGraph, roots: &[Unit], + scrape_units: &[Unit], to_host: CompileKind, -) -> (Vec, UnitGraph) { +) -> (Vec, Vec, UnitGraph) { let mut result = UnitGraph::new(); // Map of the old unit to the new unit, used to avoid recursing into units // that have already been computed to improve performance. @@ -1466,7 +1560,11 @@ traverse_and_share(interner, &mut memo, &mut result, &unit_graph, root, to_host) }) .collect(); - (new_roots, result) + let new_scrape_units = scrape_units + .iter() + .map(|unit| memo.get(unit).unwrap().clone()) + .collect(); + (new_roots, new_scrape_units, result) } /// Recursive function for rebuilding the graph. diff -Nru cargo-0.58.0/src/cargo/ops/cargo_doc.rs cargo-0.60.0ubuntu1/src/cargo/ops/cargo_doc.rs --- cargo-0.58.0/src/cargo/ops/cargo_doc.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/ops/cargo_doc.rs 2022-02-10 02:58:21.000000000 +0000 @@ -20,7 +20,10 @@ let compilation = ops::compile(ws, &options.compile_opts)?; if options.open_result { - let name = &compilation.root_crate_names[0]; + let name = &compilation + .root_crate_names + .get(0) + .ok_or_else(|| anyhow::anyhow!("no crates with documentation"))?; let kind = options.compile_opts.build_config.single_requested_kind()?; let path = compilation.root_output[&kind] .with_file_name("doc") diff -Nru cargo-0.58.0/src/cargo/ops/cargo_package.rs cargo-0.60.0ubuntu1/src/cargo/ops/cargo_package.rs --- cargo-0.58.0/src/cargo/ops/cargo_package.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/ops/cargo_package.rs 2022-02-10 02:58:21.000000000 +0000 @@ -763,6 +763,7 @@ }, target_rustdoc_args: None, target_rustc_args: rustc_args, + target_rustc_crate_types: None, local_rustdoc_args: None, rustdoc_document_private_items: false, honor_rust_version: true, diff -Nru cargo-0.58.0/src/cargo/ops/cargo_test.rs cargo-0.60.0ubuntu1/src/cargo/ops/cargo_test.rs --- cargo-0.58.0/src/cargo/ops/cargo_test.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/ops/cargo_test.rs 2022-02-10 02:58:21.000000000 +0000 @@ -84,8 +84,6 @@ script_meta, } in compilation.tests.iter() { - let test = unit.target.name().to_string(); - let test_path = unit.target.src_path().path().unwrap(); let exe_display = if let TargetKind::Test = unit.target.kind() { format!( @@ -117,20 +115,17 @@ let result = cmd.exec(); - match result { - Err(e) => { - let e = e.downcast::()?; - errors.push(( - unit.target.kind().clone(), - test.clone(), - unit.pkg.name().to_string(), - e, - )); - if !options.no_fail_fast { - break; - } + if let Err(e) = result { + let e = e.downcast::()?; + errors.push(( + unit.target.kind().clone(), + unit.target.name().to_string(), + unit.pkg.name().to_string(), + e, + )); + if !options.no_fail_fast { + break; } - Ok(()) => {} } } @@ -178,6 +173,16 @@ CompileKind::Target(target) => { if target.short_name() != compilation.host { // Skip doctests, -Zdoctest-xcompile not enabled. + config.shell().verbose(|shell| { + shell.note(format!( + "skipping doctests for {} ({}), \ + cross-compilation doctests are not yet supported\n\ + See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile \ + for more information.", + unit.pkg, + unit.target.description_named() + )) + })?; continue; } } diff -Nru cargo-0.58.0/src/cargo/ops/fix.rs cargo-0.60.0ubuntu1/src/cargo/ops/fix.rs --- cargo-0.58.0/src/cargo/ops/fix.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/ops/fix.rs 2022-02-10 02:58:21.000000000 +0000 @@ -52,7 +52,7 @@ use rustfix::{self, CodeFix}; use semver::Version; -use crate::core::compiler::{CompileKind, RustcTargetData, TargetInfo}; +use crate::core::compiler::RustcTargetData; use crate::core::resolver::features::{DiffMap, FeatureOpts, FeatureResolver}; use crate::core::resolver::{HasDevUnits, Resolve, ResolveBehavior}; use crate::core::{Edition, MaybePackage, PackageId, Workspace}; @@ -68,7 +68,6 @@ const BROKEN_CODE_ENV: &str = "__CARGO_FIX_BROKEN_CODE"; const EDITION_ENV: &str = "__CARGO_FIX_EDITION"; const IDIOMS_ENV: &str = "__CARGO_FIX_IDIOMS"; -const SUPPORTS_FORCE_WARN: &str = "__CARGO_SUPPORTS_FORCE_WARN"; pub struct FixOptions { pub edition: bool, @@ -124,17 +123,6 @@ let rustc = ws.config().load_global_rustc(Some(ws))?; wrapper.arg(&rustc.path); - // Remove this once 1.56 is stabilized. - let target_info = TargetInfo::new( - ws.config(), - &opts.compile_opts.build_config.requested_kinds, - &rustc, - CompileKind::Host, - )?; - if target_info.supports_force_warn { - wrapper.env(SUPPORTS_FORCE_WARN, "1"); - } - // primary crates are compiled using a cargo subprocess to do extra work of applying fixes and // repeating build until there are no more changes to be applied opts.compile_opts.build_config.primary_unit_rustc = Some(wrapper); @@ -849,7 +837,7 @@ fn apply(&self, cmd: &mut Command) { cmd.arg(&self.file); cmd.args(&self.other); - if self.prepare_for_edition.is_some() && env::var_os(SUPPORTS_FORCE_WARN).is_some() { + if self.prepare_for_edition.is_some() { // When migrating an edition, we don't want to fix other lints as // they can sometimes add suggestions that fail to apply, causing // the entire migration to fail. But those lints aren't needed to @@ -868,12 +856,8 @@ if let Some(edition) = self.prepare_for_edition { if edition.supports_compat_lint() { - if env::var_os(SUPPORTS_FORCE_WARN).is_some() { - cmd.arg("--force-warn") - .arg(format!("rust-{}-compatibility", edition)); - } else { - cmd.arg("-W").arg(format!("rust-{}-compatibility", edition)); - } + cmd.arg("--force-warn") + .arg(format!("rust-{}-compatibility", edition)); } } } diff -Nru cargo-0.58.0/src/cargo/ops/mod.rs cargo-0.60.0ubuntu1/src/cargo/ops/mod.rs --- cargo-0.58.0/src/cargo/ops/mod.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/ops/mod.rs 2022-02-10 02:58:21.000000000 +0000 @@ -28,6 +28,7 @@ pub use self::registry::{publish, registry_configuration, RegistryConfig}; pub use self::resolve::{ add_overrides, get_resolved_packages, resolve_with_previous, resolve_ws, resolve_ws_with_opts, + WorkspaceResolve, }; pub use self::vendor::{vendor, VendorOptions}; diff -Nru cargo-0.58.0/src/cargo/ops/resolve.rs cargo-0.60.0ubuntu1/src/cargo/ops/resolve.rs --- cargo-0.58.0/src/cargo/ops/resolve.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/ops/resolve.rs 2022-02-10 02:58:21.000000000 +0000 @@ -29,7 +29,7 @@ use crate::util::{profile, CanonicalUrl}; use anyhow::Context as _; use log::{debug, trace}; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; /// Result for `resolve_ws_with_opts`. pub struct WorkspaceResolve<'cfg> { @@ -467,25 +467,17 @@ .require(Feature::public_dependency()) .is_ok(), )?; - resolved.register_used_patches(®istry.patches()); - if register_patches { - // It would be good if this warning was more targeted and helpful - // (such as showing close candidates that failed to match). However, - // that's not terribly easy to do, so just show a general help - // message. - let warnings: Vec = resolved - .unused_patches() - .iter() - .map(|pkgid| format!("Patch `{}` was not used in the crate graph.", pkgid)) - .collect(); - if !warnings.is_empty() { - ws.config().shell().warn(format!( - "{}\n{}", - warnings.join("\n"), - UNUSED_PATCH_WARNING - ))?; - } + let patches: Vec<_> = registry + .patches() + .values() + .flat_map(|v| v.iter().cloned()) + .collect(); + resolved.register_used_patches(&patches[..]); + + if register_patches && !resolved.unused_patches().is_empty() { + emit_warnings_of_unused_patches(ws, &resolved, registry)?; } + if let Some(previous) = previous { resolved.merge_from(previous)?; } @@ -757,3 +749,79 @@ } None } + +/// Emits warnings of unused patches case by case. +/// +/// This function does its best to provide more targeted and helpful +/// (such as showing close candidates that failed to match). However, that's +/// not terribly easy to do, so just show a general help message if we cannot. +fn emit_warnings_of_unused_patches( + ws: &Workspace<'_>, + resolve: &Resolve, + registry: &PackageRegistry<'_>, +) -> CargoResult<()> { + const MESSAGE: &str = "was not used in the crate graph."; + + // Patch package with the source URLs being patch + let mut patch_pkgid_to_urls = HashMap::new(); + for (url, summaries) in registry.patches().iter() { + for summary in summaries.iter() { + patch_pkgid_to_urls + .entry(summary.package_id()) + .or_insert_with(HashSet::new) + .insert(url); + } + } + + // pkg name -> all source IDs of under the same pkg name + let mut source_ids_grouped_by_pkg_name = HashMap::new(); + for pkgid in resolve.iter() { + source_ids_grouped_by_pkg_name + .entry(pkgid.name()) + .or_insert_with(HashSet::new) + .insert(pkgid.source_id()); + } + + let mut unemitted_unused_patches = Vec::new(); + for unused in resolve.unused_patches().iter() { + // Show alternative source URLs if the source URLs being patch + // cannot not be found in the crate graph. + match ( + source_ids_grouped_by_pkg_name.get(&unused.name()), + patch_pkgid_to_urls.get(unused), + ) { + (Some(ids), Some(patched_urls)) + if ids + .iter() + .all(|id| !patched_urls.contains(id.canonical_url())) => + { + use std::fmt::Write; + let mut msg = String::new(); + writeln!(&mut msg, "Patch `{}` {}", unused, MESSAGE)?; + write!( + &mut msg, + "Perhaps you misspell the source URL being patched.\n\ + Possible URLs for `[patch.]`:", + )?; + for id in ids.iter() { + write!(&mut msg, "\n {}", id.display_registry_name())?; + } + ws.config().shell().warn(msg)?; + } + _ => unemitted_unused_patches.push(unused), + } + } + + // Show general help message. + if !unemitted_unused_patches.is_empty() { + let warnings: Vec<_> = unemitted_unused_patches + .iter() + .map(|pkgid| format!("Patch `{}` {}", pkgid, MESSAGE)) + .collect(); + ws.config() + .shell() + .warn(format!("{}\n{}", warnings.join("\n"), UNUSED_PATCH_WARNING))?; + } + + return Ok(()); +} diff -Nru cargo-0.58.0/src/cargo/ops/tree/graph.rs cargo-0.60.0ubuntu1/src/cargo/ops/tree/graph.rs --- cargo-0.58.0/src/cargo/ops/tree/graph.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/ops/tree/graph.rs 2022-02-10 02:58:21.000000000 +0000 @@ -427,28 +427,32 @@ /// ```text /// from -Edge-> featname -Edge::Feature-> to /// ``` +/// +/// Returns a tuple `(missing, index)`. +/// `missing` is true if this feature edge was already added. +/// `index` is the index of the index in the graph of the `Feature` node. fn add_feature( graph: &mut Graph<'_>, name: InternedString, from: Option, to: usize, kind: EdgeKind, -) -> usize { +) -> (bool, usize) { // `to` *must* point to a package node. assert!(matches! {graph.nodes[to], Node::Package{..}}); let node = Node::Feature { node_index: to, name, }; - let node_index = match graph.index.get(&node) { - Some(idx) => *idx, - None => graph.add_node(node), + let (missing, node_index) = match graph.index.get(&node) { + Some(idx) => (false, *idx), + None => (true, graph.add_node(node)), }; if let Some(from) = from { graph.edges[from].add_edge(kind, node_index); } graph.edges[node_index].add_edge(EdgeKind::Feature, to); - node_index + (missing, node_index) } /// Adds nodes for features requested on the command-line for the given member. @@ -480,7 +484,7 @@ for fv in to_add { match fv { FeatureValue::Feature(feature) => { - let index = add_feature(graph, feature, None, package_index, EdgeKind::Feature); + let index = add_feature(graph, feature, None, package_index, EdgeKind::Feature).1; graph.cli_features.insert(index); } // This is enforced by CliFeatures. @@ -511,10 +515,11 @@ if is_optional { // Activate the optional dep on self. let index = - add_feature(graph, dep_name, None, package_index, EdgeKind::Feature); + add_feature(graph, dep_name, None, package_index, EdgeKind::Feature).1; graph.cli_features.insert(index); } - let index = add_feature(graph, dep_feature, None, dep_index, EdgeKind::Feature); + let index = + add_feature(graph, dep_feature, None, dep_index, EdgeKind::Feature).1; graph.cli_features.insert(index); } } @@ -571,21 +576,24 @@ for fv in fvs { match fv { FeatureValue::Feature(dep_name) => { - let feat_index = add_feature( + let (missing, feat_index) = add_feature( graph, *dep_name, Some(from), package_index, EdgeKind::Feature, ); - add_feature_rec( - graph, - resolve, - *dep_name, - package_id, - feat_index, - package_index, - ); + // Don't recursive if the edge already exists to deal with cycles. + if missing { + add_feature_rec( + graph, + resolve, + *dep_name, + package_id, + feat_index, + package_index, + ); + } } // Dependencies are already shown in the graph as dep edges. I'm // uncertain whether or not this might be confusing in some cases @@ -628,21 +636,23 @@ EdgeKind::Feature, ); } - let feat_index = add_feature( + let (missing, feat_index) = add_feature( graph, *dep_feature, Some(from), dep_index, EdgeKind::Feature, ); - add_feature_rec( - graph, - resolve, - *dep_feature, - dep_pkg_id, - feat_index, - dep_index, - ); + if missing { + add_feature_rec( + graph, + resolve, + *dep_feature, + dep_pkg_id, + feat_index, + dep_index, + ); + } } } } diff -Nru cargo-0.58.0/src/cargo/ops/vendor.rs cargo-0.60.0ubuntu1/src/cargo/ops/vendor.rs --- cargo-0.58.0/src/cargo/ops/vendor.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/ops/vendor.rs 2022-02-10 02:58:21.000000000 +0000 @@ -32,11 +32,15 @@ let vendor_config = sync(config, &workspaces, opts).with_context(|| "failed to sync")?; if config.shell().verbosity() != Verbosity::Quiet { - crate::drop_eprint!( - config, - "To use vendored sources, add this to your .cargo/config.toml for this project:\n\n" - ); - crate::drop_print!(config, "{}", &toml::to_string(&vendor_config).unwrap()); + if vendor_config.source.is_empty() { + crate::drop_eprintln!(config, "There is no dependency to vendor in this project."); + } else { + crate::drop_eprint!( + config, + "To use vendored sources, add this to your .cargo/config.toml for this project:\n\n" + ); + crate::drop_print!(config, "{}", &toml::to_string(&vendor_config).unwrap()); + } } Ok(()) @@ -75,6 +79,7 @@ ) -> CargoResult { let canonical_destination = opts.destination.canonicalize(); let canonical_destination = canonical_destination.as_deref().unwrap_or(opts.destination); + let dest_dir_already_exists = canonical_destination.exists(); paths::create_dir_all(&canonical_destination)?; let mut to_remove = HashSet::new(); @@ -239,12 +244,6 @@ let mut config = BTreeMap::new(); let merged_source_name = "vendored-sources"; - config.insert( - merged_source_name.to_string(), - VendorSource::Directory { - directory: opts.destination.to_path_buf(), - }, - ); // replace original sources with vendor for source_id in sources { @@ -290,6 +289,18 @@ config.insert(name, source); } + if !config.is_empty() { + config.insert( + merged_source_name.to_string(), + VendorSource::Directory { + directory: opts.destination.to_path_buf(), + }, + ); + } else if !dest_dir_already_exists { + // Nothing to vendor. Remove the destination dir we've just created. + paths::remove_dir(canonical_destination)?; + } + Ok(VendorConfig { source: config }) } diff -Nru cargo-0.58.0/src/cargo/sources/path.rs cargo-0.60.0ubuntu1/src/cargo/sources/path.rs --- cargo-0.58.0/src/cargo/sources/path.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/sources/path.rs 2022-02-10 02:58:21.000000000 +0000 @@ -1,6 +1,5 @@ use std::collections::HashSet; use std::fmt::{self, Debug, Formatter}; -use std::fs; use std::path::{Path, PathBuf}; use crate::core::source::MaybePackage; @@ -11,8 +10,8 @@ use cargo_util::paths; use filetime::FileTime; use ignore::gitignore::GitignoreBuilder; -use ignore::Match; use log::{trace, warn}; +use walkdir::WalkDir; pub struct PathSource<'cfg> { source_id: SourceId, @@ -131,39 +130,36 @@ } let ignore_include = include_builder.build()?; - let ignore_should_package = |relative_path: &Path, is_dir: bool| -> CargoResult { + let ignore_should_package = |relative_path: &Path, is_dir: bool| { // "Include" and "exclude" options are mutually exclusive. if no_include_option { - match ignore_exclude.matched_path_or_any_parents(relative_path, is_dir) { - Match::None => Ok(true), - Match::Ignore(_) => Ok(false), - Match::Whitelist(_) => Ok(true), - } + !ignore_exclude + .matched_path_or_any_parents(relative_path, is_dir) + .is_ignore() } else { if is_dir { // Generally, include directives don't list every // directory (nor should they!). Just skip all directory // checks, and only check files. - return Ok(true); + return true; } - match ignore_include + ignore_include .matched_path_or_any_parents(relative_path, /* is_dir */ false) - { - Match::None => Ok(false), - Match::Ignore(_) => Ok(true), - Match::Whitelist(_) => Ok(false), - } + .is_ignore() } }; - let mut filter = |path: &Path, is_dir: bool| -> CargoResult { - let relative_path = path.strip_prefix(root)?; + let mut filter = |path: &Path, is_dir: bool| { + let relative_path = match path.strip_prefix(root) { + Ok(p) => p, + Err(_) => return false, + }; let rel = relative_path.as_os_str(); if rel == "Cargo.lock" { - return Ok(pkg.include_lockfile()); + return pkg.include_lockfile(); } else if rel == "Cargo.toml" { - return Ok(true); + return true; } ignore_should_package(relative_path, is_dir) @@ -225,7 +221,7 @@ &self, pkg: &Package, repo: &git2::Repository, - filter: &mut dyn FnMut(&Path, bool) -> CargoResult, + filter: &mut dyn FnMut(&Path, bool) -> bool, ) -> CargoResult> { warn!("list_files_git {}", pkg.package_id()); let index = repo.index()?; @@ -344,10 +340,10 @@ ret.extend(files.into_iter()); } Err(..) => { - PathSource::walk(&file_path, &mut ret, false, filter)?; + self.walk(&file_path, &mut ret, false, filter)?; } } - } else if (*filter)(&file_path, is_dir)? { + } else if filter(&file_path, is_dir) { assert!(!is_dir); // We found a file! warn!(" found {}", file_path.display()); @@ -379,50 +375,71 @@ fn list_files_walk( &self, pkg: &Package, - filter: &mut dyn FnMut(&Path, bool) -> CargoResult, + filter: &mut dyn FnMut(&Path, bool) -> bool, ) -> CargoResult> { let mut ret = Vec::new(); - PathSource::walk(pkg.root(), &mut ret, true, filter)?; + self.walk(pkg.root(), &mut ret, true, filter)?; Ok(ret) } fn walk( + &self, path: &Path, ret: &mut Vec, is_root: bool, - filter: &mut dyn FnMut(&Path, bool) -> CargoResult, + filter: &mut dyn FnMut(&Path, bool) -> bool, ) -> CargoResult<()> { - let is_dir = path.is_dir(); - if !is_root && !(*filter)(path, is_dir)? { - return Ok(()); - } - if !is_dir { - ret.push(path.to_path_buf()); - return Ok(()); - } - // Don't recurse into any sub-packages that we have. - if !is_root && path.join("Cargo.toml").exists() { - return Ok(()); - } + let walkdir = WalkDir::new(path) + .follow_links(true) + .into_iter() + .filter_entry(|entry| { + let path = entry.path(); + let at_root = is_root && entry.depth() == 0; + let is_dir = entry.file_type().is_dir(); - // For package integration tests, we need to sort the paths in a deterministic order to - // be able to match stdout warnings in the same order. - // - // TODO: drop `collect` and sort after transition period and dropping warning tests. - // See rust-lang/cargo#4268 and rust-lang/cargo#4270. - let mut entries: Vec = fs::read_dir(path) - .with_context(|| format!("cannot read {:?}", path))? - .map(|e| e.unwrap().path()) - .collect(); - entries.sort_unstable_by(|a, b| a.as_os_str().cmp(b.as_os_str())); - for path in entries { - let name = path.file_name().and_then(|s| s.to_str()); - if is_root && name == Some("target") { - // Skip Cargo artifacts. - continue; + if !at_root && !filter(path, is_dir) { + return false; + } + + if !is_dir { + return true; + } + + // Don't recurse into any sub-packages that we have. + if !at_root && path.join("Cargo.toml").exists() { + return false; + } + + // Skip root Cargo artifacts. + if is_root + && entry.depth() == 1 + && path.file_name().and_then(|s| s.to_str()) == Some("target") + { + return false; + } + + true + }); + for entry in walkdir { + match entry { + Ok(entry) => { + if !entry.file_type().is_dir() { + ret.push(entry.into_path()); + } + } + Err(err) if err.loop_ancestor().is_some() => { + self.config.shell().warn(err)?; + } + Err(err) => match err.path() { + // If the error occurs with a path, simply recover from it. + // Don't worry about error skipping here, the callers would + // still hit the IO error if they do access it thereafter. + Some(path) => ret.push(path.to_path_buf()), + None => return Err(err.into()), + }, } - PathSource::walk(&path, ret, false, filter)?; } + Ok(()) } diff -Nru cargo-0.58.0/src/cargo/util/command_prelude.rs cargo-0.60.0ubuntu1/src/cargo/util/command_prelude.rs --- cargo-0.58.0/src/cargo/util/command_prelude.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/util/command_prelude.rs 2022-02-10 02:58:21.000000000 +0000 @@ -142,7 +142,7 @@ } fn arg_release(self, release: &'static str) -> Self { - self._arg(opt("release", release)) + self._arg(opt("release", release).short("r")) } fn arg_profile(self, profile: &'static str) -> Self { @@ -212,11 +212,6 @@ fn arg_index(self) -> Self { self._arg(opt("index", "Registry index URL to upload the package to").value_name("INDEX")) - ._arg( - opt("host", "DEPRECATED, renamed to '--index'") - .value_name("HOST") - .hidden(true), - ) } fn arg_dry_run(self, dry_run: &'static str) -> Self { @@ -233,9 +228,13 @@ fn arg_future_incompat_report(self) -> Self { self._arg(opt( "future-incompat-report", - "Outputs a future incompatibility report at the end of the build (unstable)", + "Outputs a future incompatibility report at the end of the build", )) } + + fn arg_quiet(self) -> Self { + self._arg(opt("quiet", "Do not print cargo log messages").short("q")) + } } impl AppExt for App { @@ -287,15 +286,15 @@ ]) } -// Determines whether or not to gate `--profile` as unstable when resolving it. +/// Determines whether or not to gate `--profile` as unstable when resolving it. pub enum ProfileChecking { - // `cargo rustc` historically has allowed "test", "bench", and "check". This - // variant explicitly allows those. + /// `cargo rustc` historically has allowed "test", "bench", and "check". This + /// variant explicitly allows those. LegacyRustc, - // `cargo check` and `cargo fix` historically has allowed "test". This variant - // explicitly allows that on stable. + /// `cargo check` and `cargo fix` historically has allowed "test". This variant + /// explicitly allows that on stable. LegacyTestOnly, - // All other commands, which allow any valid custom named profile. + /// All other commands, which allow any valid custom named profile. Custom, } @@ -512,17 +511,6 @@ .cli_unstable() .fail_if_stable_opt("--unit-graph", 8002)?; } - if build_config.future_incompat_report { - config - .cli_unstable() - .fail_if_stable_opt("--future-incompat-report", 9241)?; - - if !config.cli_unstable().future_incompat_report { - anyhow::bail!( - "Usage of `--future-incompat-report` requires `-Z future-incompat-report`" - ) - } - } let opts = CompileOptions { build_config, @@ -542,6 +530,7 @@ ), target_rustdoc_args: None, target_rustc_args: None, + target_rustc_crate_types: None, local_rustdoc_args: None, rustdoc_document_private_items: false, honor_rust_version: !self._is_present("ignore-rust-version"), @@ -626,27 +615,8 @@ } } - fn index(&self, config: &Config) -> CargoResult> { - // TODO: deprecated. Remove once it has been decided `--host` can be removed - // We may instead want to repurpose the host flag, as mentioned in issue - // rust-lang/cargo#4208. - let msg = "The flag '--host' is no longer valid. - -Previous versions of Cargo accepted this flag, but it is being -deprecated. The flag is being renamed to 'index', as the flag -wants the location of the index. Please use '--index' instead. - -This will soon become a hard error, so it's either recommended -to update to a fixed version or contact the upstream maintainer -about this warning."; - - let index = match self._value_of("host") { - Some(host) => { - config.shell().warn(&msg)?; - Some(host.to_string()) - } - None => self._value_of("index").map(|s| s.to_string()), - }; + fn index(&self) -> CargoResult> { + let index = self._value_of("index").map(|s| s.to_string()); Ok(index) } diff -Nru cargo-0.58.0/src/cargo/util/config/mod.rs cargo-0.60.0ubuntu1/src/cargo/util/config/mod.rs --- cargo-0.58.0/src/cargo/util/config/mod.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/util/config/mod.rs 2022-02-10 02:58:21.000000000 +0000 @@ -909,20 +909,19 @@ let color = color.or_else(|| term.color.as_deref()); - let verbosity = match (verbose, term.verbose, quiet) { - (true, _, false) | (_, Some(true), false) => Verbosity::Verbose, - - // Command line takes precedence over configuration, so ignore the - // configuration.. - (false, _, true) => Verbosity::Quiet, - - // Can't pass both at the same time on the command line regardless - // of configuration. - (true, _, true) => { - bail!("cannot set both --verbose and --quiet"); - } - - (false, _, false) => Verbosity::Normal, + // The command line takes precedence over configuration. + let verbosity = match (verbose, quiet) { + (true, true) => bail!("cannot set both --verbose and --quiet"), + (true, false) => Verbosity::Verbose, + (false, true) => Verbosity::Quiet, + (false, false) => match (term.verbose, term.quiet) { + (Some(true), Some(true)) => { + bail!("cannot set both `term.verbose` and `term.quiet`") + } + (Some(true), Some(false)) => Verbosity::Verbose, + (Some(false), Some(true)) => Verbosity::Quiet, + _ => Verbosity::Normal, + }, }; let cli_target_dir = target_dir.as_ref().map(|dir| Filesystem::new(dir.clone())); @@ -2127,6 +2126,7 @@ #[derive(Deserialize, Default)] struct TermConfig { verbose: Option, + quiet: Option, color: Option, #[serde(default)] #[serde(deserialize_with = "progress_or_string")] diff -Nru cargo-0.58.0/src/cargo/util/flock.rs cargo-0.60.0ubuntu1/src/cargo/util/flock.rs --- cargo-0.58.0/src/cargo/util/flock.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/util/flock.rs 2022-02-10 02:58:21.000000000 +0000 @@ -374,7 +374,10 @@ pub(super) fn error_unsupported(err: &Error) -> bool { match err.raw_os_error() { - Some(libc::ENOTSUP) => true, + // Unfortunately, depending on the target, these may or may not be the same. + // For targets in which they are the same, the duplicate pattern causes a warning. + #[allow(unreachable_patterns)] + Some(libc::ENOTSUP | libc::EOPNOTSUPP) => true, #[cfg(target_os = "linux")] Some(libc::ENOSYS) => true, _ => false, diff -Nru cargo-0.58.0/src/cargo/util/lev_distance.rs cargo-0.60.0ubuntu1/src/cargo/util/lev_distance.rs --- cargo-0.58.0/src/cargo/util/lev_distance.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/util/lev_distance.rs 2022-02-10 02:58:21.000000000 +0000 @@ -1,6 +1,14 @@ use std::cmp; pub fn lev_distance(me: &str, t: &str) -> usize { + // Comparing the strings lowercased will result in a difference in capitalization being less distance away + // than being a completely different letter. Otherwise `CHECK` is as far away from `check` as it + // is from `build` (both with a distance of 5). For a single letter shortcut (e.g. `b` or `c`), they will + // all be as far away from any capital single letter entry (all with a distance of 1). + // By first lowercasing the strings, `C` and `c` are closer than `C` and `b`, for example. + let me = me.to_lowercase(); + let t = t.to_lowercase(); + let t_len = t.chars().count(); if me.is_empty() { return t_len; diff -Nru cargo-0.58.0/src/cargo/util/toml/mod.rs cargo-0.60.0ubuntu1/src/cargo/util/toml/mod.rs --- cargo-0.58.0/src/cargo/util/toml/mod.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/util/toml/mod.rs 2022-02-10 02:58:21.000000000 +0000 @@ -52,12 +52,20 @@ ); let contents = paths::read(path).map_err(|err| ManifestError::new(err, path.into()))?; - do_read_manifest(&contents, path, source_id, config) + read_manifest_from_str(&contents, path, source_id, config) .with_context(|| format!("failed to parse manifest at `{}`", path.display())) .map_err(|err| ManifestError::new(err, path.into())) } -fn do_read_manifest( +/// Parse an already-loaded `Cargo.toml` as a Cargo manifest. +/// +/// This could result in a real or virtual manifest being returned. +/// +/// A list of nested paths is also returned, one for each path dependency +/// within the manifest. For virtual manifests, these paths can only +/// come from patched or replaced dependencies. These paths are not +/// canonicalized. +pub fn read_manifest_from_str( contents: &str, manifest_file: &Path, source_id: SourceId, @@ -522,10 +530,6 @@ } } - if self.strip.is_some() { - features.require(Feature::strip())?; - } - if let Some(codegen_backend) = &self.codegen_backend { features.require(Feature::codegen_backend())?; if codegen_backend.contains(|c: char| !c.is_ascii_alphanumeric() && c != '_') { @@ -1248,7 +1252,7 @@ for (name, platform) in me.target.iter().flatten() { cx.platform = { let platform: Platform = name.parse()?; - platform.check_cfg_attributes(&mut cx.warnings); + platform.check_cfg_attributes(cx.warnings); Some(platform) }; process_dependencies(&mut cx, platform.dependencies.as_ref(), None)?; diff -Nru cargo-0.58.0/src/cargo/util/toml/targets.rs cargo-0.60.0ubuntu1/src/cargo/util/toml/targets.rs --- cargo-0.58.0/src/cargo/util/toml/targets.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/util/toml/targets.rs 2022-02-10 02:58:21.000000000 +0000 @@ -25,6 +25,11 @@ use anyhow::Context as _; +const DEFAULT_TEST_DIR_NAME: &'static str = "tests"; +const DEFAULT_BENCH_DIR_NAME: &'static str = "benches"; +const DEFAULT_EXAMPLE_DIR_NAME: &'static str = "examples"; +const DEFAULT_BIN_DIR_NAME: &'static str = "bin"; + pub fn targets( features: &Features, manifest: &TomlManifest, @@ -353,7 +358,10 @@ return Some(path); } - let path = package_root.join("src").join("bin").join("main.rs"); + let path = package_root + .join("src") + .join(DEFAULT_BIN_DIR_NAME) + .join("main.rs"); if path.exists() { return Some(path); } @@ -370,7 +378,7 @@ warnings: &mut Vec, errors: &mut Vec, ) -> CargoResult> { - let inferred = infer_from_directory(&package_root.join("examples")); + let inferred = infer_from_directory(&package_root.join(DEFAULT_EXAMPLE_DIR_NAME)); let targets = clean_targets( "example", @@ -415,7 +423,7 @@ warnings: &mut Vec, errors: &mut Vec, ) -> CargoResult> { - let inferred = infer_from_directory(&package_root.join("tests")); + let inferred = infer_from_directory(&package_root.join(DEFAULT_TEST_DIR_NAME)); let targets = clean_targets( "test", @@ -590,7 +598,9 @@ if main.exists() { result.push((package_name.to_string(), main)); } - result.extend(infer_from_directory(&package_root.join("src").join("bin"))); + result.extend(infer_from_directory( + &package_root.join("src").join(DEFAULT_BIN_DIR_NAME), + )); result } @@ -812,6 +822,90 @@ Ok(()) } +/// Build an error message for a target path that cannot be determined either +/// by auto-discovery or specifiying. +/// +/// This function tries to detect commonly wrong paths for targets: +/// +/// test -> tests/*.rs, tests/*/main.rs +/// bench -> benches/*.rs, benches/*/main.rs +/// example -> examples/*.rs, examples/*/main.rs +/// bin -> src/bin/*.rs, src/bin/*/main.rs +/// +/// Note that the logic need to sync with [`infer_from_directory`] if changes. +fn target_path_not_found_error_message( + package_root: &Path, + target: &TomlTarget, + target_kind: &str, +) -> String { + fn possible_target_paths(name: &str, kind: &str, commonly_wrong: bool) -> [PathBuf; 2] { + let mut target_path = PathBuf::new(); + match (kind, commonly_wrong) { + // commonly wrong paths + ("test" | "bench" | "example", true) => target_path.push(kind), + ("bin", true) => { + target_path.push("src"); + target_path.push("bins"); + } + // default inferred paths + ("test", false) => target_path.push(DEFAULT_TEST_DIR_NAME), + ("bench", false) => target_path.push(DEFAULT_BENCH_DIR_NAME), + ("example", false) => target_path.push(DEFAULT_EXAMPLE_DIR_NAME), + ("bin", false) => { + target_path.push("src"); + target_path.push(DEFAULT_BIN_DIR_NAME); + } + _ => unreachable!("invalid target kind: {}", kind), + } + target_path.push(name); + + let target_path_file = { + let mut path = target_path.clone(); + path.set_extension("rs"); + path + }; + let target_path_subdir = { + target_path.push("main.rs"); + target_path + }; + return [target_path_file, target_path_subdir]; + } + + let target_name = target.name(); + let commonly_wrong_paths = possible_target_paths(&target_name, target_kind, true); + let possible_paths = possible_target_paths(&target_name, target_kind, false); + let existing_wrong_path_index = match ( + package_root.join(&commonly_wrong_paths[0]).exists(), + package_root.join(&commonly_wrong_paths[1]).exists(), + ) { + (true, _) => Some(0), + (_, true) => Some(1), + _ => None, + }; + + if let Some(i) = existing_wrong_path_index { + return format!( + "\ +can't find `{name}` {kind} at default paths, but found a file at `{wrong_path}`. +Perhaps rename the file to `{possible_path}` for target auto-discovery, \ +or specify {kind}.path if you want to use a non-default path.", + name = target_name, + kind = target_kind, + wrong_path = commonly_wrong_paths[i].display(), + possible_path = possible_paths[i].display(), + ); + } + + format!( + "can't find `{name}` {kind} at `{path_file}` or `{path_dir}`. \ + Please specify {kind}.path if you want to use a non-default path.", + name = target_name, + kind = target_kind, + path_file = possible_paths[0].display(), + path_dir = possible_paths[1].display(), + ) +} + fn target_path( target: &TomlTarget, inferred: &[(String, PathBuf)], @@ -835,16 +929,32 @@ let second = matching.next(); match (first, second) { (Some(path), None) => Ok(path), - (None, None) | (Some(_), Some(_)) => { + (None, None) => { + if edition == Edition::Edition2015 { + if let Some(path) = legacy_path(target) { + return Ok(path); + } + } + Err(target_path_not_found_error_message( + package_root, + target, + target_kind, + )) + } + (Some(p0), Some(p1)) => { if edition == Edition::Edition2015 { if let Some(path) = legacy_path(target) { return Ok(path); } } Err(format!( - "can't find `{name}` {target_kind}, specify {target_kind}.path", - name = name, - target_kind = target_kind + "\ +cannot infer path for `{}` {} +Cargo doesn't know which to use because multiple target files found at `{}` and `{}`.", + target.name(), + target_kind, + p0.strip_prefix(package_root).unwrap_or(&p0).display(), + p1.strip_prefix(package_root).unwrap_or(&p1).display(), )) } (None, Some(_)) => unreachable!(), diff -Nru cargo-0.58.0/src/cargo/version.rs cargo-0.60.0ubuntu1/src/cargo/version.rs --- cargo-0.58.0/src/cargo/version.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/cargo/version.rs 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,95 @@ +//! Code for representing cargo's release version number. + +use std::fmt; + +/// Information about the git repository where cargo was built from. +pub struct CommitInfo { + pub short_commit_hash: String, + pub commit_hash: String, + pub commit_date: String, +} + +/// Information provided by the outer build system (rustbuild aka bootstrap). +pub struct CfgInfo { + /// Information about the Git repository we may have been built from. + pub commit_info: Option, + /// The release channel we were built for (stable/beta/nightly/dev). + pub release_channel: String, +} + +/// Cargo's version. +pub struct VersionInfo { + /// Cargo's version, such as "1.57.0", "1.58.0-beta.1", "1.59.0-nightly", etc. + pub version: String, + /// Information that's only available when we were built with + /// rustbuild, rather than Cargo itself. + pub cfg_info: Option, +} + +impl fmt::Display for VersionInfo { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.version)?; + + if let Some(ref cfg) = self.cfg_info { + if let Some(ref ci) = cfg.commit_info { + write!(f, " ({} {})", ci.short_commit_hash, ci.commit_date)?; + } + }; + Ok(()) + } +} + +/// Returns information about cargo's version. +pub fn version() -> VersionInfo { + macro_rules! option_env_str { + ($name:expr) => { + option_env!($name).map(|s| s.to_string()) + }; + } + + // This is the version set in rustbuild, which we use to match rustc. + let version = option_env_str!("CFG_RELEASE").unwrap_or_else(|| { + // If cargo is not being built by rustbuild, then we just use the + // version from cargo's own `Cargo.toml`. + // + // There are two versions at play here: + // - version of cargo-the-binary, which you see when you type `cargo --version` + // - version of cargo-the-library, which you download from crates.io for use + // in your packages. + // + // The library is permanently unstable, so it always has a 0 major + // version. However, the CLI now reports a stable 1.x version + // (starting in 1.26) which stays in sync with rustc's version. + // + // Coincidentally, the minor version for cargo-the-library is always + // +1 of rustc's minor version (that is, `rustc 1.11.0` corresponds to + // `cargo `0.12.0`). The versions always get bumped in lockstep, so + // this should continue to hold. + let minor = env!("CARGO_PKG_VERSION_MINOR").parse::().unwrap() - 1; + let patch = env!("CARGO_PKG_VERSION_PATCH").parse::().unwrap(); + format!("1.{}.{}", minor, patch) + }); + + match option_env!("CFG_RELEASE_CHANNEL") { + // We have environment variables set up from configure/make. + Some(_) => { + let commit_info = option_env!("CFG_COMMIT_HASH").map(|s| CommitInfo { + commit_hash: s.to_string(), + short_commit_hash: option_env_str!("CFG_SHORT_COMMIT_HASH").unwrap(), + commit_date: option_env_str!("CFG_COMMIT_DATE").unwrap(), + }); + VersionInfo { + version, + cfg_info: Some(CfgInfo { + release_channel: option_env_str!("CFG_RELEASE_CHANNEL").unwrap(), + commit_info, + }), + } + } + // We are being compiled by Cargo itself. + None => VersionInfo { + version, + cfg_info: None, + }, + } +} diff -Nru cargo-0.58.0/src/doc/book.toml cargo-0.60.0ubuntu1/src/doc/book.toml --- cargo-0.58.0/src/doc/book.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/book.toml 2022-02-10 02:58:21.000000000 +0000 @@ -4,3 +4,4 @@ [output.html] git-repository-url = "https://github.com/rust-lang/cargo/tree/master/src/doc/src" +edit-url-template = "https://github.com/rust-lang/cargo/edit/master/src/doc/{path}" diff -Nru cargo-0.58.0/src/doc/contrib/src/SUMMARY.md cargo-0.60.0ubuntu1/src/doc/contrib/src/SUMMARY.md --- cargo-0.58.0/src/doc/contrib/src/SUMMARY.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/contrib/src/SUMMARY.md 2022-02-10 02:58:21.000000000 +0000 @@ -16,5 +16,5 @@ - [Tests](./tests/index.md) - [Running Tests](./tests/running.md) - [Writing Tests](./tests/writing.md) - - [Profiling](./tests/profiling.md) + - [Benchmarking and Profiling](./tests/profiling.md) - [Design Principles](./design.md) diff -Nru cargo-0.58.0/src/doc/contrib/src/tests/profiling.md cargo-0.60.0ubuntu1/src/doc/contrib/src/tests/profiling.md --- cargo-0.58.0/src/doc/contrib/src/tests/profiling.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/contrib/src/tests/profiling.md 2022-02-10 02:58:21.000000000 +0000 @@ -1,4 +1,4 @@ -# Profiling +# Benchmarking and Profiling ## Internal profiler @@ -11,7 +11,15 @@ CARGO_PROFILE=3 cargo generate-lockfile ``` -## Informal profiling +## Benchmarking + +### Benchsuite + +Head over to the [`benches` +directory](https://github.com/rust-lang/cargo/tree/master/benches) for more +information about the benchmarking suite. + +### Informal benchmarking The overhead for starting a build should be kept as low as possible (preferably, well under 0.5 seconds on most projects and systems). Currently, @@ -23,12 +31,10 @@ * Scanning the local project. * Building the unit dependency graph. -We currently don't have any automated systems or tools for measuring or -tracking the startup time. We informally measure these on changes that are -likely to affect the performance. Usually this is done by measuring the time -for `cargo build` to finish in a large project where the build is fresh (no -actual compilation is performed). [Hyperfine] is a command-line tool that can -be used to roughly measure the difference between different commands and -settings. +One way to test this is to use [hyperfine]. This is a tool that can be used to +measure the difference between different commands and settings. Usually this +is done by measuring the time it takes for `cargo build` to finish in a large +project where the build is fresh (no actual compilation is performed). Just +run `cargo build` once before using hyperfine. -[Hyperfine]: https://github.com/sharkdp/hyperfine +[hyperfine]: https://github.com/sharkdp/hyperfine diff -Nru cargo-0.58.0/src/doc/man/cargo-build.md cargo-0.60.0ubuntu1/src/doc/man/cargo-build.md --- cargo-0.58.0/src/doc/man/cargo-build.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/cargo-build.md 2022-02-10 02:58:21.000000000 +0000 @@ -89,6 +89,7 @@ {{#options}} {{> options-jobs }} +{{> options-future-incompat }} {{/options}} {{> section-environment }} diff -Nru cargo-0.58.0/src/doc/man/cargo-check.md cargo-0.60.0ubuntu1/src/doc/man/cargo-check.md --- cargo-0.58.0/src/doc/man/cargo-check.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/cargo-check.md 2022-02-10 02:58:21.000000000 +0000 @@ -74,6 +74,7 @@ {{#options}} {{> options-jobs }} +{{> options-future-incompat }} {{/options}} {{> section-environment }} diff -Nru cargo-0.58.0/src/doc/man/cargo-install.md cargo-0.60.0ubuntu1/src/doc/man/cargo-install.md --- cargo-0.58.0/src/doc/man/cargo-install.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/cargo-install.md 2022-02-10 02:58:21.000000000 +0000 @@ -185,6 +185,9 @@ {{#options}} {{> options-display }} + +{{> options-message-format }} + {{/options}} {{> section-options-common }} diff -Nru cargo-0.58.0/src/doc/man/cargo-metadata.md cargo-0.60.0ubuntu1/src/doc/man/cargo-metadata.md --- cargo-0.58.0/src/doc/man/cargo-metadata.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/cargo-metadata.md 2022-02-10 02:58:21.000000000 +0000 @@ -182,6 +182,8 @@ ], /* Optional string that is the default binary picked by cargo run. */ "default_run": null, + /* Optional string that is the minimum supported rust version */ + "rust_version": "1.56", /* Array of keywords from the manifest. */ "keywords": [ "cli" diff -Nru cargo-0.58.0/src/doc/man/cargo-report.md cargo-0.60.0ubuntu1/src/doc/man/cargo-report.md --- cargo-0.58.0/src/doc/man/cargo-report.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/cargo-report.md 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,42 @@ +# cargo-report(1) + +## NAME + +cargo-report - Generate and display various kinds of reports + +## SYNOPSIS + +`cargo report` _type_ [_options_] + +### DESCRIPTION + +Displays a report of the given _type_ - currently, only `future-incompat` is supported + +## OPTIONS + +{{#options}} + +{{#option "`--id` _id_" }} +Show the report with the specified Cargo-generated id +{{/option}} + +{{#option "`-p` _spec_..." "`--package` _spec_..." }} +Only display a report for the specified package +{{/option}} + +{{/options}} + +## EXAMPLES + +1. Display the latest future-incompat report: + + cargo report future-incompat + +2. Display the latest future-incompat report for a specific package: + + cargo report future-incompat --package my-dep:0.0.1 + +## SEE ALSO +[Future incompat report](../reference/future-incompat-report.html) + +{{man "cargo" 1}} diff -Nru cargo-0.58.0/src/doc/man/cargo-rustc.md cargo-0.60.0ubuntu1/src/doc/man/cargo-rustc.md --- cargo-0.58.0/src/doc/man/cargo-rustc.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/cargo-rustc.md 2022-02-10 02:58:21.000000000 +0000 @@ -100,6 +100,7 @@ {{#options}} {{> options-jobs }} +{{> options-future-incompat }} {{/options}} {{> section-environment }} diff -Nru cargo-0.58.0/src/doc/man/cargo-test.md cargo-0.60.0ubuntu1/src/doc/man/cargo-test.md --- cargo-0.58.0/src/doc/man/cargo-test.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/cargo-test.md 2022-02-10 02:58:21.000000000 +0000 @@ -153,6 +153,7 @@ {{#options}} {{> options-jobs }} +{{> options-future-incompat }} {{/options}} diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-bench.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-bench.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-bench.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-bench.txt 2022-02-10 02:58:21.000000000 +0000 @@ -241,7 +241,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-build.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-build.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-build.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-build.txt 2022-02-10 02:58:21.000000000 +0000 @@ -142,7 +142,7 @@ documentation for more details. - --release + -r, --release Build optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name. @@ -181,7 +181,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: @@ -287,6 +289,12 @@ . Defaults to the number of CPUs. + --future-incompat-report + Displays a future-incompat report for any future-incompatible + warnings produced during execution of this command + + See cargo-report(1) + ENVIRONMENT See the reference diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-check.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-check.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-check.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-check.txt 2022-02-10 02:58:21.000000000 +0000 @@ -148,7 +148,7 @@ documentation for more details. - --release + -r, --release Check optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name. @@ -185,7 +185,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: @@ -281,6 +283,12 @@ . Defaults to the number of CPUs. + --future-incompat-report + Displays a future-incompat report for any future-incompatible + warnings produced during execution of this command + + See cargo-report(1) + ENVIRONMENT See the reference diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-clean.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-clean.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-clean.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-clean.txt 2022-02-10 02:58:21.000000000 +0000 @@ -62,7 +62,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-doc.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-doc.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-doc.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-doc.txt 2022-02-10 02:58:21.000000000 +0000 @@ -126,7 +126,7 @@ documentation for more details. - --release + -r, --release Document optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name. @@ -156,7 +156,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-fetch.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-fetch.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-fetch.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-fetch.txt 2022-02-10 02:58:21.000000000 +0000 @@ -47,7 +47,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-fix.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-fix.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-fix.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-fix.txt 2022-02-10 02:58:21.000000000 +0000 @@ -221,7 +221,7 @@ documentation for more details. - --release + -r, --release Fix optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name. @@ -258,7 +258,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-generate-lockfile.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-generate-lockfile.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-generate-lockfile.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-generate-lockfile.txt 2022-02-10 02:58:21.000000000 +0000 @@ -23,7 +23,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-init.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-init.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-init.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-init.txt 2022-02-10 02:58:21.000000000 +0000 @@ -62,7 +62,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-install.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-install.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-install.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-install.txt 2022-02-10 02:58:21.000000000 +0000 @@ -247,7 +247,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: @@ -262,6 +264,34 @@ May also be specified with the term.color config value . + --message-format fmt + The output format for diagnostic messages. Can be specified multiple + times and consists of comma-separated values. Valid values: + + o human (default): Display in a human-readable text format. + Conflicts with short and json. + + o short: Emit shorter, human-readable text messages. Conflicts with + human and json. + + o json: Emit JSON messages to stdout. See the reference + + for more details. Conflicts with human and short. + + o json-diagnostic-short: Ensure the rendered field of JSON messages + contains the "short" rendering from rustc. Cannot be used with + human or short. + + o json-diagnostic-rendered-ansi: Ensure the rendered field of JSON + messages contains embedded ANSI color codes for respecting + rustc's default color scheme. Cannot be used with human or short. + + o json-render-diagnostics: Instruct Cargo to not include rustc + diagnostics in in JSON messages printed, but instead Cargo itself + should render the JSON diagnostics coming from rustc. Cargo's own + JSON diagnostics and others coming from rustc are still emitted. + Cannot be used with human or short. + Common Options +toolchain If Cargo has been installed with rustup, and the first argument to diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-locate-project.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-locate-project.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-locate-project.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-locate-project.txt 2022-02-10 02:58:21.000000000 +0000 @@ -32,7 +32,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-login.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-login.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-login.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-login.txt 2022-02-10 02:58:21.000000000 +0000 @@ -37,7 +37,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-metadata.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-metadata.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-metadata.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-metadata.txt 2022-02-10 02:58:21.000000000 +0000 @@ -177,6 +177,8 @@ ], /* Optional string that is the default binary picked by cargo run. */ "default_run": null, + /* Optional string that is the minimum supported rust version */ + "rust_version": "1.56", /* Array of keywords from the manifest. */ "keywords": [ "cli" @@ -333,7 +335,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-new.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-new.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-new.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-new.txt 2022-02-10 02:58:21.000000000 +0000 @@ -57,7 +57,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-owner.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-owner.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-owner.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-owner.txt 2022-02-10 02:58:21.000000000 +0000 @@ -64,7 +64,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-package.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-package.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-package.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-package.txt 2022-02-10 02:58:21.000000000 +0000 @@ -197,7 +197,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-pkgid.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-pkgid.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-pkgid.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-pkgid.txt 2022-02-10 02:58:21.000000000 +0000 @@ -53,7 +53,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-publish.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-publish.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-publish.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-publish.txt 2022-02-10 02:58:21.000000000 +0000 @@ -164,7 +164,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-report.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-report.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-report.txt 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-report.txt 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,34 @@ +CARGO-REPORT(1) + +NAME + cargo-report - Generate and display various kinds of reports + +SYNOPSIS + cargo report type [options] + + DESCRIPTION + Displays a report of the given type - currently, only future-incompat is + supported + +OPTIONS + --id id + Show the report with the specified Cargo-generated id + + -p spec..., --package spec... + Only display a report for the specified package + +EXAMPLES + 1. Display the latest future-incompat report: + + cargo report future-incompat + + 2. Display the latest future-incompat report for a specific package: + + cargo report future-incompat --package my-dep:0.0.1 + +SEE ALSO + Future incompat report + + + cargo(1) + diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-run.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-run.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-run.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-run.txt 2022-02-10 02:58:21.000000000 +0000 @@ -71,7 +71,7 @@ documentation for more details. - --release + -r, --release Run optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name. @@ -101,7 +101,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-rustc.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-rustc.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-rustc.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-rustc.txt 2022-02-10 02:58:21.000000000 +0000 @@ -133,7 +133,7 @@ documentation for more details. - --release + -r, --release Build optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name. @@ -180,7 +180,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: @@ -276,6 +278,12 @@ . Defaults to the number of CPUs. + --future-incompat-report + Displays a future-incompat report for any future-incompatible + warnings produced during execution of this command + + See cargo-report(1) + ENVIRONMENT See the reference diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-rustdoc.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-rustdoc.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-rustdoc.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-rustdoc.txt 2022-02-10 02:58:21.000000000 +0000 @@ -142,7 +142,7 @@ documentation for more details. - --release + -r, --release Document optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name. @@ -172,7 +172,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-search.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-search.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-search.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-search.txt 2022-02-10 02:58:21.000000000 +0000 @@ -34,7 +34,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-test.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-test.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-test.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-test.txt 2022-02-10 02:58:21.000000000 +0000 @@ -219,7 +219,7 @@ documentation for more details. - --release + -r, --release Test optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name. @@ -255,7 +255,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: @@ -357,6 +359,12 @@ . Defaults to the number of CPUs. + --future-incompat-report + Displays a future-incompat report for any future-incompatible + warnings produced during execution of this command + + See cargo-report(1) + ENVIRONMENT See the reference diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-tree.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-tree.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-tree.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-tree.txt 2022-02-10 02:58:21.000000000 +0000 @@ -244,7 +244,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo.txt 2022-02-10 02:58:21.000000000 +0000 @@ -136,7 +136,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-uninstall.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-uninstall.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-uninstall.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-uninstall.txt 2022-02-10 02:58:21.000000000 +0000 @@ -46,7 +46,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-update.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-update.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-update.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-update.txt 2022-02-10 02:58:21.000000000 +0000 @@ -53,7 +53,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-vendor.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-vendor.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-vendor.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-vendor.txt 2022-02-10 02:58:21.000000000 +0000 @@ -79,7 +79,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-verify-project.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-verify-project.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-verify-project.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-verify-project.txt 2022-02-10 02:58:21.000000000 +0000 @@ -26,7 +26,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/generated_txt/cargo-yank.txt cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-yank.txt --- cargo-0.58.0/src/doc/man/generated_txt/cargo-yank.txt 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/generated_txt/cargo-yank.txt 2022-02-10 02:58:21.000000000 +0000 @@ -59,7 +59,9 @@ value . -q, --quiet - No output printed to stdout. + Do not print cargo log messages. May also be specified with the + term.quiet config value + . --color when Control when colored output is used. Valid values: diff -Nru cargo-0.58.0/src/doc/man/includes/options-display.md cargo-0.60.0ubuntu1/src/doc/man/includes/options-display.md --- cargo-0.58.0/src/doc/man/includes/options-display.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/includes/options-display.md 2022-02-10 02:58:21.000000000 +0000 @@ -6,7 +6,9 @@ {{/option}} {{#option "`-q`" "`--quiet`"}} -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the `term.quiet` +[config value](../reference/config.html). {{/option}} {{#option "`--color` _when_"}} diff -Nru cargo-0.58.0/src/doc/man/includes/options-future-incompat.md cargo-0.60.0ubuntu1/src/doc/man/includes/options-future-incompat.md --- cargo-0.58.0/src/doc/man/includes/options-future-incompat.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/includes/options-future-incompat.md 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,6 @@ +{{#option "`--future-incompat-report`"}} +Displays a future-incompat report for any future-incompatible warnings +produced during execution of this command + +See {{man "cargo-report" 1}} +{{/option}} diff -Nru cargo-0.58.0/src/doc/man/includes/options-release.md cargo-0.60.0ubuntu1/src/doc/man/includes/options-release.md --- cargo-0.58.0/src/doc/man/includes/options-release.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/man/includes/options-release.md 2022-02-10 02:58:21.000000000 +0000 @@ -1,4 +1,4 @@ -{{#option "`--release`"}} +{{#option "`-r`" "`--release`"}} {{actionverb}} optimized artifacts with the `release` profile. See also the `--profile` option for choosing a specific profile by name. {{/option}} diff -Nru cargo-0.58.0/src/doc/semver-check/Cargo.toml cargo-0.60.0ubuntu1/src/doc/semver-check/Cargo.toml --- cargo-0.58.0/src/doc/semver-check/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/semver-check/Cargo.toml 2022-02-10 02:58:21.000000000 +0000 @@ -2,7 +2,7 @@ name = "semver-check" version = "0.1.0" authors = ["Eric Huss"] -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff -Nru cargo-0.58.0/src/doc/src/appendix/git-authentication.md cargo-0.60.0ubuntu1/src/doc/src/appendix/git-authentication.md --- cargo-0.58.0/src/doc/src/appendix/git-authentication.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/appendix/git-authentication.md 2022-02-10 02:58:21.000000000 +0000 @@ -41,7 +41,14 @@ SSH authentication requires `ssh-agent` to be running to acquire the SSH key. Make sure the appropriate environment variables are set up (`SSH_AUTH_SOCK` on most Unix-like systems), and that the correct keys are added (with `ssh-add`). -Windows uses Pageant for SSH authentication. + +Windows can use Pageant (part of [PuTTY]) or `ssh-agent`. +To use `ssh-agent`, Cargo needs to use the OpenSSH that is distributed as part +of Windows, as Cargo does not support the simulated Unix-domain sockets used +by MinGW or Cygwin. +More information about installing with Windows can be found at the [Microsoft +installation documentation] and the page on [key management] has instructions +on how to start `ssh-agent` and to add keys. > **Note:** Cargo does not support git's shorthand SSH URLs like > `git@example.com:user/repo.git`. Use a full SSH URL like @@ -54,3 +61,6 @@ [`credential.helper`]: https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage [`net.git-fetch-with-cli`]: ../reference/config.md#netgit-fetch-with-cli [GCM]: https://github.com/microsoft/Git-Credential-Manager-Core/ +[PuTTY]: https://www.chiark.greenend.org.uk/~sgtatham/putty/ +[Microsoft installation documentation]: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse +[key management]: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement diff -Nru cargo-0.58.0/src/doc/src/commands/build-commands.md cargo-0.60.0ubuntu1/src/doc/src/commands/build-commands.md --- cargo-0.58.0/src/doc/src/commands/build-commands.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/build-commands.md 2022-02-10 02:58:21.000000000 +0000 @@ -10,3 +10,4 @@ * [cargo rustc](cargo-rustc.md) * [cargo rustdoc](cargo-rustdoc.md) * [cargo test](cargo-test.md) +* [cargo report](cargo-report.md) diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-bench.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-bench.md --- cargo-0.58.0/src/doc/src/commands/cargo-bench.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-bench.md 2022-02-10 02:58:21.000000000 +0000 @@ -299,7 +299,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-build.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-build.md --- cargo-0.58.0/src/doc/src/commands/cargo-build.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-build.md 2022-02-10 02:58:21.000000000 +0000 @@ -181,6 +181,7 @@ +
-r
--release
Build optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name.
@@ -235,7 +236,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
@@ -354,6 +357,12 @@ the number of CPUs. +
--future-incompat-report
+
Displays a future-incompat report for any future-incompatible warnings +produced during execution of this command

+

See cargo-report(1)

+ + ## ENVIRONMENT diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-check.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-check.md --- cargo-0.58.0/src/doc/src/commands/cargo-check.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-check.md 2022-02-10 02:58:21.000000000 +0000 @@ -186,6 +186,7 @@ +
-r
--release
Check optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name.
@@ -235,7 +236,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
@@ -345,6 +348,12 @@ the number of CPUs. +
--future-incompat-report
+
Displays a future-incompat report for any future-incompatible warnings +produced during execution of this command

+

See cargo-report(1)

+ + ## ENVIRONMENT diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-clean.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-clean.md --- cargo-0.58.0/src/doc/src/commands/cargo-clean.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-clean.md 2022-02-10 02:58:21.000000000 +0000 @@ -84,7 +84,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-doc.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-doc.md --- cargo-0.58.0/src/doc/src/commands/cargo-doc.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-doc.md 2022-02-10 02:58:21.000000000 +0000 @@ -164,6 +164,7 @@ +
-r
--release
Document optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name.
@@ -209,7 +210,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-fetch.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-fetch.md --- cargo-0.58.0/src/doc/src/commands/cargo-fetch.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-fetch.md 2022-02-10 02:58:21.000000000 +0000 @@ -57,7 +57,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-fix.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-fix.md --- cargo-0.58.0/src/doc/src/commands/cargo-fix.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-fix.md 2022-02-10 02:58:21.000000000 +0000 @@ -266,6 +266,7 @@ +
-r
--release
Fix optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name.
@@ -315,7 +316,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-generate-lockfile.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-generate-lockfile.md --- cargo-0.58.0/src/doc/src/commands/cargo-generate-lockfile.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-generate-lockfile.md 2022-02-10 02:58:21.000000000 +0000 @@ -32,7 +32,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-init.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-init.md --- cargo-0.58.0/src/doc/src/commands/cargo-init.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-init.md 2022-02-10 02:58:21.000000000 +0000 @@ -80,7 +80,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-install.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-install.md --- cargo-0.58.0/src/doc/src/commands/cargo-install.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-install.md 2022-02-10 02:58:21.000000000 +0000 @@ -292,7 +292,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
@@ -307,6 +309,31 @@ config value. + +
--message-format fmt
+
The output format for diagnostic messages. Can be specified multiple times +and consists of comma-separated values. Valid values:

+
    +
  • human (default): Display in a human-readable text format. Conflicts with +short and json.
  • +
  • short: Emit shorter, human-readable text messages. Conflicts with human +and json.
  • +
  • json: Emit JSON messages to stdout. See +the reference +for more details. Conflicts with human and short.
  • +
  • json-diagnostic-short: Ensure the rendered field of JSON messages contains +the "short" rendering from rustc. Cannot be used with human or short.
  • +
  • json-diagnostic-rendered-ansi: Ensure the rendered field of JSON messages +contains embedded ANSI color codes for respecting rustc's default color +scheme. Cannot be used with human or short.
  • +
  • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics in +in JSON messages printed, but instead Cargo itself should render the +JSON diagnostics coming from rustc. Cargo's own JSON diagnostics and others +coming from rustc are still emitted. Cannot be used with human or short.
  • +
+ + + ### Common Options diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-locate-project.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-locate-project.md --- cargo-0.58.0/src/doc/src/commands/cargo-locate-project.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-locate-project.md 2022-02-10 02:58:21.000000000 +0000 @@ -46,7 +46,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-login.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-login.md --- cargo-0.58.0/src/doc/src/commands/cargo-login.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-login.md 2022-02-10 02:58:21.000000000 +0000 @@ -48,7 +48,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo.md --- cargo-0.58.0/src/doc/src/commands/cargo.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo.md 2022-02-10 02:58:21.000000000 +0000 @@ -160,7 +160,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-metadata.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-metadata.md --- cargo-0.58.0/src/doc/src/commands/cargo-metadata.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-metadata.md 2022-02-10 02:58:21.000000000 +0000 @@ -182,6 +182,8 @@ ], /* Optional string that is the default binary picked by cargo run. */ "default_run": null, + /* Optional string that is the minimum supported rust version */ + "rust_version": "1.56", /* Array of keywords from the manifest. */ "keywords": [ "cli" @@ -358,7 +360,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-new.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-new.md --- cargo-0.58.0/src/doc/src/commands/cargo-new.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-new.md 2022-02-10 02:58:21.000000000 +0000 @@ -75,7 +75,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-owner.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-owner.md --- cargo-0.58.0/src/doc/src/commands/cargo-owner.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-owner.md 2022-02-10 02:58:21.000000000 +0000 @@ -86,7 +86,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-package.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-package.md --- cargo-0.58.0/src/doc/src/commands/cargo-package.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-package.md 2022-02-10 02:58:21.000000000 +0000 @@ -243,7 +243,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-pkgid.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-pkgid.md --- cargo-0.58.0/src/doc/src/commands/cargo-pkgid.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-pkgid.md 2022-02-10 02:58:21.000000000 +0000 @@ -59,7 +59,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-publish.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-publish.md --- cargo-0.58.0/src/doc/src/commands/cargo-publish.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-publish.md 2022-02-10 02:58:21.000000000 +0000 @@ -209,7 +209,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-report.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-report.md --- cargo-0.58.0/src/doc/src/commands/cargo-report.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-report.md 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,43 @@ +# cargo-report(1) + +## NAME + +cargo-report - Generate and display various kinds of reports + +## SYNOPSIS + +`cargo report` _type_ [_options_] + +### DESCRIPTION + +Displays a report of the given _type_ - currently, only `future-incompat` is supported + +## OPTIONS + +
+ +
--id id
+
Show the report with the specified Cargo-generated id
+ + +
-p spec...
+
--package spec...
+
Only display a report for the specified package
+ + +
+ +## EXAMPLES + +1. Display the latest future-incompat report: + + cargo report future-incompat + +2. Display the latest future-incompat report for a specific package: + + cargo report future-incompat --package my-dep:0.0.1 + +## SEE ALSO +[Future incompat report](../reference/future-incompat-report.html) + +[cargo(1)](cargo.html) diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-run.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-run.md --- cargo-0.58.0/src/doc/src/commands/cargo-run.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-run.md 2022-02-10 02:58:21.000000000 +0000 @@ -99,6 +99,7 @@ +
-r
--release
Run optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name.
@@ -145,7 +146,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-rustc.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-rustc.md --- cargo-0.58.0/src/doc/src/commands/cargo-rustc.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-rustc.md 2022-02-10 02:58:21.000000000 +0000 @@ -168,6 +168,7 @@ +
-r
--release
Build optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name.
@@ -224,7 +225,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
@@ -337,6 +340,12 @@ the number of CPUs. +
--future-incompat-report
+
Displays a future-incompat report for any future-incompatible warnings +produced during execution of this command

+

See cargo-report(1)

+ + ## ENVIRONMENT diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-rustdoc.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-rustdoc.md --- cargo-0.58.0/src/doc/src/commands/cargo-rustdoc.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-rustdoc.md 2022-02-10 02:58:21.000000000 +0000 @@ -183,6 +183,7 @@ +
-r
--release
Document optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name.
@@ -228,7 +229,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-search.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-search.md --- cargo-0.58.0/src/doc/src/commands/cargo-search.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-search.md 2022-02-10 02:58:21.000000000 +0000 @@ -52,7 +52,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-test.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-test.md --- cargo-0.58.0/src/doc/src/commands/cargo-test.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-test.md 2022-02-10 02:58:21.000000000 +0000 @@ -262,6 +262,7 @@ +
-r
--release
Test optimized artifacts with the release profile. See also the --profile option for choosing a specific profile by name.
@@ -314,7 +315,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
@@ -434,6 +437,12 @@ the number of CPUs. +
--future-incompat-report
+
Displays a future-incompat report for any future-incompatible warnings +produced during execution of this command

+

See cargo-report(1)

+ + diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-tree.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-tree.md --- cargo-0.58.0/src/doc/src/commands/cargo-tree.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-tree.md 2022-02-10 02:58:21.000000000 +0000 @@ -280,7 +280,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-uninstall.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-uninstall.md --- cargo-0.58.0/src/doc/src/commands/cargo-uninstall.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-uninstall.md 2022-02-10 02:58:21.000000000 +0000 @@ -61,7 +61,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-update.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-update.md --- cargo-0.58.0/src/doc/src/commands/cargo-update.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-update.md 2022-02-10 02:58:21.000000000 +0000 @@ -70,7 +70,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-vendor.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-vendor.md --- cargo-0.58.0/src/doc/src/commands/cargo-vendor.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-vendor.md 2022-02-10 02:58:21.000000000 +0000 @@ -102,7 +102,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-verify-project.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-verify-project.md --- cargo-0.58.0/src/doc/src/commands/cargo-verify-project.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-verify-project.md 2022-02-10 02:58:21.000000000 +0000 @@ -35,7 +35,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/commands/cargo-yank.md cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-yank.md --- cargo-0.58.0/src/doc/src/commands/cargo-yank.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/commands/cargo-yank.md 2022-02-10 02:58:21.000000000 +0000 @@ -79,7 +79,9 @@
-q
--quiet
-
No output printed to stdout.
+
Do not print cargo log messages. +May also be specified with the term.quiet +config value.
--color when
diff -Nru cargo-0.58.0/src/doc/src/getting-started/first-steps.md cargo-0.60.0ubuntu1/src/doc/src/getting-started/first-steps.md --- cargo-0.58.0/src/doc/src/getting-started/first-steps.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/getting-started/first-steps.md 2022-02-10 02:58:21.000000000 +0000 @@ -33,7 +33,7 @@ [package] name = "hello_world" version = "0.1.0" -edition = "2018" +edition = "2021" [dependencies] ``` diff -Nru cargo-0.58.0/src/doc/src/guide/continuous-integration.md cargo-0.60.0ubuntu1/src/doc/src/guide/continuous-integration.md --- cargo-0.58.0/src/doc/src/guide/continuous-integration.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/guide/continuous-integration.md 2022-02-10 02:58:21.000000000 +0000 @@ -21,6 +21,40 @@ documentation](https://docs.travis-ci.com/user/languages/rust/) for more information. +### GitHub Actions + +To test your package on GitHub Actions, here is a sample `.github/workflows/ci.yml` file: + +```yaml +name: Cargo Build & Test + +on: + push: + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + build_and_test: + name: Rust project - latest + runs-on: ubuntu-latest + strategy: + matrix: + toolchain: + - stable + - beta + - nightly + steps: + - uses: actions/checkout@v2 + - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} + - run: cargo build --verbose + - run: cargo test --verbose + +``` + +This will test all three release channels (note a failure in any toolchain version will fail the entire job). You can also click `"Actions" > "new workflow"` in the GitHub UI and select Rust to add the [default configuration](https://github.com/actions/starter-workflows/blob/main/ci/rust.yml) to your repo. See [GitHub Actions documentation](https://docs.github.com/en/actions) for more information. + ### GitLab CI To test your package on GitLab CI, here is a sample `.gitlab-ci.yml` file: diff -Nru cargo-0.58.0/src/doc/src/guide/creating-a-new-project.md cargo-0.60.0ubuntu1/src/doc/src/guide/creating-a-new-project.md --- cargo-0.58.0/src/doc/src/guide/creating-a-new-project.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/guide/creating-a-new-project.md 2022-02-10 02:58:21.000000000 +0000 @@ -29,7 +29,7 @@ [package] name = "hello_world" version = "0.1.0" -edition = "2018" +edition = "2021" [dependencies] diff -Nru cargo-0.58.0/src/doc/src/guide/dependencies.md cargo-0.60.0ubuntu1/src/doc/src/guide/dependencies.md --- cargo-0.58.0/src/doc/src/guide/dependencies.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/guide/dependencies.md 2022-02-10 02:58:21.000000000 +0000 @@ -20,11 +20,11 @@ time = "0.1.12" ``` -The version string is a [semver] version requirement. The [specifying +The version string is a [SemVer] version requirement. The [specifying dependencies](../reference/specifying-dependencies.md) docs have more information about the options you have here. -[semver]: https://github.com/steveklabnik/semver#requirements +[SemVer]: https://semver.org If we also wanted to add a dependency on the `regex` crate, we would not need to add `[dependencies]` for each crate listed. Here's what your whole @@ -35,7 +35,7 @@ [package] name = "hello_world" version = "0.1.0" -edition = "2018" +edition = "2021" [dependencies] time = "0.1.12" diff -Nru cargo-0.58.0/src/doc/src/reference/build-script-examples.md cargo-0.60.0ubuntu1/src/doc/src/reference/build-script-examples.md --- cargo-0.58.0/src/doc/src/reference/build-script-examples.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/reference/build-script-examples.md 2022-02-10 02:58:21.000000000 +0000 @@ -147,7 +147,7 @@ [package] name = "hello-world-from-c" version = "0.1.0" -edition = "2018" +edition = "2021" ``` For now we’re not going to use any build dependencies, so let’s take a look at @@ -297,7 +297,7 @@ [package] name = "libz-sys" version = "0.1.0" -edition = "2018" +edition = "2021" links = "z" [build-dependencies] @@ -384,7 +384,7 @@ [package] name = "zuser" version = "0.1.0" -edition = "2018" +edition = "2021" [dependencies] libz-sys = "1.0.25" diff -Nru cargo-0.58.0/src/doc/src/reference/config.md cargo-0.60.0ubuntu1/src/doc/src/reference/config.md --- cargo-0.58.0/src/doc/src/reference/config.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/reference/config.md 2022-02-10 02:58:21.000000000 +0000 @@ -87,6 +87,9 @@ # Value is relative to .cargo directory containing `config.toml`, make absolute ENV_VAR_NAME_3 = { value = "relative/path", relative = true } +[future-incompat-report] +frequency = 'always' # when to display a notification about a future incompat report + [cargo-new] vcs = "none" # VCS to use ('git', 'hg', 'pijul', 'fossil', 'none') @@ -168,6 +171,7 @@ metadata_key2 = "value" [term] +quiet = false # whether cargo output is quiet verbose = false # whether cargo provides verbose output color = 'auto' # whether cargo colorizes output progress.when = 'auto' # whether cargo shows progress bar @@ -504,6 +508,20 @@ OPENSSL_DIR = { value = "vendor/openssl", relative = true } ``` +### `[future-incompat-report]` + +The `[future-incompat-report]` table controls setting for [future incompat reporting](future-incompat-report.md) + +#### `future-incompat-report.frequency` +* Type: string +* Default: "always" +* Environment: `CARGO_FUTURE_INCOMPAT_REPORT_FREQUENCY` + +Controls how often we display a notification to the terminal when a future incompat report is available. Possible values: + +* `always` (default): Always display a notification when a command (e.g. `cargo build`) produces a future incompat report +* `never`: Never display a notification + #### `[http]` The `[http]` table defines settings for HTTP behavior. This includes fetching @@ -992,6 +1010,16 @@ The `[term]` table controls terminal output and interaction. +##### `term.quiet` +* Type: boolean +* Default: false +* Environment: `CARGO_TERM_QUIET` + +Controls whether or not log messages are displayed by Cargo. + +Specifying the `--quiet` flag will override and force quiet output. +Specifying the `--verbose` flag will override and disable quiet output. + ##### `term.verbose` * Type: boolean * Default: false diff -Nru cargo-0.58.0/src/doc/src/reference/environment-variables.md cargo-0.60.0ubuntu1/src/doc/src/reference/environment-variables.md --- cargo-0.58.0/src/doc/src/reference/environment-variables.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/reference/environment-variables.md 2022-02-10 02:58:21.000000000 +0000 @@ -83,6 +83,7 @@ * `CARGO_BUILD_DEP_INFO_BASEDIR` — Dep-info relative directory, see [`build.dep-info-basedir`]. * `CARGO_BUILD_PIPELINING` — Whether or not to use `rustc` pipelining, see [`build.pipelining`]. * `CARGO_CARGO_NEW_VCS` — The default source control system with [`cargo new`], see [`cargo-new.vcs`]. +* `CARGO_FUTURE_INCOMPAT_REPORT_FREQUENCY` - How often we should generate a future incompat report notifcation, see [`future-incompat-report.frequency`]. * `CARGO_HTTP_DEBUG` — Enables HTTP debugging, see [`http.debug`]. * `CARGO_HTTP_PROXY` — Enables HTTP proxy, see [`http.proxy`]. * `CARGO_HTTP_TIMEOUT` — The HTTP timeout, see [`http.timeout`]. @@ -114,6 +115,7 @@ * `CARGO_TARGET__LINKER` — The linker to use, see [`target..linker`]. The triple must be [converted to uppercase and underscores](config.md#environment-variables). * `CARGO_TARGET__RUNNER` — The executable runner, see [`target..runner`]. * `CARGO_TARGET__RUSTFLAGS` — Extra `rustc` flags for a target, see [`target..rustflags`]. +* `CARGO_TERM_QUIET` — Quiet mode, see [`term.quiet`]. * `CARGO_TERM_VERBOSE` — The default terminal verbosity, see [`term.verbose`]. * `CARGO_TERM_COLOR` — The default color mode, see [`term.color`]. * `CARGO_TERM_PROGRESS_WHEN` — The default progress bar showing mode, see [`term.progress.when`]. @@ -144,6 +146,7 @@ [`cargo-new.name`]: config.md#cargo-newname [`cargo-new.email`]: config.md#cargo-newemail [`cargo-new.vcs`]: config.md#cargo-newvcs +[`future-incompat-report.frequency`]: config.md#future-incompat-reportfrequency [`http.debug`]: config.md#httpdebug [`http.proxy`]: config.md#httpproxy [`http.timeout`]: config.md#httptimeout @@ -175,6 +178,7 @@ [`target..linker`]: config.md#targettriplelinker [`target..runner`]: config.md#targettriplerunner [`target..rustflags`]: config.md#targettriplerustflags +[`term.quiet`]: config.md#termquiet [`term.verbose`]: config.md#termverbose [`term.color`]: config.md#termcolor [`term.progress.when`]: config.md#termprogresswhen @@ -353,10 +357,10 @@ changed by editing `.cargo/config.toml`; see the documentation about [cargo configuration][cargo-config] for more information. -* `CARGO_ENCODED_RUSTFLAGS` — extra flags that Cargo invokes `rustc` - with, separated by a `0x1f` character - (ASCII Unit Separator). See - [`build.rustflags`]. +* `CARGO_ENCODED_RUSTFLAGS` — extra flags that Cargo invokes `rustc` with, + separated by a `0x1f` character (ASCII Unit Separator). See + [`build.rustflags`]. Note that since Rust 1.55, `RUSTFLAGS` is removed from + the environment; scripts should use `CARGO_ENCODED_RUSTFLAGS` instead. * `CARGO_PKG_` - The package information variables, with the same names and values as are [provided during crate building][variables set for crates]. [unix-like platforms]: ../../reference/conditional-compilation.html#unix-and-windows diff -Nru cargo-0.58.0/src/doc/src/reference/future-incompat-report.md cargo-0.60.0ubuntu1/src/doc/src/reference/future-incompat-report.md --- cargo-0.58.0/src/doc/src/reference/future-incompat-report.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/reference/future-incompat-report.md 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,24 @@ +### Future incompat report + +Cargo checks for future-incompatible warnings in all dependencies. These are warnings for +changes that may become hard errors in the future, causing the dependency to +stop building in a future version of rustc. If any warnings are found, a small +notice is displayed indicating that the warnings were found, and provides +instructions on how to display a full report. + +A full report can be displayed with the `cargo report future-incompatibilities +--id ID` command, or by running the build again with +the `--future-incompat-report` flag. The developer should then update their +dependencies to a version where the issue is fixed, or work with the +developers of the dependencies to help resolve the issue. + +This feature can be configured through a `[future-incompat-report]` +section in `.cargo/config`. Currently, the supported options are: + +``` +[future-incompat-report] +frequency = FREQUENCY +``` + +The supported values for `FREQUENCY` are 'always` and 'never', which control +whether or not a message is printed out at the end of `cargo build` / `cargo check`. diff -Nru cargo-0.58.0/src/doc/src/reference/index.md cargo-0.60.0ubuntu1/src/doc/src/reference/index.md --- cargo-0.58.0/src/doc/src/reference/index.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/reference/index.md 2022-02-10 02:58:21.000000000 +0000 @@ -21,4 +21,5 @@ * [Registries](registries.md) * [Dependency Resolution](resolver.md) * [SemVer Compatibility](semver.md) +* [Future incompat report](future-incompat-report.md) * [Unstable Features](unstable.md) diff -Nru cargo-0.58.0/src/doc/src/reference/profiles.md cargo-0.60.0ubuntu1/src/doc/src/reference/profiles.md --- cargo-0.58.0/src/doc/src/reference/profiles.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/reference/profiles.md 2022-02-10 02:58:21.000000000 +0000 @@ -93,6 +93,28 @@ [nightly channel]: ../../book/appendix-07-nightly-rust.html [`-C split-debuginfo` flag]: ../../rustc/codegen-options/index.html#split-debuginfo +#### strip + +The `strip` option controls the [`-C strip` flag], which directs rustc to +strip either symbols or debuginfo from a binary. This can be enabled like so: + +```toml +[package] +# ... + +[profile.release] +strip = "debuginfo" +``` + +Possible string values of `strip` are `"none"`, `"debuginfo"`, and `"symbols"`. +The default is `"none"`. + +You can also configure this option with the boolean values `true` or `false`. +`strip = true` is equivalent to `strip = "symbols"`. `strip = false` is +equivalent to `strip = "none"` and disables `strip` completely. + +[`-C strip` flag]: ../../rustc/codegen-options/index.html#strip + #### debug-assertions The `debug-assertions` setting controls the [`-C debug-assertions` flag] which @@ -266,15 +288,13 @@ #### test -The `test` profile is used for building tests, or when benchmarks are built in -debug mode with `cargo build`. By default, the `test` profile inherits the -settings from the [`dev`](#dev) profile. +The `test` profile is the default profile used by [`cargo test`]. +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. By default, the `bench` profile inherits the -settings from the [`release`](#release) profile. +The `bench` profile is the default profile used by [`cargo bench`]. +The `bench` profile inherits the settings from the [`release`](#release) profile. #### Build Dependencies @@ -293,7 +313,7 @@ ``` Build dependencies otherwise inherit settings from the active profile in use, as -described below. +described in [Profile selection](#profile-selection). ### Custom profiles @@ -331,11 +351,22 @@ `--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) +| Command | Default Profile | +|---------|-----------------| +| [`cargo run`], [`cargo build`],
[`cargo check`], [`cargo rustc`] | [`dev` profile](#dev) | +| [`cargo test`] | [`test` profile](#test) +| [`cargo bench`] | [`bench` profile](#bench) +| [`cargo install`] | [`release` profile](#release) + +You can switch to a different profile using the `--profile=NAME` option which will used the given profile. +The `--release` flag is equivalent to `--profile=release`. + +The selected profile applies to all Cargo targets, +including [library](./cargo-targets.md#library), +[binary](./cargo-targets.md#binaries), +[example](./cargo-targets.md#examples), +[test](./cargo-targets.md#tests), +and [benchmark](./cargo-targets.md#benchmarks). The profile for specific packages can be specified with [overrides](#overrides), described below. diff -Nru cargo-0.58.0/src/doc/src/reference/registries.md cargo-0.60.0ubuntu1/src/doc/src/reference/registries.md --- cargo-0.58.0/src/doc/src/reference/registries.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/reference/registries.md 2022-02-10 02:58:21.000000000 +0000 @@ -222,9 +222,9 @@ // this is the new name. The original package name is stored in // the `package` field. "name": "rand", - // The semver requirement for this dependency. + // The SemVer requirement for this dependency. // This must be a valid version requirement defined at - // https://github.com/steveklabnik/semver#requirements. + // https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html. "req": "^0.6", // Array of features (as strings) enabled for this dependency. "features": ["i128_support"], diff -Nru cargo-0.58.0/src/doc/src/reference/specifying-dependencies.md cargo-0.60.0ubuntu1/src/doc/src/reference/specifying-dependencies.md --- cargo-0.58.0/src/doc/src/reference/specifying-dependencies.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/reference/specifying-dependencies.md 2022-02-10 02:58:21.000000000 +0000 @@ -19,35 +19,30 @@ time = "0.1.12" ``` -The string `"0.1.12"` is a [semver] version requirement. Since this -string does not have any operators in it, it is interpreted the same way as -if we had specified `"^0.1.12"`, which is called a caret requirement. +The string `"0.1.12"` is a version requirement. Although it looks like a +specific *version* of the `time` crate, it actually specifies a *range* of +versions and allows [SemVer] compatible updates. An update is allowed if the new +version number does not modify the left-most non-zero digit in the major, minor, +patch grouping. In this case, if we ran `cargo update -p time`, cargo should +update us to version `0.1.13` if it is the latest `0.1.z` release, but would not +update us to `0.2.0`. If instead we had specified the version string as `1.0`, +cargo should update to `1.1` if it is the latest `1.y` release, but not `2.0`. +The version `0.0.x` is not considered compatible with any other version. -[semver]: https://github.com/steveklabnik/semver#requirements +[SemVer]: https://semver.org -### Caret requirements - -**Caret requirements** allow SemVer compatible updates to a specified version. -An update is allowed if the new version number does not modify the left-most -non-zero digit in the major, minor, patch grouping. In this case, if we ran -`cargo update -p time`, cargo should update us to version `0.1.13` if it is the -latest `0.1.z` release, but would not update us to `0.2.0`. If instead we had -specified the version string as `^1.0`, cargo should update to `1.1` if it is -the latest `1.y` release, but not `2.0`. The version `0.0.x` is not considered -compatible with any other version. - -Here are some more examples of caret requirements and the versions that would +Here are some more examples of version requirements and the versions that would be allowed with them: ```notrust -^1.2.3 := >=1.2.3, <2.0.0 -^1.2 := >=1.2.0, <2.0.0 -^1 := >=1.0.0, <2.0.0 -^0.2.3 := >=0.2.3, <0.3.0 -^0.2 := >=0.2.0, <0.3.0 -^0.0.3 := >=0.0.3, <0.0.4 -^0.0 := >=0.0.0, <0.1.0 -^0 := >=0.0.0, <1.0.0 +1.2.3 := >=1.2.3, <2.0.0 +1.2 := >=1.2.0, <2.0.0 +1 := >=1.0.0, <2.0.0 +0.2.3 := >=0.2.3, <0.3.0 +0.2 := >=0.2.0, <0.3.0 +0.0.3 := >=0.0.3, <0.0.4 +0.0 := >=0.0.0, <0.1.0 +0 := >=0.0.0, <1.0.0 ``` This compatibility convention is different from SemVer in the way it treats @@ -55,6 +50,14 @@ 1.0.0, Cargo considers `0.x.y` to be compatible with `0.x.z`, where `y ≥ z` and `x > 0`. +It is possible to further tweak the logic for selecting compatible versions +using special operators, though it shouldn't be necessary most of the time. + +### Caret requirements + +**Caret requirements** are an alternative syntax for the default strategy, +`^1.2.3` is exactly equivalent to `1.2.3`. + ### Tilde requirements **Tilde requirements** specify a minimal version with some ability to update. diff -Nru cargo-0.58.0/src/doc/src/reference/unstable.md cargo-0.60.0ubuntu1/src/doc/src/reference/unstable.md --- cargo-0.58.0/src/doc/src/reference/unstable.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/reference/unstable.md 2022-02-10 02:58:21.000000000 +0000 @@ -83,6 +83,7 @@ * [build-std-features](#build-std-features) — Sets features to use with the standard library. * [binary-dep-depinfo](#binary-dep-depinfo) — Causes the dep-info file to track binary dependencies. * [panic-abort-tests](#panic-abort-tests) — Allows running tests with the "abort" panic strategy. + * [crate-type](#crate-type) - Supports passing crate types to the compiler. * rustdoc * [`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/). @@ -93,7 +94,6 @@ * [Build-plan](#build-plan) — Emits JSON information on which commands will be run. * [timings](#timings) — Generates a report on how long individual dependencies took to run. * [unit-graph](#unit-graph) — Emits JSON for Cargo's internal graph structure. - * [future incompat report](#future-incompat-report) — Displays a report for future incompatibilities that may error in the future. * [`cargo rustc --print`](#rustc---print) — Calls rustc with `--print` to display information from rustc. * Configuration * [config-cli](#config-cli) — Adds the ability to pass configuration options on the command-line. @@ -506,7 +506,8 @@ The "custom build" units are `build.rs` scripts, which when run are highlighted in orange. -The second graph shows Cargo's concurrency over time. The three lines are: +The second graph shows Cargo's concurrency over time. The background +indicates CPU usage. The three lines are: - "Waiting" (red) — This is the number of units waiting for a CPU slot to open. - "Inactive" (blue) — This is the number of units that are waiting for their @@ -554,6 +555,23 @@ [rust-lang/rust#64158]: https://github.com/rust-lang/rust/pull/64158 +### crate-type +* Tracking Issue: [#10083](https://github.com/rust-lang/cargo/issues/10083) +* RFC: [#3180](https://github.com/rust-lang/rfcs/pull/3180) +* Original Pull Request: [#10093](https://github.com/rust-lang/cargo/pull/10093) + +`cargo rustc --crate-type=lib,cdylib` forwards the `--crate-type` flag to `rustc`. +This runs `rustc` with the corresponding +[`--crate-type`](https://doc.rust-lang.org/rustc/command-line-arguments.html#--crate-type-a-list-of-types-of-crates-for-the-compiler-to-emit) +flag, and compiling. + +When using it, it requires the `-Z unstable-options` +command-line option: + +```console +cargo rustc --crate-type lib,cdylib -Z unstable-options +``` + ### config-cli * Tracking Issue: [#7722](https://github.com/rust-lang/cargo/issues/7722) @@ -802,28 +820,6 @@ } ``` -### Profile `strip` option -* Tracking Issue: [rust-lang/rust#72110](https://github.com/rust-lang/rust/issues/72110) - -This feature provides a new option in the `[profile]` section to strip either -symbols or debuginfo from a binary. This can be enabled like so: - -```toml -cargo-features = ["strip"] - -[package] -# ... - -[profile.release] -strip = "debuginfo" -``` - -Other possible string values of `strip` are `none`, `symbols`, and `off`. The default is `none`. - -You can also configure this option with the two absolute boolean values -`true` and `false`. The former enables `strip` at its higher level, `symbols`, -while the latter disables `strip` completely. - ### rustdoc-map * Tracking Issue: [#8296](https://github.com/rust-lang/cargo/issues/8296) @@ -1124,35 +1120,6 @@ [crates.io]: https://crates.io/ [config file]: config.md -### future incompat report -* RFC: [#2834](https://github.com/rust-lang/rfcs/blob/master/text/2834-cargo-report-future-incompat.md) -* rustc Tracking Issue: [#71249](https://github.com/rust-lang/rust/issues/71249) - -The `-Z future-incompat-report` flag causes Cargo to check for -future-incompatible warnings in all dependencies. These are warnings for -changes that may become hard errors in the future, causing the dependency to -stop building in a future version of rustc. If any warnings are found, a small -notice is displayed indicating that the warnings were found, and provides -instructions on how to display a full report. - -A full report can be displayed with the `cargo report future-incompatibilities --Z future-incompat-report --id ID` command, or by running the build again with -the `--future-incompat-report` flag. The developer should then update their -dependencies to a version where the issue is fixed, or work with the -developers of the dependencies to help resolve the issue. - -This feature can be configured through a `[future-incompat-report]` -section in `.cargo/config`. Currently, the supported options are: - -``` -[future-incompat-report] -frequency = FREQUENCY -``` - -The supported values for `FREQUENCY` are 'always` and 'never', which control -whether or not a message is printed out at the end of `cargo build` / `cargo check`. - - ### `cargo config` * Original Issue: [#2362](https://github.com/rust-lang/cargo/issues/2362) @@ -1207,7 +1174,7 @@ * Tracking Issue: [#9778](https://github.com/rust-lang/cargo/issues/9778) * PR: [#9627](https://github.com/rust-lang/cargo/pull/9627) -The `different-binary-name` feature allows setting the filename of the binary without having to obey the +The `different-binary-name` feature allows setting the filename of the binary without having to obey the restrictions placed on crate names. For example, the crate name must use only `alphanumeric` characters or `-` or `_`, and cannot be empty. @@ -1229,6 +1196,20 @@ path = "src/main.rs" ``` +### scrape-examples + +* RFC: [#3123](https://github.com/rust-lang/rfcs/pull/3123) +* Tracking Issue: [#9910](https://github.com/rust-lang/cargo/issues/9910) + +The `-Z rustdoc-scrape-examples` argument tells Rustdoc to search crates in the current workspace +for calls to functions. Those call-sites are then included as documentation. The flag can take an +argument of `all` or `examples` which configures which crate in the workspace to analyze for examples. +For instance: + +``` +cargo doc -Z unstable-options -Z rustdoc-scrape-examples=examples +``` + ## Stabilized and removed features ### Compile progress @@ -1378,7 +1359,19 @@ 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. + +### Profile `strip` option + +The profile `strip` option has been stabilized in the 1.59 release. See the +[profiles chapter](profiles.md#strip) for more information. + +### Future incompat report + +Support for generating a future-incompat report has been stabilized +in the 1.59 release. See the [future incompat report chapter](future-incompat-report.md) +for more information. diff -Nru cargo-0.58.0/src/doc/src/SUMMARY.md cargo-0.60.0ubuntu1/src/doc/src/SUMMARY.md --- cargo-0.58.0/src/doc/src/SUMMARY.md 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/doc/src/SUMMARY.md 2022-02-10 02:58:21.000000000 +0000 @@ -38,6 +38,7 @@ * [Registries](reference/registries.md) * [Dependency Resolution](reference/resolver.md) * [SemVer Compatibility](reference/semver.md) + * [Future incompat report](reference/future-incompat-report.md) * [Unstable Features](reference/unstable.md) * [Cargo Commands](commands/index.md) @@ -57,6 +58,7 @@ * [cargo rustc](commands/cargo-rustc.md) * [cargo rustdoc](commands/cargo-rustdoc.md) * [cargo test](commands/cargo-test.md) + * [cargo report](commands/cargo-report.md) * [Manifest Commands](commands/manifest-commands.md) * [cargo generate-lockfile](commands/cargo-generate-lockfile.md) * [cargo locate-project](commands/cargo-locate-project.md) diff -Nru cargo-0.58.0/src/etc/man/cargo.1 cargo-0.60.0ubuntu1/src/etc/man/cargo.1 --- cargo-0.58.0/src/etc/man/cargo.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo.1 2022-02-10 02:58:21.000000000 +0000 @@ -178,7 +178,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-bench.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-bench.1 --- cargo-0.58.0/src/etc/man/cargo-bench.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-bench.1 2022-02-10 02:58:21.000000000 +0000 @@ -300,7 +300,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-build.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-build.1 --- cargo-0.58.0/src/etc/man/cargo-build.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-build.1 2022-02-10 02:58:21.000000000 +0000 @@ -169,6 +169,7 @@ \fIbuild cache\fR documentation for more details. .RE .sp +\fB\-r\fR, \fB\-\-release\fR .RS 4 Build optimized artifacts with the \fBrelease\fR profile. @@ -219,7 +220,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR @@ -359,6 +362,14 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE +.sp +\fB\-\-future\-incompat\-report\fR +.RS 4 +Displays a future\-incompat report for any future\-incompatible warnings +produced during execution of this command +.sp +See \fBcargo\-report\fR(1) +.RE .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.58.0/src/etc/man/cargo-check.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-check.1 --- cargo-0.58.0/src/etc/man/cargo-check.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-check.1 2022-02-10 02:58:21.000000000 +0000 @@ -174,6 +174,7 @@ \fIbuild cache\fR documentation for more details. .RE .sp +\fB\-r\fR, \fB\-\-release\fR .RS 4 Check optimized artifacts with the \fBrelease\fR profile. @@ -220,7 +221,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR @@ -349,6 +352,14 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE +.sp +\fB\-\-future\-incompat\-report\fR +.RS 4 +Displays a future\-incompat report for any future\-incompatible warnings +produced during execution of this command +.sp +See \fBcargo\-report\fR(1) +.RE .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.58.0/src/etc/man/cargo-clean.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-clean.1 --- cargo-0.58.0/src/etc/man/cargo-clean.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-clean.1 2022-02-10 02:58:21.000000000 +0000 @@ -77,7 +77,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-doc.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-doc.1 --- cargo-0.58.0/src/etc/man/cargo-doc.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-doc.1 2022-02-10 02:58:21.000000000 +0000 @@ -147,6 +147,7 @@ \fIbuild cache\fR documentation for more details. .RE .sp +\fB\-r\fR, \fB\-\-release\fR .RS 4 Document optimized artifacts with the \fBrelease\fR profile. @@ -187,7 +188,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-fetch.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-fetch.1 --- cargo-0.58.0/src/etc/man/cargo-fetch.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-fetch.1 2022-02-10 02:58:21.000000000 +0000 @@ -51,7 +51,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-fix.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-fix.1 --- cargo-0.58.0/src/etc/man/cargo-fix.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-fix.1 2022-02-10 02:58:21.000000000 +0000 @@ -269,6 +269,7 @@ \fIbuild cache\fR documentation for more details. .RE .sp +\fB\-r\fR, \fB\-\-release\fR .RS 4 Fix optimized artifacts with the \fBrelease\fR profile. @@ -315,7 +316,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-generate-lockfile.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-generate-lockfile.1 --- cargo-0.58.0/src/etc/man/cargo-generate-lockfile.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-generate-lockfile.1 2022-02-10 02:58:21.000000000 +0000 @@ -29,7 +29,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-init.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-init.1 --- cargo-0.58.0/src/etc/man/cargo-init.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-init.1 2022-02-10 02:58:21.000000000 +0000 @@ -78,7 +78,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-install.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-install.1 --- cargo-0.58.0/src/etc/man/cargo-install.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-install.1 2022-02-10 02:58:21.000000000 +0000 @@ -319,7 +319,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR @@ -342,6 +344,46 @@ May also be specified with the \fBterm.color\fR \fIconfig value\fR \&. .RE +.sp +\fB\-\-message\-format\fR \fIfmt\fR +.RS 4 +The output format for diagnostic messages. Can be specified multiple times +and consists of comma\-separated values. Valid values: +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBhuman\fR (default): Display in a human\-readable text format. Conflicts with +\fBshort\fR and \fBjson\fR\&. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBshort\fR: Emit shorter, human\-readable text messages. Conflicts with \fBhuman\fR +and \fBjson\fR\&. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBjson\fR: Emit JSON messages to stdout. See +\fIthe reference\fR +for more details. Conflicts with \fBhuman\fR and \fBshort\fR\&. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBjson\-diagnostic\-short\fR: Ensure the \fBrendered\fR field of JSON messages contains +the "short" rendering from rustc. Cannot be used with \fBhuman\fR or \fBshort\fR\&. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBjson\-diagnostic\-rendered\-ansi\fR: Ensure the \fBrendered\fR field of JSON messages +contains embedded ANSI color codes for respecting rustc's default color +scheme. Cannot be used with \fBhuman\fR or \fBshort\fR\&. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBjson\-render\-diagnostics\fR: Instruct Cargo to not include rustc diagnostics in +in JSON messages printed, but instead Cargo itself should render the +JSON diagnostics coming from rustc. Cargo's own JSON diagnostics and others +coming from rustc are still emitted. Cannot be used with \fBhuman\fR or \fBshort\fR\&. +.RE +.RE .SS "Common Options" .sp \fB+\fR\fItoolchain\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-locate-project.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-locate-project.1 --- cargo-0.58.0/src/etc/man/cargo-locate-project.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-locate-project.1 2022-02-10 02:58:21.000000000 +0000 @@ -44,7 +44,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-login.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-login.1 --- cargo-0.58.0/src/etc/man/cargo-login.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-login.1 2022-02-10 02:58:21.000000000 +0000 @@ -42,7 +42,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-metadata.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-metadata.1 --- cargo-0.58.0/src/etc/man/cargo-metadata.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-metadata.1 2022-02-10 02:58:21.000000000 +0000 @@ -179,6 +179,8 @@ ], /* Optional string that is the default binary picked by cargo run. */ "default_run": null, + /* Optional string that is the minimum supported rust version */ + "rust_version": "1.56", /* Array of keywords from the manifest. */ "keywords": [ "cli" @@ -350,7 +352,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-new.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-new.1 --- cargo-0.58.0/src/etc/man/cargo-new.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-new.1 2022-02-10 02:58:21.000000000 +0000 @@ -73,7 +73,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-owner.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-owner.1 --- cargo-0.58.0/src/etc/man/cargo-owner.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-owner.1 2022-02-10 02:58:21.000000000 +0000 @@ -84,7 +84,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-package.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-package.1 --- cargo-0.58.0/src/etc/man/cargo-package.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-package.1 2022-02-10 02:58:21.000000000 +0000 @@ -249,7 +249,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-pkgid.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-pkgid.1 --- cargo-0.58.0/src/etc/man/cargo-pkgid.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-pkgid.1 2022-02-10 02:58:21.000000000 +0000 @@ -84,7 +84,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-publish.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-publish.1 --- cargo-0.58.0/src/etc/man/cargo-publish.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-publish.1 2022-02-10 02:58:21.000000000 +0000 @@ -199,7 +199,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-report.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-report.1 --- cargo-0.58.0/src/etc/man/cargo-report.1 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-report.1 2022-02-10 02:58:21.000000000 +0000 @@ -0,0 +1,48 @@ +'\" t +.TH "CARGO\-REPORT" "1" +.nh +.ad l +.ss \n[.ss] 0 +.SH "NAME" +cargo\-report \- Generate and display various kinds of reports +.SH "SYNOPSIS" +\fBcargo report\fR \fItype\fR [\fIoptions\fR] +.SS "DESCRIPTION" +Displays a report of the given \fItype\fR \- currently, only \fBfuture\-incompat\fR is supported +.SH "OPTIONS" +.sp +\fB\-\-id\fR \fIid\fR +.RS 4 +Show the report with the specified Cargo\-generated id +.RE +.sp +\fB\-p\fR \fIspec\fR\&..., +\fB\-\-package\fR \fIspec\fR\&... +.RS 4 +Only display a report for the specified package +.RE +.SH "EXAMPLES" +.sp +.RS 4 +\h'-04' 1.\h'+01'Display the latest future\-incompat report: +.sp +.RS 4 +.nf +cargo report future\-incompat +.fi +.RE +.RE +.sp +.RS 4 +\h'-04' 2.\h'+01'Display the latest future\-incompat report for a specific package: +.sp +.RS 4 +.nf +cargo report future\-incompat \-\-package my\-dep:0.0.1 +.fi +.RE +.RE +.SH "SEE ALSO" +\fIFuture incompat report\fR +.sp +\fBcargo\fR(1) diff -Nru cargo-0.58.0/src/etc/man/cargo-run.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-run.1 --- cargo-0.58.0/src/etc/man/cargo-run.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-run.1 2022-02-10 02:58:21.000000000 +0000 @@ -80,6 +80,7 @@ \fIbuild cache\fR documentation for more details. .RE .sp +\fB\-r\fR, \fB\-\-release\fR .RS 4 Run optimized artifacts with the \fBrelease\fR profile. @@ -120,7 +121,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-rustc.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-rustc.1 --- cargo-0.58.0/src/etc/man/cargo-rustc.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-rustc.1 2022-02-10 02:58:21.000000000 +0000 @@ -155,6 +155,7 @@ \fIbuild cache\fR documentation for more details. .RE .sp +\fB\-r\fR, \fB\-\-release\fR .RS 4 Build optimized artifacts with the \fBrelease\fR profile. @@ -215,7 +216,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR @@ -344,6 +347,14 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE +.sp +\fB\-\-future\-incompat\-report\fR +.RS 4 +Displays a future\-incompat report for any future\-incompatible warnings +produced during execution of this command +.sp +See \fBcargo\-report\fR(1) +.RE .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.58.0/src/etc/man/cargo-rustdoc.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-rustdoc.1 --- cargo-0.58.0/src/etc/man/cargo-rustdoc.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-rustdoc.1 2022-02-10 02:58:21.000000000 +0000 @@ -166,6 +166,7 @@ \fIbuild cache\fR documentation for more details. .RE .sp +\fB\-r\fR, \fB\-\-release\fR .RS 4 Document optimized artifacts with the \fBrelease\fR profile. @@ -206,7 +207,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-search.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-search.1 --- cargo-0.58.0/src/etc/man/cargo-search.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-search.1 2022-02-10 02:58:21.000000000 +0000 @@ -45,7 +45,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-test.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-test.1 --- cargo-0.58.0/src/etc/man/cargo-test.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-test.1 2022-02-10 02:58:21.000000000 +0000 @@ -266,6 +266,7 @@ \fIbuild cache\fR documentation for more details. .RE .sp +\fB\-r\fR, \fB\-\-release\fR .RS 4 Test optimized artifacts with the \fBrelease\fR profile. @@ -315,7 +316,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR @@ -453,6 +456,14 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE +.sp +\fB\-\-future\-incompat\-report\fR +.RS 4 +Displays a future\-incompat report for any future\-incompatible warnings +produced during execution of this command +.sp +See \fBcargo\-report\fR(1) +.RE .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.58.0/src/etc/man/cargo-tree.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-tree.1 --- cargo-0.58.0/src/etc/man/cargo-tree.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-tree.1 2022-02-10 02:58:21.000000000 +0000 @@ -317,7 +317,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-uninstall.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-uninstall.1 --- cargo-0.58.0/src/etc/man/cargo-uninstall.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-uninstall.1 2022-02-10 02:58:21.000000000 +0000 @@ -68,7 +68,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-update.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-update.1 --- cargo-0.58.0/src/etc/man/cargo-update.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-update.1 2022-02-10 02:58:21.000000000 +0000 @@ -69,7 +69,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-vendor.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-vendor.1 --- cargo-0.58.0/src/etc/man/cargo-vendor.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-vendor.1 2022-02-10 02:58:21.000000000 +0000 @@ -96,7 +96,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-verify-project.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-verify-project.1 --- cargo-0.58.0/src/etc/man/cargo-verify-project.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-verify-project.1 2022-02-10 02:58:21.000000000 +0000 @@ -39,7 +39,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/src/etc/man/cargo-yank.1 cargo-0.60.0ubuntu1/src/etc/man/cargo-yank.1 --- cargo-0.58.0/src/etc/man/cargo-yank.1 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/src/etc/man/cargo-yank.1 2022-02-10 02:58:21.000000000 +0000 @@ -73,7 +73,9 @@ \fB\-q\fR, \fB\-\-quiet\fR .RS 4 -No output printed to stdout. +Do not print cargo log messages. +May also be specified with the \fBterm.quiet\fR +\fIconfig value\fR \&. .RE .sp \fB\-\-color\fR \fIwhen\fR diff -Nru cargo-0.58.0/tests/testsuite/alt_registry.rs cargo-0.60.0ubuntu1/tests/testsuite/alt_registry.rs --- cargo-0.58.0/tests/testsuite/alt_registry.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/alt_registry.rs 2022-02-10 02:58:21.000000000 +0000 @@ -823,6 +823,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -880,6 +881,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -905,6 +907,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -930,6 +933,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -980,6 +984,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -1018,6 +1023,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -1115,6 +1121,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -1140,6 +1147,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -1178,6 +1186,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", diff -Nru cargo-0.58.0/tests/testsuite/build.rs cargo-0.60.0ubuntu1/tests/testsuite/build.rs --- cargo-0.58.0/tests/testsuite/build.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/build.rs 2022-02-10 02:58:21.000000000 +0000 @@ -1668,7 +1668,7 @@ } #[cargo_test] -/// Make sure broken symlinks don't break the build +/// Make sure broken and loop symlinks don't break the build /// /// This test requires you to be able to make symlinks. /// For windows, this may require you to enable developer mode. @@ -1681,9 +1681,17 @@ .file("Cargo.toml", &basic_bin_manifest("foo")) .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) .symlink("Notafile", "bar") + // To hit the symlink directory, we need a build script + // to trigger a full scan of package files. + .file("build.rs", &main_file(r#""build script""#, &[])) + .symlink_dir("a/b", "a/b/c/d/foo") .build(); - p.cargo("build").run(); + p.cargo("build") + .with_stderr_contains( + "[WARNING] File system loop found: [..]/a/b/c/d/foo points to an ancestor [..]/a/b", + ) + .run(); assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("i am foo\n").run(); @@ -1707,11 +1715,6 @@ #[cargo_test] fn lto_build() { - // FIXME: currently this hits a linker bug on 32-bit MSVC - if cfg!(all(target_env = "msvc", target_pointer_width = "32")) { - return; - } - let p = project() .file( "Cargo.toml", @@ -1781,6 +1784,25 @@ } #[cargo_test] +fn verbose_release_build_short() { + let p = project().file("src/lib.rs", "").build(); + p.cargo("build -v -r") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \ + --emit=[..]link[..]\ + -C opt-level=3[..]\ + -C metadata=[..] \ + --out-dir [..] \ + -L dependency=[CWD]/target/release/deps` +[FINISHED] release [optimized] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] fn verbose_release_build_deps() { let p = project() .file( @@ -1900,6 +1922,40 @@ } #[cargo_test] +fn non_existing_test() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "1.0.0" + + [lib] + name = "foo" + path = "src/lib.rs" + + [[test]] + name = "hello" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build --tests -v") + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[..]` + +Caused by: + can't find `hello` test at `tests/hello.rs` or `tests/hello/main.rs`. \ + Please specify test.path if you want to use a non-default path.", + ) + .run(); +} + +#[cargo_test] fn non_existing_example() { let p = project() .file( @@ -1908,7 +1964,6 @@ [package] name = "foo" version = "1.0.0" - authors = [] [lib] name = "foo" @@ -1921,14 +1976,49 @@ .file("src/lib.rs", "") .build(); - p.cargo("test -v") + p.cargo("build --examples -v") .with_status(101) .with_stderr( "\ [ERROR] failed to parse manifest at `[..]` Caused by: - can't find `hello` example, specify example.path", + can't find `hello` example at `examples/hello.rs` or `examples/hello/main.rs`. \ + Please specify example.path if you want to use a non-default path.", + ) + .run(); +} + +#[cargo_test] +fn non_existing_benchmark() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "1.0.0" + + [lib] + name = "foo" + path = "src/lib.rs" + + [[bench]] + name = "hello" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build --benches -v") + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[..]` + +Caused by: + can't find `hello` bench at `benches/hello.rs` or `benches/hello/main.rs`. \ + Please specify bench.path if you want to use a non-default path.", ) .run(); } @@ -1948,7 +2038,184 @@ [ERROR] failed to parse manifest at `[..]` Caused by: - can't find `foo` bin, specify bin.path", + can't find `foo` bin at `src/bin/foo.rs` or `src/bin/foo/main.rs`. \ + Please specify bin.path if you want to use a non-default path.", + ) + .run(); +} + +#[cargo_test] +fn commonly_wrong_path_of_test() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "1.0.0" + + [lib] + name = "foo" + path = "src/lib.rs" + + [[test]] + name = "foo" + "#, + ) + .file("src/lib.rs", "") + .file("test/foo.rs", "") + .build(); + + p.cargo("build --tests -v") + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[..]` + +Caused by: + can't find `foo` test at default paths, but found a file at `test/foo.rs`. + Perhaps rename the file to `tests/foo.rs` for target auto-discovery, \ + or specify test.path if you want to use a non-default path.", + ) + .run(); +} + +#[cargo_test] +fn commonly_wrong_path_of_example() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "1.0.0" + + [lib] + name = "foo" + path = "src/lib.rs" + + [[example]] + name = "foo" + "#, + ) + .file("src/lib.rs", "") + .file("example/foo.rs", "") + .build(); + + p.cargo("build --examples -v") + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[..]` + +Caused by: + can't find `foo` example at default paths, but found a file at `example/foo.rs`. + Perhaps rename the file to `examples/foo.rs` for target auto-discovery, \ + or specify example.path if you want to use a non-default path.", + ) + .run(); +} + +#[cargo_test] +fn commonly_wrong_path_of_benchmark() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "1.0.0" + + [lib] + name = "foo" + path = "src/lib.rs" + + [[bench]] + name = "foo" + "#, + ) + .file("src/lib.rs", "") + .file("bench/foo.rs", "") + .build(); + + p.cargo("build --benches -v") + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[..]` + +Caused by: + can't find `foo` bench at default paths, but found a file at `bench/foo.rs`. + Perhaps rename the file to `benches/foo.rs` for target auto-discovery, \ + or specify bench.path if you want to use a non-default path.", + ) + .run(); +} + +#[cargo_test] +fn commonly_wrong_path_binary() { + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/lib.rs", "") + .file("src/bins/foo.rs", "") + .build(); + + p.cargo("build -v") + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[..]` + +Caused by: + can't find `foo` bin at default paths, but found a file at `src/bins/foo.rs`. + Perhaps rename the file to `src/bin/foo.rs` for target auto-discovery, \ + or specify bin.path if you want to use a non-default path.", + ) + .run(); +} + +#[cargo_test] +fn commonly_wrong_path_subdir_binary() { + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/lib.rs", "") + .file("src/bins/foo/main.rs", "") + .build(); + + p.cargo("build -v") + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[..]` + +Caused by: + can't find `foo` bin at default paths, but found a file at `src/bins/foo/main.rs`. + Perhaps rename the file to `src/bin/foo/main.rs` for target auto-discovery, \ + or specify bin.path if you want to use a non-default path.", + ) + .run(); +} + +#[cargo_test] +fn found_multiple_target_files() { + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/lib.rs", "") + .file("src/bin/foo.rs", "") + .file("src/bin/foo/main.rs", "") + .build(); + + p.cargo("build -v") + .with_status(101) + // Don't assert the inferred pathes since the order is non-deterministic. + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[..]` + +Caused by: + cannot infer path for `foo` bin + Cargo doesn't know which to use because multiple target files found \ + at `src/bin/foo[..].rs` and `src/bin/foo[..].rs`.", ) .run(); } @@ -4319,7 +4586,7 @@ [ERROR] failed to parse manifest at `[..]` Caused by: - can't find `foo` bin, specify bin.path", + can't find `foo` bin at `src/bin/foo.rs` or `src/bin/foo/main.rs`. [..]", ) .run(); } @@ -4529,7 +4796,9 @@ p.cargo("build") .with_status(101) - .with_stderr_contains("[..]can't find `a_bin` bin, specify bin.path") + .with_stderr_contains( + "[..]can't find `a_bin` bin at `src/bin/a_bin.rs` or `src/bin/a_bin/main.rs`[..]", + ) .run(); } diff -Nru cargo-0.58.0/tests/testsuite/build_script_extra_link_arg.rs cargo-0.60.0ubuntu1/tests/testsuite/build_script_extra_link_arg.rs --- cargo-0.58.0/tests/testsuite/build_script_extra_link_arg.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/build_script_extra_link_arg.rs 2022-02-10 02:58:21.000000000 +0000 @@ -279,3 +279,34 @@ .with_stderr_does_not_contain("--bogus") .run(); } + +#[cargo_test] +fn link_arg_with_doctest() { + let p = project() + .file( + "src/lib.rs", + r#" + //! ``` + //! let x = 5; + //! assert_eq!(x, 5); + //! ``` + "#, + ) + .file( + "build.rs", + r#" + fn main() { + println!("cargo:rustc-link-arg=--this-is-a-bogus-flag"); + } + "#, + ) + .build(); + + p.cargo("test --doc -v") + .masquerade_as_nightly_cargo() + .without_status() + .with_stderr_contains( + "[RUNNING] `rustdoc [..]--crate-name foo [..]-C link-arg=--this-is-a-bogus-flag[..]", + ) + .run(); +} diff -Nru cargo-0.58.0/tests/testsuite/build_script.rs cargo-0.60.0ubuntu1/tests/testsuite/build_script.rs --- cargo-0.58.0/tests/testsuite/build_script.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/build_script.rs 2022-02-10 02:58:21.000000000 +0000 @@ -4619,69 +4619,6 @@ } #[cargo_test] -#[cfg(unix)] -fn build_script_scan_eacces() { - // build.rs causes a scan of the whole project, which can be a problem if - // a directory is not accessible. - use cargo_test_support::git; - use std::os::unix::fs::PermissionsExt; - - let p = project() - .file("src/lib.rs", "") - .file("build.rs", "fn main() {}") - .file("secrets/stuff", "") - .build(); - let path = p.root().join("secrets"); - fs::set_permissions(&path, fs::Permissions::from_mode(0o0)).unwrap(); - // The last "Caused by" is a string from libc such as the following: - // Permission denied (os error 13) - p.cargo("build") - .with_stderr( - "\ -[ERROR] failed to determine package fingerprint for build script for foo v0.0.1 ([..]/foo) - -Caused by: - failed to determine the most recently modified file in [..]/foo - -Caused by: - failed to determine list of files in [..]/foo - -Caused by: - cannot read \"[..]/foo/secrets\" - -Caused by: - [..] -", - ) - .with_status(101) - .run(); - - // Try `package.exclude` to skip a directory. - p.change_file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - exclude = ["secrets"] - "#, - ); - p.cargo("build").run(); - - // Try with git. This succeeds because the git status walker ignores - // directories it can't access. - p.change_file("Cargo.toml", &basic_manifest("foo", "0.0.1")); - p.build_dir().rm_rf(); - let repo = git::init(&p.root()); - git::add(&repo); - git::commit(&repo); - p.cargo("build").run(); - - // Restore permissions so that the directory can be deleted. - fs::set_permissions(&path, fs::Permissions::from_mode(0o755)).unwrap(); -} - -#[cargo_test] fn dev_dep_with_links() { let p = project() .file( diff -Nru cargo-0.58.0/tests/testsuite/cargo_alias_config.rs cargo-0.60.0ubuntu1/tests/testsuite/cargo_alias_config.rs --- cargo-0.58.0/tests/testsuite/cargo_alias_config.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/cargo_alias_config.rs 2022-02-10 02:58:21.000000000 +0000 @@ -77,6 +77,38 @@ } #[cargo_test] +fn alias_shadowing_external_subcommand() { + let echo = echo_subcommand(); + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/main.rs", "fn main() {}") + .file( + ".cargo/config", + r#" + [alias] + echo = "build" + "#, + ) + .build(); + + let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap_or_default()).collect(); + paths.push(echo.target_debug_dir()); + let path = env::join_paths(paths).unwrap(); + + p.cargo("echo") + .env("PATH", &path) + .with_stderr("\ +[WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]` +This was previously accepted but is being phased out; it will become a hard error in a future release. +For more information, see issue #10049 . +[COMPILING] foo v0.5.0 [..] +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] fn default_args_alias() { let echo = echo_subcommand(); let p = project() @@ -100,14 +132,24 @@ p.cargo("echo") .env("PATH", &path) .with_status(101) - .with_stderr("error: alias echo has unresolvable recursive definition: echo -> echo") + .with_stderr("\ +[WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]` +This was previously accepted but is being phased out; it will become a hard error in a future release. +For more information, see issue #10049 . +error: alias echo has unresolvable recursive definition: echo -> echo +", + ) .run(); p.cargo("test-1") .env("PATH", &path) .with_status(101) - .with_stderr( - "error: alias test-1 has unresolvable recursive definition: test-1 -> echo -> echo", + .with_stderr("\ +[WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]` +This was previously accepted but is being phased out; it will become a hard error in a future release. +For more information, see issue #10049 . +error: alias test-1 has unresolvable recursive definition: test-1 -> echo -> echo +", ) .run(); diff -Nru cargo-0.58.0/tests/testsuite/cargo_command.rs cargo-0.60.0ubuntu1/tests/testsuite/cargo_command.rs --- cargo-0.58.0/tests/testsuite/cargo_command.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/cargo_command.rs 2022-02-10 02:58:21.000000000 +0000 @@ -57,8 +57,8 @@ .build(); p.cargo("--list") - .with_stdout_contains(" myaliasstr foo --bar") - .with_stdout_contains(" myaliasvec foo --bar") + .with_stdout_contains(" myaliasstr alias: foo --bar") + .with_stdout_contains(" myaliasvec alias: foo --bar") .run(); } @@ -148,6 +148,34 @@ } #[cargo_test] +fn find_closest_capital_c_to_c() { + cargo_process("C") + .with_status(101) + .with_stderr_contains( + "\ +error: no such subcommand: `C` + +Did you mean `c`? +", + ) + .run(); +} + +#[cargo_test] +fn find_closest_captial_b_to_b() { + cargo_process("B") + .with_status(101) + .with_stderr_contains( + "\ +error: no such subcommand: `B` + +Did you mean `b`? +", + ) + .run(); +} + +#[cargo_test] fn find_closest_biuld_to_build() { cargo_process("biuld") .with_status(101) diff -Nru cargo-0.58.0/tests/testsuite/clean.rs cargo-0.60.0ubuntu1/tests/testsuite/clean.rs --- cargo-0.58.0/tests/testsuite/clean.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/clean.rs 2022-02-10 02:58:21.000000000 +0000 @@ -2,9 +2,12 @@ use cargo_test_support::paths::is_symlink; use cargo_test_support::registry::Package; -use cargo_test_support::{basic_bin_manifest, basic_manifest, git, main_file, project, rustc_host}; +use cargo_test_support::{ + basic_bin_manifest, basic_manifest, git, main_file, project, project_in, rustc_host, +}; +use glob::GlobError; use std::env; -use std::path::Path; +use std::path::{Path, PathBuf}; #[cargo_test] fn cargo_clean_simple() { @@ -87,6 +90,41 @@ } #[cargo_test] +fn clean_multiple_packages_in_glob_char_path() { + let p = project_in("[d1]") + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + .build(); + let foo_path = &p.build_dir().join("debug").join("deps"); + + // Assert that build artifacts are produced + p.cargo("build").run(); + assert_ne!(get_build_artifacts(foo_path).len(), 0); + + // Assert that build artifacts are destroyed + p.cargo("clean -p foo").run(); + assert_eq!(get_build_artifacts(foo_path).len(), 0); +} + +fn get_build_artifacts(path: &PathBuf) -> Vec> { + let pattern = path.to_str().expect("expected utf-8 path"); + let pattern = glob::Pattern::escape(pattern); + + #[cfg(not(target_env = "msvc"))] + const FILE: &str = "foo-*"; + + #[cfg(target_env = "msvc")] + const FILE: &str = "foo.pdb"; + + let path = PathBuf::from(pattern).join(FILE); + let path = path.to_str().expect("expected utf-8 path"); + glob::glob(path) + .expect("expected glob to run") + .into_iter() + .collect::>>() +} + +#[cargo_test] fn clean_release() { let p = project() .file( @@ -378,7 +416,7 @@ "#, ) .file("src/lib.rs", "") - .file("src/main.rs", "fn main() {}") + .file("src/lib/some-main.rs", "fn main() {}") .file("src/bin/other-main.rs", "fn main() {}") .file("examples/foo-ex-rlib.rs", "") .file("examples/foo-ex-cdylib.rs", "") diff -Nru cargo-0.58.0/tests/testsuite/config_cli.rs cargo-0.60.0ubuntu1/tests/testsuite/config_cli.rs --- cargo-0.58.0/tests/testsuite/config_cli.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/config_cli.rs 2022-02-10 02:58:21.000000000 +0000 @@ -39,12 +39,14 @@ jobs = 3 rustc = 'file' [term] + quiet = false verbose = false ", ); let config = ConfigBuilder::new().build(); assert_eq!(config.get::("build.jobs").unwrap(), 3); assert_eq!(config.get::("build.rustc").unwrap(), "file"); + assert_eq!(config.get::("term.quiet").unwrap(), false); assert_eq!(config.get::("term.verbose").unwrap(), false); let config = ConfigBuilder::new() @@ -58,6 +60,14 @@ assert_eq!(config.get::("build.jobs").unwrap(), 1); assert_eq!(config.get::("build.rustc").unwrap(), "cli"); assert_eq!(config.get::("term.verbose").unwrap(), true); + + // Setting both term.verbose and term.quiet is invalid and is tested + // in the run test suite. + let config = ConfigBuilder::new() + .env("CARGO_TERM_QUIET", "false") + .config_arg("term.quiet=true") + .build(); + assert_eq!(config.get::("term.quiet").unwrap(), true); } #[cargo_test] diff -Nru cargo-0.58.0/tests/testsuite/config.rs cargo-0.60.0ubuntu1/tests/testsuite/config.rs --- cargo-0.58.0/tests/testsuite/config.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/config.rs 2022-02-10 02:58:21.000000000 +0000 @@ -1491,7 +1491,7 @@ let profile = toml::TomlProfile { build_override: Some(Box::new(base_settings.clone())), package: Some(overrides), - ..base_settings.clone() + ..base_settings }; let profile_toml = ::toml::to_string(&profile).unwrap(); let roundtrip: toml::TomlProfile = ::toml::from_str(&profile_toml).unwrap(); diff -Nru cargo-0.58.0/tests/testsuite/credential_process.rs cargo-0.60.0ubuntu1/tests/testsuite/credential_process.rs --- cargo-0.58.0/tests/testsuite/credential_process.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/credential_process.rs 2022-02-10 02:58:21.000000000 +0000 @@ -403,13 +403,16 @@ .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( + // FIXME: Update "Caused by" error message once rust/pull/87704 is merged. + // On Windows, changing to a custom executable resolver has changed the + // error messages. &format!("\ [UPDATING] [..] [ERROR] failed to execute `[..]libexec/cargo-credential-doesnotexist[EXE]` to store authentication token for registry `crates-io` Caused by: - {} -", cargo_test_support::no_such_file_err_msg()), + [..] +"), ) .run(); } diff -Nru cargo-0.58.0/tests/testsuite/cross_compile.rs cargo-0.60.0ubuntu1/tests/testsuite/cross_compile.rs --- cargo-0.58.0/tests/testsuite/cross_compile.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/cross_compile.rs 2022-02-10 02:58:21.000000000 +0000 @@ -617,6 +617,10 @@ [COMPILING] foo v0.0.1 ([CWD]) [RUNNING] `rustc --crate-name foo [..] [FINISHED] test [unoptimized + debuginfo] target(s) in [..] +[NOTE] skipping doctests for foo v0.0.1 ([ROOT]/foo) (lib), \ +cross-compilation doctests are not yet supported +See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile \ +for more information. ", ) .run(); @@ -634,6 +638,10 @@ [RUNNING] `rustc --crate-name foo [..]--test[..] [FINISHED] test [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[CWD]/target/{triple}/debug/deps/foo-[..][EXE]` +[NOTE] skipping doctests for foo v0.0.1 ([ROOT]/foo) (lib), \ +cross-compilation doctests are not yet supported +See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile \ +for more information. ", triple = target )) diff -Nru cargo-0.58.0/tests/testsuite/doc.rs cargo-0.60.0ubuntu1/tests/testsuite/doc.rs --- cargo-0.58.0/tests/testsuite/doc.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/doc.rs 2022-02-10 02:58:21.000000000 +0000 @@ -464,8 +464,17 @@ .build(); p.cargo("doc --bin foo") - .with_stderr( + // The checking/documenting lines are sometimes swapped since they run + // concurrently. + .with_stderr_unordered( "\ +warning: output filename collision. +The bin target `foo` in package `foo v0.0.1 ([ROOT]/foo)` \ +has the same output filename as the lib target `foo` in package `foo v0.0.1 ([ROOT]/foo)`. +Colliding filename is: [ROOT]/foo/target/doc/foo/index.html +The targets should have unique names. +This is a known bug where multiple crates with the same name use +the same path; see . [CHECKING] foo v0.0.1 ([CWD]) [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -500,8 +509,17 @@ .build(); p.cargo("doc --bins") - .with_stderr( + // The checking/documenting lines are sometimes swapped since they run + // concurrently. + .with_stderr_unordered( "\ +warning: output filename collision. +The bin target `foo` in package `foo v0.0.1 ([ROOT]/foo)` \ +has the same output filename as the lib target `foo` in package `foo v0.0.1 ([ROOT]/foo)`. +Colliding filename is: [ROOT]/foo/target/doc/foo/index.html +The targets should have unique names. +This is a known bug where multiple crates with the same name use +the same path; see . [CHECKING] foo v0.0.1 ([CWD]) [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -543,7 +561,9 @@ .build(); p.cargo("doc --example ex1") - .with_stderr( + // The checking/documenting lines are sometimes swapped since they run + // concurrently. + .with_stderr_unordered( "\ [CHECKING] foo v0.0.1 ([CWD]) [DOCUMENTING] foo v0.0.1 ([CWD]) @@ -594,7 +614,9 @@ .build(); p.cargo("doc --examples") - .with_stderr( + // The checking/documenting lines are sometimes swapped since they run + // concurrently. + .with_stderr_unordered( "\ [CHECKING] foo v0.0.1 ([CWD]) [DOCUMENTING] foo v0.0.1 ([CWD]) @@ -803,7 +825,7 @@ "a/src/lib.rs", " /// ``` - /// ☃ + /// ` /// ``` pub fn foo() {} ", @@ -811,9 +833,7 @@ .build(); p.cargo("doc") - .without_status() - .with_stderr_contains("[..]☃") - .with_stderr_contains(r"[..]unknown start of token: \u{2603}") + .with_stderr_contains("[..]unknown start of token: `") .run(); } @@ -1244,8 +1264,24 @@ Package::new("bar", "0.1.0").publish(); p.cargo("doc --workspace") - .with_stderr_contains("[..] Updating `[..]` index") - .with_stderr_contains("[..] Documenting bar v0.1.0 ([..])") + .with_stderr_unordered( + "\ +[UPDATING] [..] +[DOWNLOADING] crates ... +[DOWNLOADED] bar v0.1.0 (registry `dummy-registry`) +warning: output filename collision. +The lib target `bar` in package `bar v0.1.0` has the same output filename as \ +the lib target `bar` in package `bar v0.1.0 ([ROOT]/foo/bar)`. +Colliding filename is: [ROOT]/foo/target/doc/bar/index.html +The targets should have unique names. +This is a known bug where multiple crates with the same name use +the same path; see . +[DOCUMENTING] bar v0.1.0 +[CHECKING] bar v0.1.0 +[DOCUMENTING] bar v0.1.0 [..] +[FINISHED] [..] +", + ) .run(); } @@ -1309,6 +1345,31 @@ } #[cargo_test] +fn open_no_doc_crate() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + + [lib] + doc = false + "#, + ) + .file("src/lib.rs", "#[cfg(feature)] pub fn f();") + .build(); + + p.cargo("doc --open") + .env("BROWSER", "do_not_run_me") + .with_status(101) + .with_stderr_contains("error: no crates with documentation") + .run(); +} + +#[cargo_test] fn doc_workspace_open_different_library_and_package_names() { let p = project() .file( @@ -1625,6 +1686,89 @@ } #[cargo_test] +fn doc_json_artifacts() { + // Checks the output of json artifact messages. + let p = project() + .file("src/lib.rs", "") + .file("src/bin/somebin.rs", "fn main() {}") + .build(); + + p.cargo("doc --message-format=json") + .with_json_contains_unordered( + r#" +{ + "reason": "compiler-artifact", + "package_id": "foo 0.0.1 [..]", + "manifest_path": "[ROOT]/foo/Cargo.toml", + "target": + { + "kind": ["lib"], + "crate_types": ["lib"], + "name": "foo", + "src_path": "[ROOT]/foo/src/lib.rs", + "edition": "2015", + "doc": true, + "doctest": true, + "test": true + }, + "profile": "{...}", + "features": [], + "filenames": ["[ROOT]/foo/target/debug/deps/libfoo-[..].rmeta"], + "executable": null, + "fresh": false +} + +{ + "reason": "compiler-artifact", + "package_id": "foo 0.0.1 [..]", + "manifest_path": "[ROOT]/foo/Cargo.toml", + "target": + { + "kind": ["lib"], + "crate_types": ["lib"], + "name": "foo", + "src_path": "[ROOT]/foo/src/lib.rs", + "edition": "2015", + "doc": true, + "doctest": true, + "test": true + }, + "profile": "{...}", + "features": [], + "filenames": ["[ROOT]/foo/target/doc/foo/index.html"], + "executable": null, + "fresh": false +} + +{ + "reason": "compiler-artifact", + "package_id": "foo 0.0.1 [..]", + "manifest_path": "[ROOT]/foo/Cargo.toml", + "target": + { + "kind": ["bin"], + "crate_types": ["bin"], + "name": "somebin", + "src_path": "[ROOT]/foo/src/bin/somebin.rs", + "edition": "2015", + "doc": true, + "doctest": false, + "test": true + }, + "profile": "{...}", + "features": [], + "filenames": ["[ROOT]/foo/target/doc/somebin/index.html"], + "executable": null, + "fresh": false +} + +{"reason":"build-finished","success":true} +"#, + ) + .run(); +} + +#[cargo_test] fn short_message_format() { let p = project().file("src/lib.rs", BAD_INTRA_LINK_LIB).build(); p.cargo("doc --message-format=short") @@ -2148,3 +2292,344 @@ assert!(build_doc.join("somefile").exists()); assert!(real_doc.join("somefile").exists()); } + +#[cargo_test] +fn scrape_examples_basic() { + if !is_nightly() { + // -Z rustdoc-scrape-examples is unstable + return; + } + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + "#, + ) + .file("examples/ex.rs", "fn main() { foo::foo(); }") + .file("src/lib.rs", "pub fn foo() {}\npub fn bar() { foo(); }") + .build(); + + p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples=all") + .masquerade_as_nightly_cargo() + .with_stderr( + "\ +[..] foo v0.0.1 ([CWD]) +[..] foo v0.0.1 ([CWD]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); + + let doc_html = p.read_file("target/doc/foo/fn.foo.html"); + assert!(doc_html.contains("Examples found in repository")); + assert!(doc_html.contains("More examples")); + + // Ensure that the reverse-dependency has its sources generated + assert!(p.build_dir().join("doc/src/ex/ex.rs.html").exists()); +} + +#[cargo_test] +fn scrape_examples_avoid_build_script_cycle() { + if !is_nightly() { + // -Z rustdoc-scrape-examples is unstable + return; + } + + let p = project() + // package with build dependency + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + links = "foo" + + [workspace] + members = ["bar"] + + [build-dependencies] + bar = {path = "bar"} + "#, + ) + .file("src/lib.rs", "") + .file("build.rs", "fn main(){}") + // dependency + .file( + "bar/Cargo.toml", + r#" + [package] + name = "bar" + version = "0.0.1" + authors = [] + links = "bar" + "#, + ) + .file("bar/src/lib.rs", "") + .file("bar/build.rs", "fn main(){}") + .build(); + + p.cargo("doc --all -Zunstable-options -Z rustdoc-scrape-examples=all") + .masquerade_as_nightly_cargo() + .run(); +} + +#[cargo_test] +fn scrape_examples_complex_reverse_dependencies() { + if !is_nightly() { + // -Z rustdoc-scrape-examples is unstable + return; + } + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dev-dependencies] + a = {path = "a", features = ["feature"]} + b = {path = "b"} + + [workspace] + members = ["b"] + "#, + ) + .file("src/lib.rs", "") + .file("examples/ex.rs", "fn main() { a::f(); }") + .file( + "a/Cargo.toml", + r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + + [lib] + proc-macro = true + + [dependencies] + b = {path = "../b"} + + [features] + feature = [] + "#, + ) + .file("a/src/lib.rs", "#[cfg(feature)] pub fn f();") + .file( + "b/Cargo.toml", + r#" + [package] + name = "b" + version = "0.0.1" + authors = [] + "#, + ) + .file("b/src/lib.rs", "") + .build(); + + p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples=all") + .masquerade_as_nightly_cargo() + .run(); +} + +#[cargo_test] +fn scrape_examples_crate_with_dash() { + if !is_nightly() { + // -Z rustdoc-scrape-examples is unstable + return; + } + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "da-sh" + version = "0.0.1" + authors = [] + "#, + ) + .file("src/lib.rs", "pub fn foo() {}") + .file("examples/a.rs", "fn main() { da_sh::foo(); }") + .build(); + + p.cargo("doc -Zunstable-options -Z rustdoc-scrape-examples=all") + .masquerade_as_nightly_cargo() + .run(); + + let doc_html = p.read_file("target/doc/da_sh/fn.foo.html"); + assert!(doc_html.contains("Examples found in repository")); +} + +#[cargo_test] +fn scrape_examples_missing_flag() { + if !is_nightly() { + return; + } + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "1.2.4" + authors = [] + "#, + ) + .file("src/lib.rs", "//! These are the docs!") + .build(); + p.cargo("doc -Zrustdoc-scrape-examples") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr("error: -Z rustdoc-scrape-examples must take [..] an argument") + .run(); +} + +#[cargo_test] +fn lib_before_bin() { + // Checks that the library is documented before the binary. + // Previously they were built concurrently, which can cause issues + // if the bin has intra-doc links to the lib. + let p = project() + .file( + "src/lib.rs", + r#" + /// Hi + pub fn abc() {} + "#, + ) + .file( + "src/bin/somebin.rs", + r#" + //! See [`foo::abc`] + fn main() {} + "#, + ) + .build(); + + // Run check first. This just helps ensure that the test clearly shows the + // order of the rustdoc commands. + p.cargo("check").run(); + + // The order of output here should be deterministic. + p.cargo("doc -v") + .with_stderr( + "\ +[DOCUMENTING] foo [..] +[RUNNING] `rustdoc --crate-type lib --crate-name foo src/lib.rs [..] +[RUNNING] `rustdoc --crate-type bin --crate-name somebin src/bin/somebin.rs [..] +[FINISHED] [..] +", + ) + .run(); + + // And the link should exist. + let bin_html = p.read_file("target/doc/somebin/index.html"); + assert!(bin_html.contains("../foo/fn.abc.html")); +} + +#[cargo_test] +fn doc_lib_false() { + // doc = false for a library + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [lib] + doc = false + + [dependencies] + bar = {path = "bar"} + "#, + ) + .file("src/lib.rs", "extern crate bar;") + .file("src/bin/some-bin.rs", "fn main() {}") + .file( + "bar/Cargo.toml", + r#" + [package] + name = "bar" + version = "0.1.0" + + [lib] + doc = false + "#, + ) + .file("bar/src/lib.rs", "") + .build(); + + p.cargo("doc") + .with_stderr( + "\ +[CHECKING] bar v0.1.0 [..] +[CHECKING] foo v0.1.0 [..] +[DOCUMENTING] foo v0.1.0 [..] +[FINISHED] [..] +", + ) + .run(); + + assert!(!p.build_dir().join("doc/foo").exists()); + assert!(!p.build_dir().join("doc/bar").exists()); + assert!(p.build_dir().join("doc/some_bin").exists()); +} + +#[cargo_test] +fn doc_lib_false_dep() { + // doc = false for a dependency + // Ensures that the rmeta gets produced + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + bar = { path = "bar" } + "#, + ) + .file("src/lib.rs", "extern crate bar;") + .file( + "bar/Cargo.toml", + r#" + [package] + name = "bar" + version = "0.1.0" + + [lib] + doc = false + "#, + ) + .file("bar/src/lib.rs", "") + .build(); + + p.cargo("doc") + .with_stderr( + "\ +[CHECKING] bar v0.1.0 [..] +[DOCUMENTING] foo v0.1.0 [..] +[FINISHED] [..] +", + ) + .run(); + + assert!(p.build_dir().join("doc/foo").exists()); + assert!(!p.build_dir().join("doc/bar").exists()); +} diff -Nru cargo-0.58.0/tests/testsuite/features_namespaced.rs cargo-0.60.0ubuntu1/tests/testsuite/features_namespaced.rs --- cargo-0.58.0/tests/testsuite/features_namespaced.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/features_namespaced.rs 2022-02-10 02:58:21.000000000 +0000 @@ -715,6 +715,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "edition": "2015", "links": null } diff -Nru cargo-0.58.0/tests/testsuite/fix.rs cargo-0.60.0ubuntu1/tests/testsuite/fix.rs --- cargo-0.58.0/tests/testsuite/fix.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/fix.rs 2022-02-10 02:58:21.000000000 +0000 @@ -950,10 +950,6 @@ #[cargo_test] fn prepare_for_already_on_latest_stable() { // Stable counterpart of prepare_for_already_on_latest_unstable. - if !is_nightly() { - // Remove once 1.56 is stabilized. - return; - } if Edition::LATEST_UNSTABLE.is_some() { eprintln!("This test cannot run while the latest edition is unstable, skipping."); return; @@ -1528,10 +1524,6 @@ #[cargo_test] fn fix_edition_2021() { // Can migrate 2021, even when lints are allowed. - if !is_nightly() { - // Remove once 1.56 is stabilized. - return; - } let p = project() .file( "Cargo.toml", @@ -1748,10 +1740,6 @@ #[cargo_test] fn non_edition_lint_migration() { // Migrating to a new edition where a non-edition lint causes problems. - if !is_nightly() { - // Remove once force-warn hits stable. - return; - } let p = project() .file("Cargo.toml", &basic_manifest("foo", "0.1.0")) .file( diff -Nru cargo-0.58.0/tests/testsuite/future_incompat_report.rs cargo-0.60.0ubuntu1/tests/testsuite/future_incompat_report.rs --- cargo-0.58.0/tests/testsuite/future_incompat_report.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/future_incompat_report.rs 2022-02-10 02:58:21.000000000 +0000 @@ -25,7 +25,7 @@ } #[cargo_test] -fn no_output_on_stable() { +fn output_on_stable() { if !is_nightly() { // -Zfuture-incompat-test requires nightly (permanently) return; @@ -33,39 +33,23 @@ let p = simple_project(); p.cargo("check") - // Even though rustc emits the report, cargo ignores it without -Z. .env("RUSTFLAGS", "-Zfuture-incompat-test") .with_stderr_contains(FUTURE_OUTPUT) - .with_stderr_does_not_contain("[..]cargo report[..]") + .with_stderr_contains("[..]cargo report[..]") .run(); } +// This feature is stable, and should not be gated #[cargo_test] -fn gate_future_incompat_report() { +fn no_gate_future_incompat_report() { let p = simple_project(); p.cargo("build --future-incompat-report") - .with_stderr_contains("error: the `--future-incompat-report` flag is unstable[..]") - .with_status(101) - .run(); - - // Both `-Z future-incompat-report` and `-Z unstable-opts` are required - p.cargo("build --future-incompat-report -Z future-incompat-report") - .masquerade_as_nightly_cargo() - .with_stderr_contains("error: the `--future-incompat-report` flag is unstable[..]") - .with_status(101) - .run(); - - p.cargo("build --future-incompat-report -Z unstable-options") - .masquerade_as_nightly_cargo() - .with_stderr_contains( - "error: Usage of `--future-incompat-report` requires `-Z future-incompat-report`", - ) - .with_status(101) + .with_status(0) .run(); p.cargo("report future-incompatibilities --id foo") - .with_stderr_contains("error: `cargo report` can only be used on the nightly channel") + .with_stderr_contains("error: no reports are currently available") .with_status(101) .run(); } @@ -83,8 +67,7 @@ .build(); // No note if --future-incompat-report is not specified. - p.cargo("build -Z future-incompat-report") - .masquerade_as_nightly_cargo() + p.cargo("build") .env("RUSTFLAGS", "-Zfuture-incompat-test") .with_stderr( "\ @@ -94,8 +77,7 @@ ) .run(); - p.cargo("build --future-incompat-report -Z unstable-options -Z future-incompat-report") - .masquerade_as_nightly_cargo() + p.cargo("build --future-incompat-report") .env("RUSTFLAGS", "-Zfuture-incompat-test") .with_stderr( "\ @@ -117,8 +99,7 @@ for command in &["build", "check", "rustc", "test"] { let check_has_future_compat = || { - p.cargo(command).arg("-Zfuture-incompat-report") - .masquerade_as_nightly_cargo() + p.cargo(command) .env("RUSTFLAGS", "-Zfuture-incompat-test") .with_stderr_contains(FUTURE_OUTPUT) .with_stderr_contains("warning: the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 [..]") @@ -147,8 +128,6 @@ ", ); p.cargo(command) - .arg("-Zfuture-incompat-report") - .masquerade_as_nightly_cargo() .env("RUSTFLAGS", "-Zfuture-incompat-test") .with_stderr_contains(FUTURE_OUTPUT) .with_stderr_does_not_contain("[..]rejected[..]") @@ -156,12 +135,11 @@ .run(); // Check that passing `--future-incompat-report` overrides `frequency = 'never'` - p.cargo(command).arg("-Zfuture-incompat-report").arg("-Zunstable-options").arg("--future-incompat-report") - .masquerade_as_nightly_cargo() + p.cargo(command).arg("--future-incompat-report") .env("RUSTFLAGS", "-Zfuture-incompat-test") .with_stderr_contains(FUTURE_OUTPUT) .with_stderr_contains("warning: the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 [..]") - .with_stderr_contains("The package `foo v0.0.0 ([..])` currently triggers the following future incompatibility lints:") + .with_stderr_contains(" - foo:0.0.0[..]") .run(); } } @@ -197,29 +175,41 @@ .build(); for command in &["build", "check", "rustc", "test"] { - p.cargo(command).arg("-Zfuture-incompat-report") - .masquerade_as_nightly_cargo() + p.cargo(command) .env("RUSTFLAGS", "-Zfuture-incompat-test") .with_stderr_does_not_contain(FUTURE_OUTPUT) .with_stderr_contains("warning: the following packages contain code that will be rejected by a future version of Rust: first-dep v0.0.1, second-dep v0.0.2") - // Check that we don't have the 'triggers' message shown at the bottom of this loop + // Check that we don't have the 'triggers' message shown at the bottom of this loop, + // and that we don't explain how to show a per-package report .with_stderr_does_not_contain("[..]triggers[..]") + .with_stderr_does_not_contain("[..]--package[..]") + .with_stderr_does_not_contain("[..]-p[..]") .run(); - p.cargo(command).arg("-Zunstable-options").arg("-Zfuture-incompat-report").arg("--future-incompat-report") - .masquerade_as_nightly_cargo() + p.cargo(command).arg("--future-incompat-report") .env("RUSTFLAGS", "-Zfuture-incompat-test") .with_stderr_contains("warning: the following packages contain code that will be rejected by a future version of Rust: first-dep v0.0.1, second-dep v0.0.2") - .with_stderr_contains("The package `first-dep v0.0.1` currently triggers the following future incompatibility lints:") - .with_stderr_contains("The package `second-dep v0.0.2` currently triggers the following future incompatibility lints:") + .with_stderr_contains(" - first-dep:0.0.1") + .with_stderr_contains(" - second-dep:0.0.2") + .run(); + + p.cargo("report future-incompatibilities").arg("--package").arg("first-dep:0.0.1") + .with_stdout_contains("The package `first-dep v0.0.1` currently triggers the following future incompatibility lints:") + .with_stdout_contains(FUTURE_OUTPUT) + .with_stdout_does_not_contain("[..]second-dep-0.0.2/src[..]") + .run(); + + p.cargo("report future-incompatibilities").arg("--package").arg("second-dep:0.0.2") + .with_stdout_contains("The package `second-dep v0.0.2` currently triggers the following future incompatibility lints:") + .with_stdout_contains(FUTURE_OUTPUT) + .with_stdout_does_not_contain("[..]first-dep-0.0.1/src[..]") .run(); } // Test that passing the correct id via '--id' doesn't generate a warning message let output = p - .cargo("build -Z future-incompat-report") + .cargo("build") .env("RUSTFLAGS", "-Zfuture-incompat-test") - .masquerade_as_nightly_cargo() .exec_with_output() .unwrap(); @@ -239,16 +229,14 @@ // Strip off the trailing '`' included in the output let id: String = id.chars().take_while(|c| *c != '`').collect(); - p.cargo(&format!("report future-incompatibilities -Z future-incompat-report --id {}", id)) - .masquerade_as_nightly_cargo() + p.cargo(&format!("report future-incompatibilities --id {}", id)) .with_stdout_contains("The package `first-dep v0.0.1` currently triggers the following future incompatibility lints:") .with_stdout_contains("The package `second-dep v0.0.2` currently triggers the following future incompatibility lints:") .run(); // Test without --id, and also the full output of the report. let output = p - .cargo("report future-incompat -Z future-incompat-report") - .masquerade_as_nightly_cargo() + .cargo("report future-incompat") .exec_with_output() .unwrap(); let output = std::str::from_utf8(&output.stdout).unwrap(); @@ -263,7 +251,9 @@ "The package `{}` currently triggers the following future incompatibility lints:", expected ), - lines.next().unwrap() + lines.next().unwrap(), + "Bad output:\n{}", + output ); let mut count = 0; while let Some(line) = lines.next() { @@ -286,17 +276,17 @@ let p = simple_project(); - p.cargo("check -Zfuture-incompat-report") + p.cargo("check") .env("RUSTFLAGS", "-Zfuture-incompat-test") .masquerade_as_nightly_cargo() .run(); - p.cargo("report future-incompatibilities -Z future-incompat-report") + p.cargo("report future-incompatibilities") .masquerade_as_nightly_cargo() .with_stdout_does_not_contain("[..]\x1b[[..]") .run(); - p.cargo("report future-incompatibilities -Z future-incompat-report") + p.cargo("report future-incompatibilities") .masquerade_as_nightly_cargo() .env("CARGO_TERM_COLOR", "always") .with_stdout_contains("[..]\x1b[[..]") @@ -312,24 +302,24 @@ let p = simple_project(); - p.cargo("report future-incompatibilities -Z future-incompat-report --id 1") + p.cargo("report future-incompatibilities --id 1") .masquerade_as_nightly_cargo() .with_status(101) .with_stderr("error: no reports are currently available") .run(); - p.cargo("check -Zfuture-incompat-report") + p.cargo("check") .env("RUSTFLAGS", "-Zfuture-incompat-test") .masquerade_as_nightly_cargo() .run(); - p.cargo("report future-incompatibilities -Z future-incompat-report --id foo") + p.cargo("report future-incompatibilities --id foo") .masquerade_as_nightly_cargo() .with_status(1) .with_stderr("error: Invalid value: could not parse `foo` as a number") .run(); - p.cargo("report future-incompatibilities -Z future-incompat-report --id 7") + p.cargo("report future-incompatibilities --id 7") .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( @@ -383,6 +373,9 @@ Package::new("with_updates", "1.0.2") .file("src/lib.rs", "") .publish(); + Package::new("with_updates", "3.0.1") + .file("src/lib.rs", "") + .publish(); Package::new("big_update", "2.0.0") .file("src/lib.rs", "") .publish(); @@ -396,22 +389,22 @@ // in a long while?). p.cargo("update -p without_updates").run(); - p.cargo("check -Zfuture-incompat-report") + let update_message = "\ +- Some affected dependencies have newer versions available. +You may want to consider updating them to a newer version to see if the issue has been fixed. + +big_update v1.0.0 has the following newer versions available: 2.0.0 +with_updates v1.0.0 has the following newer versions available: 1.0.1, 1.0.2, 3.0.1 +"; + + p.cargo("check --future-incompat-report") .masquerade_as_nightly_cargo() .env("RUSTFLAGS", "-Zfuture-incompat-test") - .with_stderr_contains("[..]cargo report future-incompatibilities --id 1[..]") + .with_stderr_contains(update_message) .run(); p.cargo("report future-incompatibilities") .masquerade_as_nightly_cargo() - .with_stdout_contains( - "\ -The following packages appear to have newer versions available. -You may want to consider updating them to a newer version to see if the issue has been fixed. - -big_update v1.0.0 has the following newer versions available: 2.0.0 -with_updates v1.0.0 has the following newer versions available: 1.0.1, 1.0.2 -", - ) - .run(); + .with_stdout_contains(update_message) + .run() } diff -Nru cargo-0.58.0/tests/testsuite/git.rs cargo-0.60.0ubuntu1/tests/testsuite/git.rs --- cargo-0.58.0/tests/testsuite/git.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/git.rs 2022-02-10 02:58:21.000000000 +0000 @@ -3147,6 +3147,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -3185,6 +3186,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", diff -Nru cargo-0.58.0/tests/testsuite/help.rs cargo-0.60.0ubuntu1/tests/testsuite/help.rs --- cargo-0.58.0/tests/testsuite/help.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/help.rs 2022-02-10 02:58:21.000000000 +0000 @@ -110,6 +110,20 @@ assert_eq!(stdout, contents); } +fn help_with_stdout_and_path(subcommand: &str, path: &Path) -> String { + let output = process(&cargo_exe()) + .arg("help") + .arg(subcommand) + .env("PATH", path) + .exec_with_output() + .unwrap(); + assert!(output.status.success()); + let stderr = from_utf8(&output.stderr).unwrap(); + assert_eq!(stderr, ""); + let stdout = from_utf8(&output.stdout).unwrap(); + stdout.to_string() +} + #[cargo_test] fn help_man() { // Checks that `help command` displays the man page using the given command. @@ -132,11 +146,25 @@ config, r#" [alias] - my-alias = ["build", "--release"] + empty-alias = "" + simple-alias = "build" + complex-alias = ["build", "--release"] "#, ) .unwrap(); - help_with_man_and_path("", "my-alias", "build", Path::new("")); + + // The `empty-alias` returns an error. + cargo_process("help empty-alias") + .env("PATH", Path::new("")) + .with_stderr_contains("[..]The subcommand 'empty-alias' wasn't recognized[..]") + .run_expect_error(); + + // Because `simple-alias` aliases a subcommand with no arguments, help shows the manpage. + help_with_man_and_path("", "simple-alias", "build", Path::new("")); + + // Help for `complex-alias` displays the full alias command. + let out = help_with_stdout_and_path("complex-alias", Path::new("")); + assert_eq!(out, "`complex-alias` is aliased to `build --release`\n"); } #[cargo_test] diff -Nru cargo-0.58.0/tests/testsuite/install.rs cargo-0.60.0ubuntu1/tests/testsuite/install.rs --- cargo-0.58.0/tests/testsuite/install.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/install.rs 2022-02-10 02:58:21.000000000 +0000 @@ -55,6 +55,83 @@ } #[cargo_test] +fn simple_with_message_format() { + pkg("foo", "0.0.1"); + + cargo_process("install foo --message-format=json") + .with_stderr( + "\ +[UPDATING] `[..]` index +[DOWNLOADING] crates ... +[DOWNLOADED] foo v0.0.1 (registry [..]) +[INSTALLING] foo v0.0.1 +[COMPILING] foo v0.0.1 +[FINISHED] release [optimized] target(s) in [..] +[INSTALLING] [CWD]/home/.cargo/bin/foo[EXE] +[INSTALLED] package `foo v0.0.1` (executable `foo[EXE]`) +[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries +", + ) + .with_json( + r#" + { + "reason": "compiler-artifact", + "package_id": "foo 0.0.1 ([..])", + "manifest_path": "[..]", + "target": { + "kind": [ + "lib" + ], + "crate_types": [ + "lib" + ], + "name": "foo", + "src_path": "[..]/foo-0.0.1/src/lib.rs", + "edition": "2015", + "doc": true, + "doctest": true, + "test": true + }, + "profile": "{...}", + "features": [], + "filenames": "{...}", + "executable": null, + "fresh": false + } + + { + "reason": "compiler-artifact", + "package_id": "foo 0.0.1 ([..])", + "manifest_path": "[..]", + "target": { + "kind": [ + "bin" + ], + "crate_types": [ + "bin" + ], + "name": "foo", + "src_path": "[..]/foo-0.0.1/src/main.rs", + "edition": "2015", + "doc": true, + "doctest": false, + "test": true + }, + "profile": "{...}", + "features": [], + "filenames": "{...}", + "executable": "[..]", + "fresh": false + } + + {"reason":"build-finished","success":true} + "#, + ) + .run(); + assert_has_installed_exe(cargo_home(), "foo"); +} + +#[cargo_test] fn with_index() { pkg("foo", "0.0.1"); diff -Nru cargo-0.58.0/tests/testsuite/login.rs cargo-0.60.0ubuntu1/tests/testsuite/login.rs --- cargo-0.58.0/tests/testsuite/login.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/login.rs 2022-02-10 02:58:21.000000000 +0000 @@ -1,9 +1,7 @@ //! Tests for the `cargo login` command. -use cargo::core::Shell; -use cargo::util::config::Config; use cargo_test_support::install::cargo_home; -use cargo_test_support::registry::{self, registry_url}; +use cargo_test_support::registry; use cargo_test_support::{cargo_process, paths, t}; use std::fs::{self, OpenOptions}; use std::io::prelude::*; @@ -18,11 +16,6 @@ setup_new_credentials_at(config); } -fn setup_new_credentials_toml() { - let config = cargo_home().join("credentials.toml"); - setup_new_credentials_at(config); -} - fn setup_new_credentials_at(config: PathBuf) { t!(fs::create_dir_all(config.parent().unwrap())); t!(fs::write( @@ -67,83 +60,6 @@ } #[cargo_test] -fn login_with_old_credentials() { - registry::init(); - - cargo_process("login --host") - .arg(registry_url().to_string()) - .arg(TOKEN) - .run(); - - // Ensure that we get the new token for the registry - assert!(check_token(TOKEN, None)); -} - -#[cargo_test] -fn login_with_new_credentials() { - registry::init(); - setup_new_credentials(); - - cargo_process("login --host") - .arg(registry_url().to_string()) - .arg(TOKEN) - .run(); - - // Ensure that we get the new token for the registry - assert!(check_token(TOKEN, None)); -} - -#[cargo_test] -fn credentials_work_with_extension() { - registry::init(); - setup_new_credentials_toml(); - - cargo_process("login --host") - .arg(registry_url().to_string()) - .arg(TOKEN) - .run(); - - // Ensure that we get the new token for the registry - assert!(check_token(TOKEN, None)); -} - -#[cargo_test] -fn login_with_old_and_new_credentials() { - setup_new_credentials(); - login_with_old_credentials(); -} - -#[cargo_test] -fn login_without_credentials() { - registry::init(); - cargo_process("login --host") - .arg(registry_url().to_string()) - .arg(TOKEN) - .run(); - - // Ensure that we get the new token for the registry - assert!(check_token(TOKEN, None)); -} - -#[cargo_test] -fn new_credentials_is_used_instead_old() { - registry::init(); - setup_new_credentials(); - - cargo_process("login --host") - .arg(registry_url().to_string()) - .arg(TOKEN) - .run(); - - let mut config = Config::new(Shell::new(), cargo_home(), cargo_home()); - let _ = config.values(); - let _ = config.load_credentials(); - - let token = config.get_string("registry.token").unwrap().map(|p| p.val); - assert_eq!(token.unwrap(), TOKEN); -} - -#[cargo_test] fn registry_credentials() { registry::alt_init(); diff -Nru cargo-0.58.0/tests/testsuite/lto.rs cargo-0.60.0ubuntu1/tests/testsuite/lto.rs --- cargo-0.58.0/tests/testsuite/lto.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/lto.rs 2022-02-10 02:58:21.000000000 +0000 @@ -177,7 +177,7 @@ ) .file("build.rs", "fn main() { dep_build::foo() }") .file( - "src/main.rs", + "src/bin/foo-bin.rs", "#[dep_proc_macro::foo] fn main() { dep_normal::foo() }", ) .file( @@ -206,7 +206,9 @@ .with_stderr_contains( "[..]`rustc[..]--crate-name dep_proc_macro [..]-C embed-bitcode=no[..]`", ) - .with_stderr_contains("[..]`rustc[..]--crate-name test [..]--crate-type bin[..]-C lto[..]`") + .with_stderr_contains( + "[..]`rustc[..]--crate-name foo_bin [..]--crate-type bin[..]-C lto[..]`", + ) .with_stderr_contains( "[..]`rustc[..]--crate-name test [..]--crate-type cdylib[..]-C lto[..]`", ) @@ -753,7 +755,7 @@ "#, ) .file("src/lib.rs", "pub fn foo() { println!(\"hi!\"); }") - .file("src/main.rs", "fn main() { foo::foo(); }") + .file("src/bin/ferret.rs", "fn main() { foo::foo(); }") .build(); let output = p.cargo("build --release -v").exec_with_output().unwrap(); @@ -763,7 +765,7 @@ "--crate-type dylib --crate-type rlib", Lto::ObjectAndBitcode, ); - verify_lto(&output, "foo", "--crate-type bin", Lto::Run(None)); + verify_lto(&output, "ferret", "--crate-type bin", Lto::Run(None)); } #[cargo_test] diff -Nru cargo-0.58.0/tests/testsuite/metadata.rs cargo-0.60.0ubuntu1/tests/testsuite/metadata.rs --- cargo-0.58.0/tests/testsuite/metadata.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/metadata.rs 2022-02-10 02:58:21.000000000 +0000 @@ -37,6 +37,7 @@ "description": null, "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "homepage": null, @@ -128,6 +129,7 @@ "homepage": null, "documentation": null, "version": "0.5.0", + "rust_version": null, "id": "foo[..]", "keywords": [], "source": null, @@ -213,6 +215,7 @@ "name": "foo", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "version": "0.5.0", @@ -342,6 +345,7 @@ "name": "bar", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": "registry+https://github.com/rust-lang/crates.io-index", @@ -382,6 +386,7 @@ "name": "baz", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": "registry+https://github.com/rust-lang/crates.io-index", @@ -447,6 +452,7 @@ "name": "foo", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": null, @@ -487,6 +493,7 @@ "name": "foobar", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": "registry+https://github.com/rust-lang/crates.io-index", @@ -617,6 +624,7 @@ "name": "foo", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "version": "0.1.0", @@ -711,6 +719,7 @@ "name": "foo", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "version": "0.1.0", @@ -814,6 +823,7 @@ "id": "bar[..]", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "keywords": [], @@ -850,6 +860,7 @@ "name": "baz", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "version": "0.5.0", @@ -943,6 +954,7 @@ "name": "bar", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "version": "0.5.0", @@ -981,6 +993,7 @@ "name": "baz", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "version": "0.5.0", @@ -1073,6 +1086,7 @@ "publish": null, "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null }], @@ -1235,6 +1249,7 @@ "name": "foo", "readme": "README.md", "repository": "https://github.com/rust-lang/cargo", + "rust_version": null, "homepage": "https://rust-lang.org", "documentation": "https://doc.rust-lang.org/stable/std/", "version": "0.1.0", @@ -1313,6 +1328,7 @@ "name": "foo", "readme": "README.md", "repository": "https://github.com/rust-lang/cargo", + "rust_version": null, "homepage": null, "documentation": null, "version": "0.1.0", @@ -1400,6 +1416,7 @@ "name": "bar", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": null, @@ -1487,6 +1504,7 @@ "name": "foo", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": null, @@ -1556,6 +1574,26 @@ } #[cargo_test] +fn package_rust_version() { + let p = project() + .file("src/lib.rs", "") + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + authors = ["wycats@example.com"] + edition = "2018" + rust-version = "1.56" + "#, + ) + .build(); + let json = p.cargo("metadata").run_json(); + assert_eq!(json["packages"][0]["rust_version"], json!("1.56")); +} + +#[cargo_test] fn target_edition_2018() { let p = project() .file("src/lib.rs", "") @@ -1600,6 +1638,7 @@ "name": "foo", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": null, @@ -1706,6 +1745,7 @@ "name": "bar", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": "registry+https://github.com/rust-lang/crates.io-index", @@ -1746,6 +1786,7 @@ "name": "bar", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": "registry+https://github.com/rust-lang/crates.io-index", @@ -1811,6 +1852,7 @@ "name": "foo", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": null, @@ -1932,6 +1974,7 @@ "name": "foo", "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "source": null, @@ -2064,6 +2107,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -2168,6 +2212,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -2211,6 +2256,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -2254,6 +2300,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -2297,6 +2344,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", @@ -2403,6 +2451,7 @@ "keywords": [], "readme": null, "repository": null, + "rust_version": null, "homepage": null, "documentation": null, "edition": "2015", diff -Nru cargo-0.58.0/tests/testsuite/new.rs cargo-0.60.0ubuntu1/tests/testsuite/new.rs --- cargo-0.58.0/tests/testsuite/new.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/new.rs 2022-02-10 02:58:21.000000000 +0000 @@ -377,10 +377,6 @@ #[cargo_test] fn lockfile_constant_during_new() { - if !cargo_test_support::is_nightly() { - // Remove when 1.56 is stable (cargo new defaults to 2021). - return; - } cargo_process("new foo").run(); cargo_process("build").cwd(&paths::root().join("foo")).run(); diff -Nru cargo-0.58.0/tests/testsuite/package.rs cargo-0.60.0ubuntu1/tests/testsuite/package.rs --- cargo-0.58.0/tests/testsuite/package.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/package.rs 2022-02-10 02:58:21.000000000 +0000 @@ -794,7 +794,7 @@ .with_status(101) .with_stderr_contains( "\ -error: failed to prepare local package for uploading +[ERROR] failed to prepare local package for uploading Caused by: failed to open for archiving: `[..]foo.rs` @@ -827,6 +827,27 @@ } #[cargo_test] +/// Tests if a symlink to ancestor causes filesystem loop error. +/// +/// This test requires you to be able to make symlinks. +/// For windows, this may require you to enable developer mode. +fn filesystem_loop() { + if !symlink_supported() { + return; + } + + project() + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) + .symlink_dir("a/b", "a/b/c/d/foo") + .build() + .cargo("package -v") + .with_stderr_contains( + "[WARNING] File system loop found: [..]/a/b/c/d/foo points to an ancestor [..]/a/b", + ) + .run(); +} + +#[cargo_test] fn do_not_package_if_repository_is_dirty() { let p = project().build(); @@ -1798,7 +1819,8 @@ .build(); p.cargo("package") - .with_stderr( + // use unordered here because the order of the warning is different on each platform. + .with_stderr_unordered( "\ [WARNING] file src/aux/mod.rs is a reserved Windows filename, it will not work on Windows platforms [WARNING] file src/con.rs is a reserved Windows filename, it will not work on Windows platforms diff -Nru cargo-0.58.0/tests/testsuite/patch.rs cargo-0.60.0ubuntu1/tests/testsuite/patch.rs --- cargo-0.58.0/tests/testsuite/patch.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/patch.rs 2022-02-10 02:58:21.000000000 +0000 @@ -358,10 +358,10 @@ "\ [UPDATING] `dummy-registry` index [WARNING] Patch `bar v0.2.0 ([CWD]/bar)` was not used in the crate graph. -[..] -[..] -[..] -[..] +Check that [..] +with the [..] +what is [..] +version. [..] [DOWNLOADING] crates ... [DOWNLOADED] bar v0.1.0 [..] [COMPILING] bar v0.1.0 @@ -374,10 +374,10 @@ .with_stderr( "\ [WARNING] Patch `bar v0.2.0 ([CWD]/bar)` was not used in the crate graph. -[..] -[..] -[..] -[..] +Check that [..] +with the [..] +what is [..] +version. [..] [FINISHED] [..] ", ) @@ -395,6 +395,60 @@ } #[cargo_test] +fn unused_with_mismatch_source_being_patched() { + registry::alt_init(); + Package::new("bar", "0.1.0").publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + bar = "0.1.0" + + [patch.alternative] + bar = { path = "bar" } + + [patch.crates-io] + bar = { path = "baz" } + "#, + ) + .file("src/lib.rs", "") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.2.0")) + .file("bar/src/lib.rs", "not rust code") + .file("baz/Cargo.toml", &basic_manifest("bar", "0.3.0")) + .file("baz/src/lib.rs", "not rust code") + .build(); + + p.cargo("build") + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[WARNING] Patch `bar v0.2.0 ([CWD]/bar)` was not used in the crate graph. +Perhaps you misspell the source URL being patched. +Possible URLs for `[patch.]`: + crates-io +[WARNING] Patch `bar v0.3.0 ([CWD]/baz)` was not used in the crate graph. +Check that [..] +with the [..] +what is [..] +version. [..] +[DOWNLOADING] crates ... +[DOWNLOADED] bar v0.1.0 [..] +[COMPILING] bar v0.1.0 +[COMPILING] foo v0.0.1 ([CWD]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] fn prefer_patch_version() { Package::new("bar", "0.1.2").publish(); @@ -477,10 +531,10 @@ "\ [UPDATING] `dummy-registry` index [WARNING] Patch `bar v0.2.0 ([CWD]/bar)` was not used in the crate graph. -[..] -[..] -[..] -[..] +Check that [..] +with the [..] +what is [..] +version. [..] [DOWNLOADING] crates ... [DOWNLOADED] bar v0.1.0 [..] [COMPILING] bar v0.1.0 @@ -493,10 +547,10 @@ .with_stderr( "\ [WARNING] Patch `bar v0.2.0 ([CWD]/bar)` was not used in the crate graph. -[..] -[..] -[..] -[..] +Check that [..] +with the [..] +what is [..] +version. [..] [FINISHED] [..] ", ) @@ -550,10 +604,10 @@ [UPDATING] git repository `file://[..]` [UPDATING] `dummy-registry` index [WARNING] Patch `bar v0.2.0 ([..])` was not used in the crate graph. -[..] -[..] -[..] -[..] +Check that [..] +with the [..] +what is [..] +version. [..] [DOWNLOADING] crates ... [DOWNLOADED] bar v0.1.0 [..] [COMPILING] bar v0.1.0 @@ -566,10 +620,10 @@ .with_stderr( "\ [WARNING] Patch `bar v0.2.0 ([..])` was not used in the crate graph. -[..] -[..] -[..] -[..] +Check that [..] +with the [..] +what is [..] +version. [..] [FINISHED] [..] ", ) @@ -752,10 +806,10 @@ .with_stderr( "\ [WARNING] Patch `bar v0.1.1 ([CWD]/bar)` was not used in the crate graph. -[..] -[..] -[..] -[..] +Check that [..] +with the [..] +what is [..] +version. [..] [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", ) .run(); @@ -763,10 +817,10 @@ .with_stderr( "\ [WARNING] Patch `bar v0.1.1 ([CWD]/bar)` was not used in the crate graph. -[..] -[..] -[..] -[..] +Check that [..] +with the [..] +what is [..] +version. [..] [FINISHED] [..]", ) .run(); @@ -1714,10 +1768,9 @@ .with_stderr( "\ warning: Patch `bar v0.1.1 [..]` was not used in the crate graph. -Check that [..] -with the [..] -what is [..] -version. [..] +Perhaps you misspell the source URL being patched. +Possible URLs for `[patch.]`: + [CWD]/bar [FINISHED] [..]", ) .run(); @@ -1769,10 +1822,9 @@ .with_stderr( "\ warning: Patch `bar v0.1.0 [..]` was not used in the crate graph. -Check that [..] -with the [..] -what is [..] -version. [..] +Perhaps you misspell the source URL being patched. +Possible URLs for `[patch.]`: + [CWD]/bar [FINISHED] [..]", ) .run(); diff -Nru cargo-0.58.0/tests/testsuite/profiles.rs cargo-0.60.0ubuntu1/tests/testsuite/profiles.rs --- cargo-0.58.0/tests/testsuite/profiles.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/profiles.rs 2022-02-10 02:58:21.000000000 +0000 @@ -472,7 +472,7 @@ #[cargo_test] fn strip_works() { if !is_nightly() { - // -Zstrip is unstable + // rustc 1.58 stabilized -C strip; disable the test until that ships. return; } @@ -480,8 +480,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["strip"] - [package] name = "foo" version = "0.1.0" @@ -494,11 +492,10 @@ .build(); p.cargo("build --release -v") - .masquerade_as_nightly_cargo() .with_stderr( "\ [COMPILING] foo [..] -[RUNNING] `rustc [..] -Z strip=symbols [..]` +[RUNNING] `rustc [..] -C strip=symbols [..]` [FINISHED] [..] ", ) @@ -506,52 +503,9 @@ } #[cargo_test] -fn strip_requires_cargo_feature() { - if !is_nightly() { - // -Zstrip is unstable - return; - } - - let p = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.1.0" - - [profile.release] - strip = 'symbols' - "#, - ) - .file("src/main.rs", "fn main() {}") - .build(); - - p.cargo("build --release -v") - .masquerade_as_nightly_cargo() - .with_status(101) - .with_stderr( - "\ -[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` - -Caused by: - feature `strip` is required - - The package requires the Cargo feature called `strip`, but that feature is \ - not stabilized in this version of Cargo (1.[..]). - Consider adding `cargo-features = [\"strip\"]` 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#profile-strip-option \ - for more information about the status of this feature. -", - ) - .run(); -} - -#[cargo_test] fn strip_passes_unknown_option_to_rustc() { if !is_nightly() { - // -Zstrip is unstable + // rustc 1.58 stabilized -C strip; disable the test until that ships. return; } @@ -559,8 +513,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["strip"] - [package] name = "foo" version = "0.1.0" @@ -573,13 +525,12 @@ .build(); p.cargo("build --release -v") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr_contains( "\ [COMPILING] foo [..] -[RUNNING] `rustc [..] -Z strip=unknown [..]` -error: incorrect value `unknown` for debugging option `strip` - either `none`, `debuginfo`, or `symbols` was expected +[RUNNING] `rustc [..] -C strip=unknown [..]` +error: incorrect value `unknown` for [..] `strip` [..] was expected ", ) .run(); @@ -588,7 +539,7 @@ #[cargo_test] fn strip_accepts_true_to_strip_symbols() { if !is_nightly() { - // -Zstrip is unstable + // rustc 1.58 stabilized -C strip; disable the test until that ships. return; } @@ -596,8 +547,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["strip"] - [package] name = "foo" version = "0.1.0" @@ -610,11 +559,10 @@ .build(); p.cargo("build --release -v") - .masquerade_as_nightly_cargo() .with_stderr( "\ [COMPILING] foo [..] -[RUNNING] `rustc [..] -Z strip=symbols [..]` +[RUNNING] `rustc [..] -C strip=symbols [..]` [FINISHED] [..] ", ) @@ -624,15 +572,14 @@ #[cargo_test] fn strip_accepts_false_to_disable_strip() { if !is_nightly() { - // -Zstrip is unstable + // rustc 1.58 stabilized -C strip; disable the test until that ships. return; } + let p = project() .file( "Cargo.toml", r#" - cargo-features = ["strip"] - [package] name = "foo" version = "0.1.0" @@ -645,7 +592,6 @@ .build(); p.cargo("build --release -v") - .masquerade_as_nightly_cargo() - .with_stderr_does_not_contain("-Z strip") + .with_stderr_does_not_contain("-C strip") .run(); } diff -Nru cargo-0.58.0/tests/testsuite/publish.rs cargo-0.60.0ubuntu1/tests/testsuite/publish.rs --- cargo-0.58.0/tests/testsuite/publish.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/publish.rs 2022-02-10 02:58:21.000000000 +0000 @@ -2,7 +2,7 @@ use cargo_test_support::git::{self, repo}; use cargo_test_support::paths; -use cargo_test_support::registry::{self, registry_path, registry_url, Package}; +use cargo_test_support::registry::{self, registry_url, Package}; use cargo_test_support::{basic_manifest, no_such_file_err_msg, project, publish}; use std::fs; @@ -185,57 +185,8 @@ validate_upload_foo(); } -// TODO: Deprecated -// remove once it has been decided --host can be removed #[cargo_test] -fn simple_with_host() { - registry::init(); - - let p = project() - .file( - "Cargo.toml", - r#" - [project] - name = "foo" - version = "0.0.1" - authors = [] - license = "MIT" - description = "foo" - "#, - ) - .file("src/main.rs", "fn main() {}") - .build(); - - p.cargo("publish --no-verify --token sekrit --host") - .arg(registry_url().to_string()) - .with_stderr(&format!( - "\ -[WARNING] The flag '--host' is no longer valid. - -Previous versions of Cargo accepted this flag, but it is being -deprecated. The flag is being renamed to 'index', as the flag -wants the location of the index. Please use '--index' instead. - -This will soon become a hard error, so it's either recommended -to update to a fixed version or contact the upstream maintainer -about this warning. -[UPDATING] `{reg}` index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[UPLOADING] foo v0.0.1 ([CWD]) -", - reg = registry_path().to_str().unwrap() - )) - .run(); - - validate_upload_foo(); -} - -// TODO: Deprecated -// remove once it has been decided --host can be removed -#[cargo_test] -fn simple_with_index_and_host() { +fn simple_with_index() { registry::init(); let p = project() @@ -255,27 +206,6 @@ p.cargo("publish --no-verify --token sekrit --index") .arg(registry_url().to_string()) - .arg("--host") - .arg(registry_url().to_string()) - .with_stderr(&format!( - "\ -[WARNING] The flag '--host' is no longer valid. - -Previous versions of Cargo accepted this flag, but it is being -deprecated. The flag is being renamed to 'index', as the flag -wants the location of the index. Please use '--index' instead. - -This will soon become a hard error, so it's either recommended -to update to a fixed version or contact the upstream maintainer -about this warning. -[UPDATING] `{reg}` index -[WARNING] manifest has no documentation, [..] -See [..] -[PACKAGING] foo v0.0.1 ([CWD]) -[UPLOADING] foo v0.0.1 ([CWD]) -", - reg = registry_path().to_str().unwrap() - )) .run(); validate_upload_foo(); diff -Nru cargo-0.58.0/tests/testsuite/read_manifest.rs cargo-0.60.0ubuntu1/tests/testsuite/read_manifest.rs --- cargo-0.58.0/tests/testsuite/read_manifest.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/read_manifest.rs 2022-02-10 02:58:21.000000000 +0000 @@ -16,6 +16,7 @@ "homepage": null, "documentation": null, "repository": null, + "rust_version": null, "version":"0.5.0", "id":"foo[..]0.5.0[..](path+file://[..]/foo)", "keywords": [], diff -Nru cargo-0.58.0/tests/testsuite/run.rs cargo-0.60.0ubuntu1/tests/testsuite/run.rs --- cargo-0.58.0/tests/testsuite/run.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/run.rs 2022-02-10 02:58:21.000000000 +0000 @@ -22,18 +22,21 @@ } #[cargo_test] -fn simple_quiet() { +fn quiet_arg() { let p = project() .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); - p.cargo("run -q").with_stdout("hello").run(); + p.cargo("run -q").with_stderr("").with_stdout("hello").run(); - p.cargo("run --quiet").with_stdout("hello").run(); + p.cargo("run --quiet") + .with_stderr("") + .with_stdout("hello") + .run(); } #[cargo_test] -fn simple_quiet_and_verbose() { +fn quiet_arg_and_verbose_arg() { let p = project() .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); @@ -45,7 +48,7 @@ } #[cargo_test] -fn quiet_and_verbose_config() { +fn quiet_arg_and_verbose_config() { let p = project() .file( ".cargo/config", @@ -57,7 +60,52 @@ .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); - p.cargo("run -q").run(); + p.cargo("run -q").with_stderr("").with_stdout("hello").run(); +} + +#[cargo_test] +fn verbose_arg_and_quiet_config() { + let p = project() + .file( + ".cargo/config", + r#" + [term] + quiet = true + "#, + ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) + .build(); + + p.cargo("run -v") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc [..] +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `target/debug/foo[EXE]`", + ) + .with_stdout("hello") + .run(); +} + +#[cargo_test] +fn quiet_config_and_verbose_config() { + let p = project() + .file( + ".cargo/config", + r#" + [term] + verbose = true + quiet = true + "#, + ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) + .build(); + + p.cargo("run") + .with_status(101) + .with_stderr("[ERROR] cannot set both `term.verbose` and `term.quiet`") + .run(); } #[cargo_test] @@ -928,6 +976,29 @@ .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) +[FINISHED] release [optimized] target(s) in [..] +[RUNNING] `target/release/foo[EXE]` +", + ) + .run(); + assert!(p.release_bin("foo").is_file()); +} + +#[cargo_test] +fn release_short_works() { + let p = project() + .file( + "src/main.rs", + r#" + fn main() { if cfg!(debug_assertions) { panic!() } } + "#, + ) + .build(); + + p.cargo("run -r") + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] `target/release/foo[EXE]` ", diff -Nru cargo-0.58.0/tests/testsuite/rustc.rs cargo-0.60.0ubuntu1/tests/testsuite/rustc.rs --- cargo-0.58.0/tests/testsuite/rustc.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/rustc.rs 2022-02-10 02:58:21.000000000 +0000 @@ -135,6 +135,228 @@ } #[cargo_test] +fn fails_with_crate_type_and_without_unstable_options() { + let p = project().file("src/lib.rs", r#" "#).build(); + + p.cargo("rustc --crate-type lib") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "[ERROR] the `crate-type` flag is unstable, pass `-Z unstable-options` to enable it +See https://github.com/rust-lang/cargo/issues/10083 for more information about the `crate-type` flag.", + ) + .run(); +} + +#[cargo_test] +fn fails_with_crate_type_to_multi_binaries() { + let p = project() + .file("src/bin/foo.rs", "fn main() {}") + .file("src/bin/bar.rs", "fn main() {}") + .file("src/bin/baz.rs", "fn main() {}") + .file("src/lib.rs", r#" "#) + .build(); + + p.cargo("rustc --crate-type lib -Zunstable-options") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "[ERROR] crate types to rustc can only be passed to one target, consider filtering +the package by passing, e.g., `--lib` or `--example` to specify a single target", + ) + .run(); +} + +#[cargo_test] +fn fails_with_crate_type_to_multi_examples() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [[example]] + name = "ex1" + crate-type = ["rlib"] + [[example]] + name = "ex2" + crate-type = ["rlib"] + "#, + ) + .file("src/lib.rs", "") + .file("examples/ex1.rs", "") + .file("examples/ex2.rs", "") + .build(); + + p.cargo("rustc -v --example ex1 --example ex2 --crate-type lib,cdylib -Zunstable-options") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "[ERROR] crate types to rustc can only be passed to one target, consider filtering +the package by passing, e.g., `--lib` or `--example` to specify a single target", + ) + .run(); +} + +#[cargo_test] +fn fails_with_crate_type_to_binary() { + let p = project().file("src/bin/foo.rs", "fn main() {}").build(); + + p.cargo("rustc --crate-type lib -Zunstable-options") + .masquerade_as_nightly_cargo() + .with_status(101) + .with_stderr( + "[ERROR] crate types can only be specified for libraries and example libraries. +Binaries, tests, and benchmarks are always the `bin` crate type", + ) + .run(); +} + +#[cargo_test] +fn build_with_crate_type_for_foo() { + let p = project() + .file("src/main.rs", "fn main() {}") + .file("src/lib.rs", r#" "#) + .build(); + + p.cargo("rustc -v --lib --crate-type lib -Zunstable-options") + .masquerade_as_nightly_cargo() + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib [..] +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_with_crate_types_for_foo() { + let p = project() + .file("src/main.rs", "fn main() {}") + .file("src/lib.rs", r#" "#) + .build(); + + p.cargo("rustc -v --lib --crate-type lib,cdylib -Zunstable-options") + .masquerade_as_nightly_cargo() + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib,cdylib [..] +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_with_crate_type_to_example() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [[example]] + name = "ex" + crate-type = ["rlib"] + "#, + ) + .file("src/lib.rs", "") + .file("examples/ex.rs", "") + .build(); + + p.cargo("rustc -v --example ex --crate-type cdylib -Zunstable-options") + .masquerade_as_nightly_cargo() + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib [..] +[RUNNING] `rustc --crate-name ex examples/ex.rs [..]--crate-type cdylib [..] +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_with_crate_types_to_example() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [[example]] + name = "ex" + crate-type = ["rlib"] + "#, + ) + .file("src/lib.rs", "") + .file("examples/ex.rs", "") + .build(); + + p.cargo("rustc -v --example ex --crate-type lib,cdylib -Zunstable-options") + .masquerade_as_nightly_cargo() + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib [..] +[RUNNING] `rustc --crate-name ex examples/ex.rs [..]--crate-type lib,cdylib [..] +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn build_with_crate_types_to_one_of_multi_examples() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [[example]] + name = "ex1" + crate-type = ["rlib"] + [[example]] + name = "ex2" + crate-type = ["rlib"] + "#, + ) + .file("src/lib.rs", "") + .file("examples/ex1.rs", "") + .file("examples/ex2.rs", "") + .build(); + + p.cargo("rustc -v --example ex1 --crate-type lib,cdylib -Zunstable-options") + .masquerade_as_nightly_cargo() + .with_stderr( + "\ +[COMPILING] foo v0.0.1 ([CWD]) +[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib [..] +[RUNNING] `rustc --crate-name ex1 examples/ex1.rs [..]--crate-type lib,cdylib [..] +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] fn build_with_args_to_one_of_multiple_tests() { let p = project() .file("tests/foo.rs", r#" "#) diff -Nru cargo-0.58.0/tests/testsuite/rustdoc.rs cargo-0.60.0ubuntu1/tests/testsuite/rustdoc.rs --- cargo-0.58.0/tests/testsuite/rustdoc.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/rustdoc.rs 2022-02-10 02:58:21.000000000 +0000 @@ -32,6 +32,7 @@ -o [CWD]/target/doc \ [..] \ --cfg=foo \ + -C metadata=[..] \ -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", @@ -83,6 +84,7 @@ -o [CWD]/target/doc \ [..] \ --cfg=foo \ + -C metadata=[..] \ -L dependency=[CWD]/target/debug/deps \ --extern [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -122,6 +124,7 @@ -o [CWD]/target/doc \ [..] \ --cfg=foo \ + -C metadata=[..] \ -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", @@ -144,6 +147,7 @@ -o [CWD]/target/doc \ [..] \ --cfg=foo \ + -C metadata=[..] \ -L dependency=[CWD]/target/debug/deps [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", diff -Nru cargo-0.58.0/tests/testsuite/search.rs cargo-0.60.0ubuntu1/tests/testsuite/search.rs --- cargo-0.58.0/tests/testsuite/search.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/search.rs 2022-02-10 02:58:21.000000000 +0000 @@ -181,60 +181,6 @@ .run(); } -// TODO: Deprecated -// remove once it has been decided '--host' can be safely removed -#[cargo_test] -fn simple_with_host() { - setup(); - - cargo_process("search postgres --host") - .arg(registry_url().to_string()) - .with_stderr( - "\ -[WARNING] The flag '--host' is no longer valid. - -Previous versions of Cargo accepted this flag, but it is being -deprecated. The flag is being renamed to 'index', as the flag -wants the location of the index. Please use '--index' instead. - -This will soon become a hard error, so it's either recommended -to update to a fixed version or contact the upstream maintainer -about this warning. -[UPDATING] `[CWD]/registry` index -", - ) - .with_stdout_contains(SEARCH_RESULTS) - .run(); -} - -// TODO: Deprecated -// remove once it has been decided '--host' can be safely removed -#[cargo_test] -fn simple_with_index_and_host() { - setup(); - - cargo_process("search postgres --index") - .arg(registry_url().to_string()) - .arg("--host") - .arg(registry_url().to_string()) - .with_stderr( - "\ -[WARNING] The flag '--host' is no longer valid. - -Previous versions of Cargo accepted this flag, but it is being -deprecated. The flag is being renamed to 'index', as the flag -wants the location of the index. Please use '--index' instead. - -This will soon become a hard error, so it's either recommended -to update to a fixed version or contact the upstream maintainer -about this warning. -[UPDATING] `[CWD]/registry` index -", - ) - .with_stdout_contains(SEARCH_RESULTS) - .run(); -} - #[cargo_test] fn multiple_query_params() { setup(); diff -Nru cargo-0.58.0/tests/testsuite/tool_paths.rs cargo-0.60.0ubuntu1/tests/testsuite/tool_paths.rs --- cargo-0.58.0/tests/testsuite/tool_paths.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/tool_paths.rs 2022-02-10 02:58:21.000000000 +0000 @@ -1,8 +1,6 @@ //! Tests for configuration values that point to programs. -use cargo_test_support::{ - basic_lib_manifest, no_such_file_err_msg, project, rustc_host, rustc_host_env, -}; +use cargo_test_support::{basic_lib_manifest, project, rustc_host, rustc_host_env}; #[cargo_test] fn pathless_tools() { @@ -271,6 +269,9 @@ p.cargo("run") .env(&key, "nonexistent-runner --foo") .with_status(101) + // FIXME: Update "Caused by" error message once rust/pull/87704 is merged. + // On Windows, changing to a custom executable resolver has changed the + // error messages. .with_stderr(&format!( "\ [COMPILING] foo [..] @@ -279,9 +280,8 @@ [ERROR] could not execute process `nonexistent-runner --foo target/debug/foo[EXE]` (never executed) Caused by: - {} -", - no_such_file_err_msg() + [..] +" )) .run(); } diff -Nru cargo-0.58.0/tests/testsuite/tree.rs cargo-0.60.0ubuntu1/tests/testsuite/tree.rs --- cargo-0.58.0/tests/testsuite/tree.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/tree.rs 2022-02-10 02:58:21.000000000 +0000 @@ -1831,3 +1831,219 @@ .with_status(101) .run(); } + +#[cargo_test] +fn cyclic_features() { + // Check for stack overflow with cyclic features (oops!). + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "1.0.0" + + [features] + a = ["b"] + b = ["a"] + default = ["a"] + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("tree -e features") + .with_stdout("foo v1.0.0 ([ROOT]/foo)") + .run(); + + p.cargo("tree -e features -i foo") + .with_stdout( + "\ +foo v1.0.0 ([ROOT]/foo) +├── foo feature \"a\" +│ ├── foo feature \"b\" +│ │ └── foo feature \"a\" (*) +│ └── foo feature \"default\" (command-line) +├── foo feature \"b\" (*) +└── foo feature \"default\" (command-line) +", + ) + .run(); +} + +#[cargo_test] +fn dev_dep_cycle_with_feature() { + // Cycle with features and a dev-dependency. + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "1.0.0" + + [dev-dependencies] + bar = { path = "bar" } + + [features] + a = ["bar/feat1"] + "#, + ) + .file("src/lib.rs", "") + .file( + "bar/Cargo.toml", + r#" + [package] + name = "bar" + version = "1.0.0" + + [dependencies] + foo = { path = ".." } + + [features] + feat1 = ["foo/a"] + "#, + ) + .file("bar/src/lib.rs", "") + .build(); + + p.cargo("tree -e features --features a") + .with_stdout( + "\ +foo v1.0.0 ([ROOT]/foo) +[dev-dependencies] +└── bar feature \"default\" + └── bar v1.0.0 ([ROOT]/foo/bar) + └── foo feature \"default\" (command-line) + └── foo v1.0.0 ([ROOT]/foo) (*) +", + ) + .run(); + + p.cargo("tree -e features --features a -i foo") + .with_stdout( + "\ +foo v1.0.0 ([ROOT]/foo) +├── foo feature \"a\" (command-line) +│ └── bar feature \"feat1\" +│ └── foo feature \"a\" (command-line) (*) +└── foo feature \"default\" (command-line) + └── bar v1.0.0 ([ROOT]/foo/bar) + ├── bar feature \"default\" + │ [dev-dependencies] + │ └── foo v1.0.0 ([ROOT]/foo) (*) + └── bar feature \"feat1\" (*) +", + ) + .run(); +} + +#[cargo_test] +fn dev_dep_cycle_with_feature_nested() { + // Checks for an issue where a cyclic dev dependency tries to activate a + // feature on its parent that tries to activate the feature back on the + // dev-dependency. + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "1.0.0" + + [dev-dependencies] + bar = { path = "bar" } + + [features] + a = ["bar/feat1"] + b = ["a"] + "#, + ) + .file("src/lib.rs", "") + .file( + "bar/Cargo.toml", + r#" + [package] + name = "bar" + version = "1.0.0" + + [dependencies] + foo = { path = ".." } + + [features] + feat1 = ["foo/b"] + "#, + ) + .file("bar/src/lib.rs", "") + .build(); + + p.cargo("tree -e features") + .with_stdout( + "\ +foo v1.0.0 ([ROOT]/foo) +[dev-dependencies] +└── bar feature \"default\" + └── bar v1.0.0 ([ROOT]/foo/bar) + └── foo feature \"default\" (command-line) + └── foo v1.0.0 ([ROOT]/foo) (*) +", + ) + .run(); + + p.cargo("tree -e features --features a -i foo") + .with_stdout( + "\ +foo v1.0.0 ([ROOT]/foo) +├── foo feature \"a\" (command-line) +│ └── foo feature \"b\" +│ └── bar feature \"feat1\" +│ └── foo feature \"a\" (command-line) (*) +├── foo feature \"b\" (*) +└── foo feature \"default\" (command-line) + └── bar v1.0.0 ([ROOT]/foo/bar) + ├── bar feature \"default\" + │ [dev-dependencies] + │ └── foo v1.0.0 ([ROOT]/foo) (*) + └── bar feature \"feat1\" (*) +", + ) + .run(); + + p.cargo("tree -e features --features b -i foo") + .with_stdout( + "\ +foo v1.0.0 ([ROOT]/foo) +├── foo feature \"a\" +│ └── foo feature \"b\" (command-line) +│ └── bar feature \"feat1\" +│ └── foo feature \"a\" (*) +├── foo feature \"b\" (command-line) (*) +└── foo feature \"default\" (command-line) + └── bar v1.0.0 ([ROOT]/foo/bar) + ├── bar feature \"default\" + │ [dev-dependencies] + │ └── foo v1.0.0 ([ROOT]/foo) (*) + └── bar feature \"feat1\" (*) +", + ) + .run(); + + p.cargo("tree -e features --features bar/feat1 -i foo") + .with_stdout( + "\ +foo v1.0.0 ([ROOT]/foo) +├── foo feature \"a\" +│ └── foo feature \"b\" +│ └── bar feature \"feat1\" (command-line) +│ └── foo feature \"a\" (*) +├── foo feature \"b\" (*) +└── foo feature \"default\" (command-line) + └── bar v1.0.0 ([ROOT]/foo/bar) + ├── bar feature \"default\" + │ [dev-dependencies] + │ └── foo v1.0.0 ([ROOT]/foo) (*) + └── bar feature \"feat1\" (command-line) (*) +", + ) + .run(); +} diff -Nru cargo-0.58.0/tests/testsuite/update.rs cargo-0.60.0ubuntu1/tests/testsuite/update.rs --- cargo-0.58.0/tests/testsuite/update.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/update.rs 2022-02-10 02:58:21.000000000 +0000 @@ -464,6 +464,7 @@ "name": "bar", "readme": null, "repository": null, + "rust_version": null, "source": null, "targets": [ { @@ -504,6 +505,7 @@ "name": "serde", "readme": null, "repository": null, + "rust_version": null, "source": "registry+https://github.com/rust-lang/crates.io-index", "targets": [ { diff -Nru cargo-0.58.0/tests/testsuite/vendor.rs cargo-0.60.0ubuntu1/tests/testsuite/vendor.rs --- cargo-0.58.0/tests/testsuite/vendor.rs 2021-10-21 14:30:11.000000000 +0000 +++ cargo-0.60.0ubuntu1/tests/testsuite/vendor.rs 2022-02-10 02:58:21.000000000 +0000 @@ -753,3 +753,34 @@ let metadata = fs::metadata(p.root().join("vendor/bar/example.sh")).unwrap(); assert_eq!(metadata.mode() & 0o777, 0o755); } + +#[cargo_test] +fn no_remote_dependency_no_vendor() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + [dependencies] + bar = { path = "bar" } + "#, + ) + .file("src/lib.rs", "") + .file( + "bar/Cargo.toml", + r#" + [package] + name = "bar" + version = "0.1.0" + "#, + ) + .file("bar/src/lib.rs", "") + .build(); + + p.cargo("vendor") + .with_stderr("There is no dependency to vendor in this project.") + .run(); + assert!(!p.root().join("vendor").exists()); +} diff -Nru cargo-0.58.0/vendor/anyhow/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/anyhow/.cargo-checksum.json --- cargo-0.58.0/vendor/anyhow/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3"} \ No newline at end of file +{"files":{},"package":"4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/anyhow/Cargo.toml cargo-0.60.0ubuntu1/vendor/anyhow/Cargo.toml --- cargo-0.58.0/vendor/anyhow/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -13,7 +13,7 @@ edition = "2018" rust-version = "1.38" name = "anyhow" -version = "1.0.52" +version = "1.0.56" authors = ["David Tolnay "] description = "Flexible concrete Error type built on std::error::Error" documentation = "https://docs.rs/anyhow" @@ -21,12 +21,15 @@ categories = ["rust-patterns"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/anyhow" + [package.metadata.docs.rs] -rustdoc-args = ["--cfg", "doc_cfg"] targets = ["x86_64-unknown-linux-gnu"] -[dependencies.backtrace] -version = "0.3.51" -optional = true +rustdoc-args = [ + "--cfg", + "doc_cfg", +] + + [dev-dependencies.futures] version = "0.3" default-features = false diff -Nru cargo-0.58.0/vendor/anyhow/debian/patches/drop-backtrace.patch cargo-0.60.0ubuntu1/vendor/anyhow/debian/patches/drop-backtrace.patch --- cargo-0.58.0/vendor/anyhow/debian/patches/drop-backtrace.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/debian/patches/drop-backtrace.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,14 @@ +Index: anyhow/Cargo.toml +=================================================================== +--- anyhow.orig/Cargo.toml ++++ anyhow/Cargo.toml +@@ -23,9 +23,6 @@ repository = "https://github.com/dtolnay + rustdoc-args = ["--cfg", "doc_cfg"] + targets = ["x86_64-unknown-linux-gnu"] + +-[dependencies.backtrace] +-version = "0.3.51" +-optional = true + + [dev-dependencies.futures] + version = "0.3" diff -Nru cargo-0.58.0/vendor/anyhow/debian/patches/series cargo-0.60.0ubuntu1/vendor/anyhow/debian/patches/series --- cargo-0.58.0/vendor/anyhow/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1 @@ +drop-backtrace.patch diff -Nru cargo-0.58.0/vendor/anyhow/src/ensure.rs cargo-0.60.0ubuntu1/vendor/anyhow/src/ensure.rs --- cargo-0.58.0/vendor/anyhow/src/ensure.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/src/ensure.rs 2022-04-20 13:48:09.000000000 +0000 @@ -257,6 +257,10 @@ $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)*) :: <- $($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)*) }; @@ -303,6 +307,10 @@ $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 $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)*) }; @@ -427,6 +435,10 @@ $crate::__parse_ensure!(generic (tpath $stack) $bail ($($fuel)*) {($($buf)* <) $($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)*) }; @@ -435,6 +447,10 @@ $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)*) :: <- $($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)*) }; @@ -802,17 +818,17 @@ }; ($cond:expr, $msg:literal $(,)?) => { if !$cond { - return $crate::private::Err($crate::anyhow!($msg)); + return $crate::private::Err($crate::__anyhow!($msg)); } }; ($cond:expr, $err:expr $(,)?) => { if !$cond { - return $crate::private::Err($crate::anyhow!($err)); + return $crate::private::Err($crate::__anyhow!($err)); } }; ($cond:expr, $fmt:expr, $($arg:tt)*) => { if !$cond { - return $crate::private::Err($crate::anyhow!($fmt, $($arg)*)); + return $crate::private::Err($crate::__anyhow!($fmt, $($arg)*)); } }; } diff -Nru cargo-0.58.0/vendor/anyhow/src/error.rs cargo-0.60.0ubuntu1/vendor/anyhow/src/error.rs --- cargo-0.58.0/vendor/anyhow/src/error.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/src/error.rs 2022-04-20 13:48:09.000000000 +0000 @@ -26,6 +26,7 @@ #[cfg(feature = "std")] #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] #[cold] + #[must_use] pub fn new(error: E) -> Self where E: StdError + Send + Sync + 'static, @@ -72,6 +73,7 @@ /// } /// ``` #[cold] + #[must_use] pub fn msg(message: M) -> Self where M: Display + Debug + Send + Sync + 'static, @@ -293,6 +295,7 @@ /// } /// ``` #[cold] + #[must_use] pub fn context(self, context: C) -> Self where C: Display + Send + Sync + 'static, diff -Nru cargo-0.58.0/vendor/anyhow/src/lib.rs cargo-0.60.0ubuntu1/vendor/anyhow/src/lib.rs --- cargo-0.58.0/vendor/anyhow/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/src/lib.rs 2022-04-20 13:48:09.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.52")] +#![doc(html_root_url = "https://docs.rs/anyhow/1.0.56")] #![cfg_attr(backtrace, feature(backtrace))] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![cfg_attr(not(feature = "std"), no_std)] @@ -496,6 +496,11 @@ /// No such file or directory (os error 2) /// ``` /// +/// Refer to the [Display representations] documentation for other forms in +/// which this context chain can be rendered. +/// +/// [Display representations]: Error#display-representations +/// ///
/// /// # Effect on downcasting @@ -663,4 +668,12 @@ Error::msg(fmt::format(args)) } } + + #[doc(hidden)] + #[inline] + #[cold] + #[must_use] + pub fn must_use(error: Error) -> Error { + error + } } diff -Nru cargo-0.58.0/vendor/anyhow/src/macros.rs cargo-0.60.0ubuntu1/vendor/anyhow/src/macros.rs --- cargo-0.58.0/vendor/anyhow/src/macros.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/src/macros.rs 2022-04-20 13:48:09.000000000 +0000 @@ -54,13 +54,13 @@ #[macro_export] macro_rules! bail { ($msg:literal $(,)?) => { - return $crate::private::Err($crate::anyhow!($msg)) + return $crate::private::Err($crate::__anyhow!($msg)) }; ($err:expr $(,)?) => { - return $crate::private::Err($crate::anyhow!($err)) + return $crate::private::Err($crate::__anyhow!($err)) }; ($fmt:expr, $($arg:tt)*) => { - return $crate::private::Err($crate::anyhow!($fmt, $($arg)*)) + return $crate::private::Err($crate::__anyhow!($fmt, $($arg)*)) }; } @@ -75,13 +75,13 @@ return $crate::private::Err($crate::Error::msg("pattern does not contain `{}`")) }; ($msg:literal $(,)?) => { - return $crate::private::Err($crate::anyhow!($msg)) + return $crate::private::Err($crate::__anyhow!($msg)) }; ($err:expr $(,)?) => { - return $crate::private::Err($crate::anyhow!($err)) + return $crate::private::Err($crate::__anyhow!($err)) }; ($fmt:expr, $($arg:tt)*) => { - return $crate::private::Err($crate::anyhow!($fmt, $($arg)*)) + return $crate::private::Err($crate::__anyhow!($fmt, $($arg)*)) }; } @@ -145,17 +145,17 @@ }; ($cond:expr, $msg:literal $(,)?) => { if !$cond { - return $crate::private::Err($crate::anyhow!($msg)); + return $crate::private::Err($crate::__anyhow!($msg)); } }; ($cond:expr, $err:expr $(,)?) => { if !$cond { - return $crate::private::Err($crate::anyhow!($err)); + return $crate::private::Err($crate::__anyhow!($err)); } }; ($cond:expr, $fmt:expr, $($arg:tt)*) => { if !$cond { - return $crate::private::Err($crate::anyhow!($fmt, $($arg)*)); + return $crate::private::Err($crate::__anyhow!($fmt, $($arg)*)); } }; } @@ -206,6 +206,32 @@ /// ``` #[macro_export] macro_rules! anyhow { + ($msg:literal $(,)?) => { + $crate::private::must_use({ + let error = $crate::private::format_err($crate::private::format_args!($msg)); + error + }) + }; + ($err:expr $(,)?) => { + $crate::private::must_use({ + use $crate::private::kind::*; + let error = match $err { + error => (&error).anyhow_kind().new(error), + }; + error + }) + }; + ($fmt:expr, $($arg:tt)*) => { + $crate::Error::msg($crate::private::format!($fmt, $($arg)*)) + }; +} + +// Not public API. This is used in the implementation of some of the other +// macros, in which the must_use call is not needed because the value is known +// to be used. +#[doc(hidden)] +#[macro_export] +macro_rules! __anyhow { ($msg:literal $(,)?) => ({ let error = $crate::private::format_err($crate::private::format_args!($msg)); error diff -Nru cargo-0.58.0/vendor/anyhow/tests/test_ensure.rs cargo-0.60.0ubuntu1/vendor/anyhow/tests/test_ensure.rs --- cargo-0.58.0/vendor/anyhow/tests/test_ensure.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/tests/test_ensure.rs 2022-04-20 13:48:09.000000000 +0000 @@ -13,7 +13,8 @@ clippy::too_many_lines, clippy::unit_arg, clippy::while_immutable_condition, - clippy::zero_ptr + clippy::zero_ptr, + irrefutable_let_patterns )] use anyhow::{anyhow, ensure, Chain, Error, Result}; @@ -323,6 +324,18 @@ "Condition failed: `Chain::<'static>::new.t(1) == 2` (1 vs 2)", ); + fn f() {} + let test = || Ok(ensure!(f::<1>() != ())); + assert_err(test, "Condition failed: `f::<1>() != ()` (() vs ())"); + let test = || Ok(ensure!(f::<-1>() != ())); + assert_err(test, "Condition failed: `f::<-1>() != ()` (() vs ())"); + + fn g() {} + let test = || Ok(ensure!(g::() != ())); + assert_err(test, "Condition failed: `g::() != ()` (() vs ())"); + let test = || Ok(ensure!(g::() != ())); + assert_err(test, "Condition failed: `g::() != ()` (() vs ())"); + #[derive(PartialOrd, PartialEq, Debug)] enum E<'a, T> { #[allow(dead_code)] @@ -395,7 +408,7 @@ let test = || Ok(ensure!(PhantomData:: {} != PhantomData)); assert_err( test, - "Condition failed: `PhantomData::{} != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `PhantomData:: {} != PhantomData` (PhantomData vs PhantomData)", ); let result = Ok::<_, Error>(1); @@ -528,7 +541,7 @@ 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 + "Condition failed: `f as for<'a> fn() as usize * 0 != 0` (0 vs 0)", ); let test = || Ok(ensure!(f as unsafe fn() as usize * 0 != 0)); @@ -613,7 +626,7 @@ 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 + "Condition failed: `if let -1..=1 = 0 { 0 } else { 1 } == 1` (0 vs 1)", ); let test = || Ok(ensure!(if let &0 = &0 { 0 } else { 1 } == 1)); @@ -656,7 +669,7 @@ 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 + "Condition failed: `if let P:: {} = p { 0 } else { 1 } == 1` (0 vs 1)", ); let test = || Ok(ensure!(if let ::std::marker::PhantomData = p {} != ())); diff -Nru cargo-0.58.0/vendor/anyhow/tests/ui/must-use.rs cargo-0.60.0ubuntu1/vendor/anyhow/tests/ui/must-use.rs --- cargo-0.58.0/vendor/anyhow/tests/ui/must-use.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/tests/ui/must-use.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,11 @@ +#![deny(unused_must_use)] + +use anyhow::anyhow; + +fn main() -> anyhow::Result<()> { + if true { + // meant to write bail! + anyhow!("it failed"); + } + Ok(()) +} diff -Nru cargo-0.58.0/vendor/anyhow/tests/ui/must-use.stderr cargo-0.60.0ubuntu1/vendor/anyhow/tests/ui/must-use.stderr --- cargo-0.58.0/vendor/anyhow/tests/ui/must-use.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/anyhow/tests/ui/must-use.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,12 @@ +error: unused return value of `must_use` that must be used + --> tests/ui/must-use.rs:8:9 + | +8 | anyhow!("it failed"); + | ^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> tests/ui/must-use.rs:1:9 + | +1 | #![deny(unused_must_use)] + | ^^^^^^^^^^^^^^^ + = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info) diff -Nru cargo-0.58.0/vendor/autocfg/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/autocfg/.cargo-checksum.json --- cargo-0.58.0/vendor/autocfg/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/autocfg/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"} \ No newline at end of file +{"files":{},"package":"d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/autocfg/Cargo.lock cargo-0.60.0ubuntu1/vendor/autocfg/Cargo.lock --- cargo-0.58.0/vendor/autocfg/Cargo.lock 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/autocfg/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -1,6 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "autocfg" -version = "1.0.1" - +version = "1.1.0" diff -Nru cargo-0.58.0/vendor/autocfg/Cargo.toml cargo-0.60.0ubuntu1/vendor/autocfg/Cargo.toml --- cargo-0.58.0/vendor/autocfg/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/autocfg/Cargo.toml 2022-04-20 13:48:09.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 = "autocfg" -version = "1.0.1" +version = "1.1.0" authors = ["Josh Stone "] exclude = ["/.github/**", "/bors.toml"] description = "Automatic cfg for Rust compiler features" diff -Nru cargo-0.58.0/vendor/autocfg/README.md cargo-0.60.0ubuntu1/vendor/autocfg/README.md --- cargo-0.58.0/vendor/autocfg/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/autocfg/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -43,6 +43,9 @@ ## Release Notes +- 1.1.0 (2022-02-07) + - Use `CARGO_ENCODED_RUSTFLAGS` when it is set. + - 1.0.1 (2020-08-20) - Apply `RUSTFLAGS` for more `--target` scenarios, by @adamreichold. diff -Nru cargo-0.58.0/vendor/autocfg/src/lib.rs cargo-0.60.0ubuntu1/vendor/autocfg/src/lib.rs --- cargo-0.58.0/vendor/autocfg/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/autocfg/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -63,7 +63,7 @@ use std::ffi::OsString; use std::fs; use std::io::{stderr, Write}; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; #[allow(deprecated)] use std::sync::atomic::ATOMIC_USIZE_INIT; @@ -86,7 +86,7 @@ rustc_version: Version, target: Option, no_std: bool, - rustflags: Option>, + rustflags: Vec, } /// Writes a config flag for rustc on standard out. @@ -166,37 +166,13 @@ return Err(error::from_str("output path is not a writable directory")); } - // Cargo only applies RUSTFLAGS for building TARGET artifact in - // cross-compilation environment. Sadly, we don't have a way to detect - // when we're building HOST artifact in a cross-compilation environment, - // so for now we only apply RUSTFLAGS when cross-compiling an artifact. - // - // See https://github.com/cuviper/autocfg/pull/10#issuecomment-527575030. - let rustflags = if target != env::var_os("HOST") - || dir_contains_target(&target, &dir, env::var_os("CARGO_TARGET_DIR")) - { - env::var("RUSTFLAGS").ok().map(|rustflags| { - // This is meant to match how cargo handles the RUSTFLAG environment - // variable. - // See https://github.com/rust-lang/cargo/blob/69aea5b6f69add7c51cca939a79644080c0b0ba0/src/cargo/core/compiler/build_context/target_info.rs#L434-L441 - rustflags - .split(' ') - .map(str::trim) - .filter(|s| !s.is_empty()) - .map(str::to_string) - .collect::>() - }) - } else { - None - }; - let mut ac = AutoCfg { + rustflags: rustflags(&target, &dir), out_dir: dir, rustc: rustc, rustc_version: rustc_version, target: target, no_std: false, - rustflags: rustflags, }; // Sanity check with and without `std`. @@ -240,14 +216,12 @@ .arg(&self.out_dir) .arg("--emit=llvm-ir"); - if let &Some(ref rustflags) = &self.rustflags { - command.args(rustflags); - } - if let Some(target) = self.target.as_ref() { command.arg("--target").arg(target); } + command.args(&self.rustflags); + command.arg("-").stdin(Stdio::piped()); let mut child = try!(command.spawn().map_err(error::from_io)); let mut stdin = child.stdin.take().expect("rustc stdin"); @@ -417,7 +391,7 @@ fn dir_contains_target( target: &Option, - dir: &PathBuf, + dir: &Path, cargo_target_dir: Option, ) -> bool { target @@ -436,3 +410,44 @@ }) .unwrap_or(false) } + +fn rustflags(target: &Option, dir: &Path) -> Vec { + // Starting with rust-lang/cargo#9601, shipped in Rust 1.55, Cargo always sets + // CARGO_ENCODED_RUSTFLAGS for any host/target build script invocation. This + // includes any source of flags, whether from the environment, toml config, or + // whatever may come in the future. The value is either an empty string, or a + // list of arguments separated by the ASCII unit separator (US), 0x1f. + if let Ok(a) = env::var("CARGO_ENCODED_RUSTFLAGS") { + return if a.is_empty() { + Vec::new() + } else { + a.split('\x1f').map(str::to_string).collect() + }; + } + + // Otherwise, we have to take a more heuristic approach, and we don't + // support values from toml config at all. + // + // Cargo only applies RUSTFLAGS for building TARGET artifact in + // cross-compilation environment. Sadly, we don't have a way to detect + // when we're building HOST artifact in a cross-compilation environment, + // so for now we only apply RUSTFLAGS when cross-compiling an artifact. + // + // See https://github.com/cuviper/autocfg/pull/10#issuecomment-527575030. + if *target != env::var_os("HOST") + || dir_contains_target(target, dir, env::var_os("CARGO_TARGET_DIR")) + { + if let Ok(rustflags) = env::var("RUSTFLAGS") { + // This is meant to match how cargo handles the RUSTFLAGS environment variable. + // See https://github.com/rust-lang/cargo/blob/69aea5b6f69add7c51cca939a79644080c0b0ba0/src/cargo/core/compiler/build_context/target_info.rs#L434-L441 + return rustflags + .split(' ') + .map(str::trim) + .filter(|s| !s.is_empty()) + .map(str::to_string) + .collect(); + } + } + + Vec::new() +} diff -Nru cargo-0.58.0/vendor/autocfg/src/tests.rs cargo-0.60.0ubuntu1/vendor/autocfg/src/tests.rs --- cargo-0.58.0/vendor/autocfg/src/tests.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/autocfg/src/tests.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,5 +1,6 @@ use super::AutoCfg; use std::env; +use std::path::Path; impl AutoCfg { fn core_std(&self, path: &str) -> String { @@ -136,7 +137,7 @@ fn dir_does_not_contain_target() { assert!(!super::dir_contains_target( &Some("x86_64-unknown-linux-gnu".into()), - &"/project/target/debug/build/project-ea75983148559682/out".into(), + Path::new("/project/target/debug/build/project-ea75983148559682/out"), None, )); } @@ -145,7 +146,9 @@ fn dir_does_contain_target() { assert!(super::dir_contains_target( &Some("x86_64-unknown-linux-gnu".into()), - &"/project/target/x86_64-unknown-linux-gnu/debug/build/project-0147aca016480b9d/out".into(), + Path::new( + "/project/target/x86_64-unknown-linux-gnu/debug/build/project-0147aca016480b9d/out" + ), None, )); } @@ -154,7 +157,7 @@ fn dir_does_not_contain_target_with_custom_target_dir() { assert!(!super::dir_contains_target( &Some("x86_64-unknown-linux-gnu".into()), - &"/project/custom/debug/build/project-ea75983148559682/out".into(), + Path::new("/project/custom/debug/build/project-ea75983148559682/out"), Some("custom".into()), )); } @@ -163,7 +166,9 @@ fn dir_does_contain_target_with_custom_target_dir() { assert!(super::dir_contains_target( &Some("x86_64-unknown-linux-gnu".into()), - &"/project/custom/x86_64-unknown-linux-gnu/debug/build/project-0147aca016480b9d/out".into(), + Path::new( + "/project/custom/x86_64-unknown-linux-gnu/debug/build/project-0147aca016480b9d/out" + ), Some("custom".into()), )); } diff -Nru cargo-0.58.0/vendor/autocfg/tests/rustflags.rs cargo-0.60.0ubuntu1/vendor/autocfg/tests/rustflags.rs --- cargo-0.58.0/vendor/autocfg/tests/rustflags.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/autocfg/tests/rustflags.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,18 +2,32 @@ use std::env; -/// Tests that autocfg uses the RUSTFLAGS environment variable when running -/// rustc. +/// Tests that autocfg uses the RUSTFLAGS or CARGO_ENCODED_RUSTFLAGS +/// environment variables when running rustc. #[test] fn test_with_sysroot() { // Use the same path as this test binary. let dir = env::current_exe().unwrap().parent().unwrap().to_path_buf(); - env::set_var("RUSTFLAGS", &format!("-L {}", dir.display())); env::set_var("OUT_DIR", &format!("{}", dir.display())); - // Ensure HOST != TARGET. - env::set_var("HOST", "lol"); + // If we have encoded rustflags, they take precedence, even if empty. + env::set_var("CARGO_ENCODED_RUSTFLAGS", ""); + env::set_var("RUSTFLAGS", &format!("-L {}", dir.display())); + let ac = autocfg::AutoCfg::new().unwrap(); + assert!(ac.probe_sysroot_crate("std")); + assert!(!ac.probe_sysroot_crate("autocfg")); + // Now try again with useful encoded args. + env::set_var( + "CARGO_ENCODED_RUSTFLAGS", + &format!("-L\x1f{}", dir.display()), + ); + let ac = autocfg::AutoCfg::new().unwrap(); + assert!(ac.probe_sysroot_crate("autocfg")); + + // Try the old-style RUSTFLAGS, ensuring HOST != TARGET. + env::remove_var("CARGO_ENCODED_RUSTFLAGS"); + env::set_var("HOST", "lol"); let ac = autocfg::AutoCfg::new().unwrap(); assert!(ac.probe_sysroot_crate("autocfg")); } diff -Nru cargo-0.58.0/vendor/bitflags/debian/patches/disable-tests-permission-denied.patch cargo-0.60.0ubuntu1/vendor/bitflags/debian/patches/disable-tests-permission-denied.patch --- cargo-0.58.0/vendor/bitflags/debian/patches/disable-tests-permission-denied.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/bitflags/debian/patches/disable-tests-permission-denied.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,27 @@ +disable compile-fail tests, they fail with a permission denied error. +in the autopkgtest environment. +Index: bitflags/tests/compile.rs +=================================================================== +--- bitflags.orig/tests/compile.rs ++++ bitflags/tests/compile.rs +@@ -7,13 +7,13 @@ use std::{ + + use walkdir::WalkDir; + +-#[test] +-fn fail() { +- prepare_stderr_files("tests/compile-fail").unwrap(); +- +- let t = trybuild::TestCases::new(); +- t.compile_fail("tests/compile-fail/**/*.rs"); +-} ++//#[test] ++//fn fail() { ++// prepare_stderr_files("tests/compile-fail").unwrap(); ++// ++// let t = trybuild::TestCases::new(); ++// t.compile_fail("tests/compile-fail/**/*.rs"); ++//} + + #[test] + fn pass() { diff -Nru cargo-0.58.0/vendor/bitflags/debian/patches/series cargo-0.60.0ubuntu1/vendor/bitflags/debian/patches/series --- cargo-0.58.0/vendor/bitflags/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/bitflags/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1 @@ +disable-tests-permission-denied.patch diff -Nru cargo-0.58.0/vendor/bitflags/tests/compile.rs cargo-0.60.0ubuntu1/vendor/bitflags/tests/compile.rs --- cargo-0.58.0/vendor/bitflags/tests/compile.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/bitflags/tests/compile.rs 2022-04-20 13:48:09.000000000 +0000 @@ -7,13 +7,13 @@ use walkdir::WalkDir; -#[test] -fn fail() { - prepare_stderr_files("tests/compile-fail").unwrap(); - - let t = trybuild::TestCases::new(); - t.compile_fail("tests/compile-fail/**/*.rs"); -} +//#[test] +//fn fail() { +// prepare_stderr_files("tests/compile-fail").unwrap(); +// +// let t = trybuild::TestCases::new(); +// t.compile_fail("tests/compile-fail/**/*.rs"); +//} #[test] fn pass() { diff -Nru cargo-0.58.0/vendor/cc/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/cc/.cargo-checksum.json --- cargo-0.58.0/vendor/cc/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cc/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"} \ No newline at end of file +{"files":{},"package":"2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/cc/Cargo.lock cargo-0.60.0ubuntu1/vendor/cc/Cargo.lock --- cargo-0.58.0/vendor/cc/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cc/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -10,7 +10,7 @@ [[package]] name = "cc" -version = "1.0.72" +version = "1.0.73" dependencies = [ "jobserver", "tempfile", @@ -23,76 +23,37 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "getrandom" -version = "0.2.3" +name = "fastrand" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" dependencies = [ - "cfg-if", - "libc", - "wasi", + "instant", ] [[package]] -name = "jobserver" -version = "0.1.24" +name = "instant" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "libc", + "cfg-if", ] [[package]] -name = "libc" -version = "0.2.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" - -[[package]] -name = "ppv-lite86" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" - -[[package]] -name = "rand" -version = "0.8.4" +name = "jobserver" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" dependencies = [ "libc", - "rand_chacha", - "rand_core", - "rand_hc", ] [[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.3.1" +name = "libc" +version = "0.2.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core", -] +checksum = "06e509672465a0504304aa87f9f176f2b2b716ed8fb105ebe5c02dc6dce96a94" [[package]] name = "redox_syscall" @@ -114,25 +75,19 @@ [[package]] name = "tempfile" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if", + "fastrand", "libc", - "rand", "redox_syscall", "remove_dir_all", "winapi", ] [[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - -[[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" diff -Nru cargo-0.58.0/vendor/cc/Cargo.toml cargo-0.60.0ubuntu1/vendor/cc/Cargo.toml --- cargo-0.58.0/vendor/cc/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cc/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "cc" -version = "1.0.72" +version = "1.0.73" 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.58.0/vendor/cc/debian/patches/use-mfpu-on-armhf.patch cargo-0.60.0ubuntu1/vendor/cc/debian/patches/use-mfpu-on-armhf.patch --- cargo-0.58.0/vendor/cc/debian/patches/use-mfpu-on-armhf.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cc/debian/patches/use-mfpu-on-armhf.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,16 @@ +The upstream code uses -march but not -mfpu on debian armhf, this works +with gcc-10 but produces an error with gcc-11, set mfpu to fix this. + +--- a/src/lib.rs 1973-11-29 21:33:09.000000000 +0000 ++++ b/src/lib.rs 2021-10-23 23:05:21.409460780 +0000 +@@ -1638,6 +1638,10 @@ + && (target.contains("-linux-") || target.contains("-kmc-solid_")) + { + cmd.args.push("-march=armv7-a".into()); ++ if target.ends_with("eabihf") { ++ // lowest common denominator FPU ++ cmd.args.push("-mfpu=vfpv3-d16".into()); ++ } + } + + // (x86 Android doesn't say "eabi") diff -Nru cargo-0.58.0/vendor/cc/src/lib.rs cargo-0.60.0ubuntu1/vendor/cc/src/lib.rs --- cargo-0.58.0/vendor/cc/src/lib.rs 2022-01-21 02:49:13.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cc/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -62,7 +62,7 @@ use std::fmt::{self, Display}; use std::fs; use std::io::{self, BufRead, BufReader, Read, Write}; -use std::path::{Path, PathBuf}; +use std::path::{Component, Path, PathBuf}; use std::process::{Child, Command, Stdio}; use std::sync::{Arc, Mutex}; use std::thread::{self, JoinHandle}; @@ -139,6 +139,8 @@ ToolExecError, /// Error occurred due to missing external tools. ToolNotFound, + /// One of the function arguments failed validation. + InvalidArgument, } /// Represents an internal error that occurred, with an explanation. @@ -408,7 +410,7 @@ self } - /// Add an arbitrary flag to the invocation of the compiler + /// Add a flag to the invocation of the ar /// /// # Example /// @@ -419,7 +421,6 @@ /// .ar_flag("/NODEFAULTLIB:libc.dll") /// .compile("foo"); /// ``` - pub fn ar_flag(&mut self, flag: &str) -> &mut Build { self.ar_flags.push(flag.to_string()); self @@ -944,6 +945,17 @@ /// /// This will return a result instead of panicing; see compile() for the complete description. pub fn try_compile(&self, output: &str) -> Result<(), Error> { + let mut output_components = Path::new(output).components(); + match (output_components.next(), output_components.next()) { + (Some(Component::Normal(_)), None) => {} + _ => { + return Err(Error::new( + ErrorKind::InvalidArgument, + "argument of `compile` must be a single normal path component", + )); + } + } + let (lib_name, gnu_lib_name) = if output.starts_with("lib") && output.ends_with(".a") { (&output[3..output.len() - 2], output.to_owned()) } else { @@ -1067,10 +1079,35 @@ /// Run the compiler, generating the file `output` /// - /// The name `output` should be the name of the library. For backwards compatibility, - /// the `output` may start with `lib` and end with `.a`. The Rust compiler will create - /// the assembly with the lib prefix and .a extension. MSVC will create a file without prefix, - /// ending with `.lib`. + /// # Library name + /// + /// The `output` string argument determines the file name for the compiled + /// library. The Rust compiler will create an assembly named "lib"+output+".a". + /// MSVC will create a file named output+".lib". + /// + /// The choice of `output` is close to arbitrary, but: + /// + /// - must be nonempty, + /// - must not contain a path separator (`/`), + /// - must be unique across all `compile` invocations made by the same build + /// script. + /// + /// If your build script compiles a single source file, the base name of + /// that source file would usually be reasonable: + /// + /// ```no_run + /// cc::Build::new().file("blobstore.c").compile("blobstore"); + /// ``` + /// + /// Compiling multiple source files, some people use their crate's name, or + /// their crate's name + "-cc". + /// + /// Otherwise, please use your imagination. + /// + /// For backwards compatibility, if `output` starts with "lib" *and* ends + /// with ".a", a second "lib" prefix and ".a" suffix do not get added on, + /// but this usage is deprecated; please omit `lib` and `.a` in the argument + /// that you pass. /// /// # Panics /// @@ -1566,6 +1603,8 @@ cmd.args.push("--target=x86_64-unknown-windows-gnu".into()); } else if target.contains("i686") { cmd.args.push("--target=i686-unknown-windows-gnu".into()) + } else if target.contains("aarch64") { + cmd.args.push("--target=aarch64-unknown-windows-gnu".into()) } } else { cmd.args.push(format!("--target={}", target).into()); @@ -1788,6 +1827,12 @@ if target.contains("linux") && arch.starts_with("64") { cmd.args.push(("-march=rv64gc").into()); cmd.args.push("-mabi=lp64d".into()); + } else if target.contains("freebsd") && arch.starts_with("64") { + cmd.args.push(("-march=rv64gc").into()); + cmd.args.push("-mabi=lp64d".into()); + } else if target.contains("openbsd") && arch.starts_with("64") { + cmd.args.push(("-march=rv64gc").into()); + cmd.args.push("-mabi=lp64d".into()); } else if target.contains("linux") && arch.starts_with("32") { cmd.args.push(("-march=rv32gc").into()); cmd.args.push("-mabi=ilp32d".into()); @@ -2501,6 +2546,8 @@ .as_ref() .map(|s| s.trim_right_matches('-').to_owned()); cross_compile.or(match &target[..] { + "aarch64-pc-windows-gnu" => Some("aarch64-w64-mingw32"), + "aarch64-uwp-windows-gnu" => Some("aarch64-w64-mingw32"), "aarch64-unknown-linux-gnu" => Some("aarch64-linux-gnu"), "aarch64-unknown-linux-musl" => Some("aarch64-linux-musl"), "aarch64-unknown-netbsd" => Some("aarch64--netbsd"), diff -Nru cargo-0.58.0/vendor/cc/src/windows_registry.rs cargo-0.60.0ubuntu1/vendor/cc/src/windows_registry.rs --- cargo-0.58.0/vendor/cc/src/windows_registry.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cc/src/windows_registry.rs 2022-04-20 13:48:09.000000000 +0000 @@ -134,7 +134,9 @@ _ => { // Check for the presence of a specific registry key // that indicates visual studio is installed. - if impl_::has_msbuild_version("16.0") { + if impl_::has_msbuild_version("17.0") { + Ok(VsVers::Vs17) + } else if impl_::has_msbuild_version("16.0") { Ok(VsVers::Vs16) } else if impl_::has_msbuild_version("15.0") { Ok(VsVers::Vs15) @@ -250,18 +252,22 @@ } } + fn find_msbuild_vs17(target: &str) -> Option { + find_tool_in_vs16plus_path(r"MSBuild\Current\Bin\MSBuild.exe", target, "17") + } + #[allow(bare_trait_objects)] - fn vs16_instances(target: &str) -> Box> { + fn vs16plus_instances(target: &str, version: &'static str) -> Box> { let instances = if let Some(instances) = vs15plus_instances(target) { instances } else { return Box::new(iter::empty()); }; - Box::new(instances.into_iter().filter_map(|instance| { + Box::new(instances.into_iter().filter_map(move |instance| { let installation_name = instance.installation_name()?; - if installation_name.starts_with("VisualStudio/16.") { + if installation_name.starts_with(&format!("VisualStudio/{}.", version)) { Some(instance.installation_path()?) - } else if installation_name.starts_with("VisualStudioPreview/16.") { + } else if installation_name.starts_with(&format!("VisualStudioPreview/{}.", version)) { Some(instance.installation_path()?) } else { None @@ -269,8 +275,8 @@ })) } - fn find_tool_in_vs16_path(tool: &str, target: &str) -> Option { - vs16_instances(target) + fn find_tool_in_vs16plus_path(tool: &str, target: &str, version: &'static str) -> Option { + vs16plus_instances(target, version) .filter_map(|path| { let path = path.join(tool); if !path.is_file() { @@ -289,7 +295,7 @@ } fn find_msbuild_vs16(target: &str) -> Option { - find_tool_in_vs16_path(r"MSBuild\Current\Bin\MSBuild.exe", target) + find_tool_in_vs16plus_path(r"MSBuild\Current\Bin\MSBuild.exe", target, "16") } // In MSVC 15 (2017) MS once again changed the scheme for locating @@ -663,7 +669,15 @@ // only need to bother checking x64, making this code a tiny bit simpler. // Like we do for the Universal CRT, we sort the possibilities // asciibetically to find the newest one as that is what vcvars does. + // Before doing that, we check the "WindowsSdkDir" and "WindowsSDKVersion" + // environment variables set by vcvars to use the environment sdk version + // if one is already configured. fn get_sdk10_dir() -> Option<(PathBuf, String)> { + if let (Ok(root), Ok(version)) = (env::var("WindowsSdkDir"), env::var("WindowsSDKVersion")) + { + return Some((root.into(), version.trim_end_matches('\\').to_string())); + } + let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0"; let key = LOCAL_MACHINE.open(key.as_ref()).ok()?; let root = key.query_str("InstallationFolder").ok()?; @@ -816,6 +830,11 @@ pub fn has_msbuild_version(version: &str) -> bool { match version { + "17.0" => { + find_msbuild_vs17("x86_64-pc-windows-msvc").is_some() + || find_msbuild_vs17("i686-pc-windows-msvc").is_some() + || find_msbuild_vs17("aarch64-pc-windows-msvc").is_some() + } "16.0" => { find_msbuild_vs16("x86_64-pc-windows-msvc").is_some() || find_msbuild_vs16("i686-pc-windows-msvc").is_some() diff -Nru cargo-0.58.0/vendor/cc/tests/support/mod.rs cargo-0.60.0ubuntu1/vendor/cc/tests/support/mod.rs --- cargo-0.58.0/vendor/cc/tests/support/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cc/tests/support/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -62,13 +62,12 @@ } pub fn shim(&self, name: &str) -> &Test { - link_or_copy( - &self.gcc, - self.td - .path() - .join(&format!("{}{}", name, env::consts::EXE_SUFFIX)), - ) - .unwrap(); + let name = if name.ends_with(env::consts::EXE_SUFFIX) { + name.to_string() + } else { + format!("{}{}", name, env::consts::EXE_SUFFIX) + }; + link_or_copy(&self.gcc, self.td.path().join(name)).unwrap(); self } diff -Nru cargo-0.58.0/vendor/cfg-if-0.1.10/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/.cargo-checksum.json --- cargo-0.58.0/vendor/cfg-if-0.1.10/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -{"files":{},"package":"4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/cfg-if-0.1.10/Cargo.toml cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/Cargo.toml --- cargo-0.58.0/vendor/cfg-if-0.1.10/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - -[package] -edition = "2018" -name = "cfg-if" -version = "0.1.10" -authors = ["Alex Crichton "] -description = "A macro to ergonomically define an item depending on a large number of #[cfg]\nparameters. Structured like an if-else chain, the first matching branch is the\nitem that gets emitted.\n" -homepage = "https://github.com/alexcrichton/cfg-if" -documentation = "https://docs.rs/cfg-if" -readme = "README.md" -license = "MIT/Apache-2.0" -repository = "https://github.com/alexcrichton/cfg-if" -[dependencies.compiler_builtins] -version = "0.1.2" -optional = true - -[dependencies.core] -version = "1.0.0" -optional = true -package = "rustc-std-workspace-core" - -[features] -rustc-dep-of-std = ["core", "compiler_builtins"] -[badges.travis-ci] -repository = "alexcrichton/cfg-if" diff -Nru cargo-0.58.0/vendor/cfg-if-0.1.10/LICENSE-APACHE cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/LICENSE-APACHE --- cargo-0.58.0/vendor/cfg-if-0.1.10/LICENSE-APACHE 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff -Nru cargo-0.58.0/vendor/cfg-if-0.1.10/LICENSE-MIT cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/LICENSE-MIT --- cargo-0.58.0/vendor/cfg-if-0.1.10/LICENSE-MIT 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -Copyright (c) 2014 Alex Crichton - -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.58.0/vendor/cfg-if-0.1.10/README.md cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/README.md --- cargo-0.58.0/vendor/cfg-if-0.1.10/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -# cfg-if - -[Documentation](https://docs.rs/cfg-if) - -A macro to ergonomically define an item depending on a large number of #[cfg] -parameters. Structured like an if-else chain, the first matching branch is the -item that gets emitted. - -```toml -[dependencies] -cfg-if = "0.1" -``` - -## Example - -```rust -cfg_if::cfg_if! { - if #[cfg(unix)] { - fn foo() { /* unix specific functionality */ } - } else if #[cfg(target_pointer_width = "32")] { - fn foo() { /* non-unix, 32-bit functionality */ } - } else { - fn foo() { /* fallback implementation */ } - } -} - -fn main() { - foo(); -} -``` - -# License - -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) - -at your option. - -### Contribution - -Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in `cfg-if` by you, as defined in the Apache-2.0 license, shall be -dual licensed as above, without any additional terms or conditions. diff -Nru cargo-0.58.0/vendor/cfg-if-0.1.10/src/lib.rs cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/src/lib.rs --- cargo-0.58.0/vendor/cfg-if-0.1.10/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ -//! A macro for defining `#[cfg]` if-else statements. -//! -//! The macro provided by this crate, `cfg_if`, is similar to the `if/elif` C -//! preprocessor macro by allowing definition of a cascade of `#[cfg]` cases, -//! emitting the implementation which matches first. -//! -//! This allows you to conveniently provide a long list `#[cfg]`'d blocks of code -//! without having to rewrite each clause multiple times. -//! -//! # Example -//! -//! ``` -//! cfg_if::cfg_if! { -//! if #[cfg(unix)] { -//! fn foo() { /* unix specific functionality */ } -//! } else if #[cfg(target_pointer_width = "32")] { -//! fn foo() { /* non-unix, 32-bit functionality */ } -//! } else { -//! fn foo() { /* fallback implementation */ } -//! } -//! } -//! -//! # fn main() {} -//! ``` - -#![no_std] -#![doc(html_root_url = "https://docs.rs/cfg-if")] -#![deny(missing_docs)] -#![cfg_attr(test, deny(warnings))] - -/// The main macro provided by this crate. See crate documentation for more -/// information. -#[macro_export] -macro_rules! cfg_if { - // match if/else chains with a final `else` - ($( - if #[cfg($($meta:meta),*)] { $($tokens:tt)* } - ) else * else { - $($tokens2:tt)* - }) => { - $crate::cfg_if! { - @__items - () ; - $( ( ($($meta),*) ($($tokens)*) ), )* - ( () ($($tokens2)*) ), - } - }; - - // match if/else chains lacking a final `else` - ( - if #[cfg($($i_met:meta),*)] { $($i_tokens:tt)* } - $( - else if #[cfg($($e_met:meta),*)] { $($e_tokens:tt)* } - )* - ) => { - $crate::cfg_if! { - @__items - () ; - ( ($($i_met),*) ($($i_tokens)*) ), - $( ( ($($e_met),*) ($($e_tokens)*) ), )* - ( () () ), - } - }; - - // Internal and recursive macro to emit all the items - // - // Collects all the negated cfgs in a list at the beginning and after the - // semicolon is all the remaining items - (@__items ($($not:meta,)*) ; ) => {}; - (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($tokens:tt)*) ), $($rest:tt)*) => { - // Emit all items within one block, applying an appropriate #[cfg]. The - // #[cfg] will require all `$m` matchers specified and must also negate - // all previous matchers. - #[cfg(all($($m,)* not(any($($not),*))))] $crate::cfg_if! { @__identity $($tokens)* } - - // Recurse to emit all other items in `$rest`, and when we do so add all - // our `$m` matchers to the list of `$not` matchers as future emissions - // will have to negate everything we just matched as well. - $crate::cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* } - }; - - // Internal macro to make __apply work out right for different match types, - // because of how macros matching/expand stuff. - (@__identity $($tokens:tt)*) => { - $($tokens)* - }; -} - -#[cfg(test)] -mod tests { - cfg_if! { - if #[cfg(test)] { - use core::option::Option as Option2; - fn works1() -> Option2 { Some(1) } - } else { - fn works1() -> Option { None } - } - } - - cfg_if! { - if #[cfg(foo)] { - fn works2() -> bool { false } - } else if #[cfg(test)] { - fn works2() -> bool { true } - } else { - fn works2() -> bool { false } - } - } - - cfg_if! { - if #[cfg(foo)] { - fn works3() -> bool { false } - } else { - fn works3() -> bool { true } - } - } - - cfg_if! { - if #[cfg(test)] { - use core::option::Option as Option3; - fn works4() -> Option3 { Some(1) } - } - } - - cfg_if! { - if #[cfg(foo)] { - fn works5() -> bool { false } - } else if #[cfg(test)] { - fn works5() -> bool { true } - } - } - - #[test] - fn it_works() { - assert!(works1().is_some()); - assert!(works2()); - assert!(works3()); - assert!(works4().is_some()); - assert!(works5()); - } - - #[test] - #[allow(clippy::assertions_on_constants)] - fn test_usage_within_a_function() { - cfg_if! {if #[cfg(debug_assertions)] { - // we want to put more than one thing here to make sure that they - // all get configured properly. - assert!(cfg!(debug_assertions)); - assert_eq!(4, 2+2); - } else { - assert!(works1().is_some()); - assert_eq!(10, 5+5); - }} - } - - trait Trait { - fn blah(&self); - } - - #[allow(dead_code)] - struct Struct; - - impl Trait for Struct { - cfg_if! { - if #[cfg(feature = "blah")] { - fn blah(&self) { - unimplemented!(); - } - } else { - fn blah(&self) { - unimplemented!(); - } - } - } - } -} diff -Nru cargo-0.58.0/vendor/cfg-if-0.1.10/tests/xcrate.rs cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/tests/xcrate.rs --- cargo-0.58.0/vendor/cfg-if-0.1.10/tests/xcrate.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/cfg-if-0.1.10/tests/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -cfg_if::cfg_if! { - if #[cfg(foo)] { - fn works() -> bool { false } - } else if #[cfg(test)] { - fn works() -> bool { true } - } else { - fn works() -> bool { false } - } -} - -#[test] -fn smoke() { - assert!(works()); -} diff -Nru cargo-0.58.0/vendor/clap/Cargo.toml cargo-0.60.0ubuntu1/vendor/clap/Cargo.toml --- cargo-0.58.0/vendor/clap/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/clap/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -64,8 +64,12 @@ [dependencies.bitflags] version = "1.0" +[dependencies.clippy] +version = "~0.0.166" +optional = true + [dependencies.strsim] -version = ">= 0.7, < 0.10" +version = "0.8" optional = true [dependencies.term_size] @@ -83,7 +87,7 @@ optional = true [dependencies.yaml-rust] -version = ">= 0.3.5, < 0.5" +version = "0.3.5" optional = true [dev-dependencies.lazy_static] version = "1.3" @@ -106,7 +110,7 @@ wrap_help = ["term_size", "textwrap/term_size"] yaml = ["yaml-rust"] [target."cfg(not(windows))".dependencies.ansi_term] -version = ">= 0.11, < 0.13" +version = "0.12" optional = true [badges.appveyor] repository = "clap-rs/clap" diff -Nru cargo-0.58.0/vendor/clap/debian/patches/disable-criterion.patch cargo-0.60.0ubuntu1/vendor/clap/debian/patches/disable-criterion.patch --- cargo-0.58.0/vendor/clap/debian/patches/disable-criterion.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/clap/debian/patches/disable-criterion.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,85 @@ +--- clap.orig/benches/01_default.rs ++++ clap/benches/01_default.rs +@@ -1 +1 @@ +-use clap::Command; ++/*use clap::Command; +@@ -15 +15,5 @@ +-criterion_main!(benches); ++criterion_main!(benches);*/ ++ ++fn main() { ++ println!("this bench is disabled because clap is not in Debian"); ++} +--- clap.orig/benches/02_simple.rs ++++ clap/benches/02_simple.rs +@@ -1 +1 @@ +-use clap::{arg, Arg, Command}; ++/*use clap::{arg, Arg, Command}; +@@ -104 +104,5 @@ +-criterion_main!(benches); ++criterion_main!(benches);*/ ++ ++fn main() { ++ println!("this bench is disabled because clap is not in Debian"); ++} +--- clap.orig/benches/03_complex.rs ++++ clap/benches/03_complex.rs +@@ -1 +1 @@ +-use clap::{arg, Arg, Command}; ++/*use clap::{arg, Arg, Command}; +@@ -307 +307,5 @@ +-criterion_main!(benches); ++criterion_main!(benches);*/ ++ ++fn main() { ++ println!("this bench is disabled because clap is not in Debian"); ++} +--- clap.orig/benches/04_new_help.rs ++++ clap/benches/04_new_help.rs +@@ -1 +1 @@ +-use clap::Command; ++/*use clap::Command; +@@ -223 +223,5 @@ +-criterion_main!(benches); ++criterion_main!(benches);*/ ++ ++fn main() { ++ println!("this bench is disabled because clap is not in Debian"); ++} +--- clap.orig/benches/05_ripgrep.rs ++++ clap/benches/05_ripgrep.rs +@@ -5,3 +5,3 @@ + +-use clap::{Arg, Command}; ++/*use clap::{Arg, Command}; + use criterion::{criterion_group, criterion_main, Criterion}; +@@ -951,2 +951,6 @@ + ); +-criterion_main!(benches); ++criterion_main!(benches);*/ ++ ++fn main() { ++ println!("this bench is disabled because clap is not in Debian"); ++} +--- clap.orig/benches/06_rustup.rs ++++ clap/benches/06_rustup.rs +@@ -4,3 +4,3 @@ + +-use clap::{AppSettings, Arg, ArgGroup, Command}; ++/*use clap::{AppSettings, Arg, ArgGroup, Command}; + use criterion::{criterion_group, criterion_main, Criterion}; +@@ -411,2 +411,6 @@ + +-criterion_main!(benches); ++criterion_main!(benches);*/ ++ ++fn main() { ++ println!("this bench is disabled because clap is not in Debian"); ++} +--- clap.orig/Cargo.toml ++++ clap/Cargo.toml +@@ -391,4 +391,2 @@ + optional = true +-[dev-dependencies.criterion] +-version = "0.3.2" + diff -Nru cargo-0.58.0/vendor/clap/debian/patches/disable-trycmd.diff cargo-0.60.0ubuntu1/vendor/clap/debian/patches/disable-trycmd.diff --- cargo-0.58.0/vendor/clap/debian/patches/disable-trycmd.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/clap/debian/patches/disable-trycmd.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,16 @@ +Index: clap/Cargo.toml +=================================================================== +--- clap.orig/Cargo.toml ++++ clap/Cargo.toml +@@ -402,11 +402,6 @@ version = "1" + [dev-dependencies.trybuild] + version = "1.0.18" + +-[dev-dependencies.trycmd] +-version = "0.12" +-features = ["color-auto", "diff", "examples"] +-default-features = false +- + [features] + cargo = ["lazy_static"] + color = ["atty", "termcolor"] diff -Nru cargo-0.58.0/vendor/clap/debian/patches/no-clippy.patch cargo-0.60.0ubuntu1/vendor/clap/debian/patches/no-clippy.patch --- cargo-0.58.0/vendor/clap/debian/patches/no-clippy.patch 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/clap/debian/patches/no-clippy.patch 2022-04-20 13:48:09.000000000 +0000 @@ -1,13 +0,0 @@ ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -64,10 +64,6 @@ - [dependencies.bitflags] - version = "1.0" - --[dependencies.clippy] --version = "~0.0.166" --optional = true -- - [dependencies.strsim] - version = "0.8" - optional = true diff -Nru cargo-0.58.0/vendor/clap/debian/patches/relax-dep-versions.patch cargo-0.60.0ubuntu1/vendor/clap/debian/patches/relax-dep-versions.patch --- cargo-0.58.0/vendor/clap/debian/patches/relax-dep-versions.patch 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/clap/debian/patches/relax-dep-versions.patch 2022-04-20 13:48:09.000000000 +0000 @@ -1,29 +1,22 @@ ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -65,7 +65,7 @@ - version = "1.0" - - [dependencies.strsim] --version = "0.8" -+version = ">= 0.7, < 0.10" +Index: clap/Cargo.toml +=================================================================== +--- clap.orig/Cargo.toml ++++ clap/Cargo.toml +@@ -352,7 +352,7 @@ version = "3.1.4" optional = true - [dependencies.term_size] -@@ -83,7 +83,7 @@ - optional = true + [dependencies.indexmap] +-version = "1.0" ++version = "1" - [dependencies.yaml-rust] --version = "0.3.5" -+version = ">= 0.3.5, < 0.5" + [dependencies.lazy_static] + version = "1" +@@ -366,7 +366,7 @@ version = "1.0" optional = true - [dev-dependencies.lazy_static] - version = "1.3" -@@ -106,7 +106,7 @@ - wrap_help = ["term_size", "textwrap/term_size"] - yaml = ["yaml-rust"] - [target."cfg(not(windows))".dependencies.ansi_term] --version = "0.12" -+version = ">= 0.11, < 0.13" + + [dependencies.strsim] +-version = "0.10" ++version = "0.9" optional = true - [badges.appveyor] - repository = "clap-rs/clap" + + [dependencies.termcolor] diff -Nru cargo-0.58.0/vendor/clap/debian/patches/series cargo-0.60.0ubuntu1/vendor/clap/debian/patches/series --- cargo-0.58.0/vendor/clap/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/clap/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -1,2 +1 @@ no-clippy.patch -relax-dep-versions.patch diff -Nru cargo-0.58.0/vendor/core-foundation/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/core-foundation/.cargo-checksum.json --- cargo-0.58.0/vendor/core-foundation/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/core-foundation/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3"} \ No newline at end of file +{"files":{},"package":"194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/core-foundation/Cargo.toml cargo-0.60.0ubuntu1/vendor/core-foundation/Cargo.toml --- cargo-0.58.0/vendor/core-foundation/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/core-foundation/Cargo.toml 2022-04-20 13:48:09.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 = "core-foundation" -version = "0.9.2" +version = "0.9.3" authors = ["The Servo Project Developers"] description = "Bindings to Core Foundation for macOS" homepage = "https://github.com/servo/core-foundation-rs" @@ -27,7 +26,7 @@ optional = true [dependencies.core-foundation-sys] -version = "0.8.0" +version = "0.8.3" [dependencies.libc] version = "0.2" diff -Nru cargo-0.58.0/vendor/core-foundation/src/filedescriptor.rs cargo-0.60.0ubuntu1/vendor/core-foundation/src/filedescriptor.rs --- cargo-0.58.0/vendor/core-foundation/src/filedescriptor.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/core-foundation/src/filedescriptor.rs 2022-04-20 13:48:09.000000000 +0000 @@ -114,22 +114,6 @@ use runloop::{CFRunLoop}; #[test] - fn test_consumed() { - let path = CString::new("/dev/null").unwrap(); - let raw_fd = unsafe { libc::open(path.as_ptr(), O_RDWR, 0) }; - let cf_fd = CFFileDescriptor::new(raw_fd, true, never_callback, None); - assert!(cf_fd.is_some()); - let cf_fd = cf_fd.unwrap(); - - assert!(cf_fd.valid()); - cf_fd.invalidate(); - assert!(!cf_fd.valid()); - - // close() should fail - assert_eq!(unsafe { libc::close(raw_fd) }, -1); - } - - #[test] fn test_unconsumed() { let path = CString::new("/dev/null").unwrap(); let raw_fd = unsafe { libc::open(path.as_ptr(), O_RDWR, 0) }; diff -Nru cargo-0.58.0/vendor/core-foundation/src/runloop.rs cargo-0.60.0ubuntu1/vendor/core-foundation/src/runloop.rs --- cargo-0.58.0/vendor/core-foundation/src/runloop.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/core-foundation/src/runloop.rs 2022-04-20 13:48:09.000000000 +0000 @@ -26,6 +26,14 @@ impl_TCFType!(CFRunLoop, CFRunLoopRef, CFRunLoopGetTypeID); impl_CFTypeDescription!(CFRunLoop); +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum CFRunLoopRunResult { + Finished = 1, + Stopped = 2, + TimedOut = 3, + HandledSource = 4, +} + impl CFRunLoop { pub fn get_current() -> CFRunLoop { unsafe { @@ -47,6 +55,24 @@ } } + pub fn run_in_mode( + mode: CFStringRef, + duration: std::time::Duration, + return_after_source_handled: bool, + ) -> CFRunLoopRunResult { + let seconds = duration.as_secs_f64(); + let return_after_source_handled = if return_after_source_handled { 1 } else { 0 }; + + unsafe { + match CFRunLoopRunInMode(mode, seconds, return_after_source_handled) { + 2 => CFRunLoopRunResult::Stopped, + 3 => CFRunLoopRunResult::TimedOut, + 4 => CFRunLoopRunResult::HandledSource, + _ => CFRunLoopRunResult::Finished, + } + } + } + pub fn stop(&self) { unsafe { CFRunLoopStop(self.0); diff -Nru cargo-0.58.0/vendor/crc32fast/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/crc32fast/.cargo-checksum.json --- cargo-0.58.0/vendor/crc32fast/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crc32fast/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836"} \ No newline at end of file +{"files":{},"package":"b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/crc32fast/Cargo.toml cargo-0.60.0ubuntu1/vendor/crc32fast/Cargo.toml --- cargo-0.58.0/vendor/crc32fast/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crc32fast/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -11,7 +11,7 @@ [package] name = "crc32fast" -version = "1.3.0" +version = "1.3.2" authors = ["Sam Rijs ", "Alex Crichton "] description = "Fast, SIMD-accelerated CRC32 (IEEE) checksum computation" readme = "README.md" diff -Nru cargo-0.58.0/vendor/crc32fast/src/specialized/aarch64.rs cargo-0.60.0ubuntu1/vendor/crc32fast/src/specialized/aarch64.rs --- cargo-0.58.0/vendor/crc32fast/src/specialized/aarch64.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crc32fast/src/specialized/aarch64.rs 2022-04-20 13:48:09.000000000 +0000 @@ -7,7 +7,7 @@ impl State { pub fn new(state: u32) -> Option { - if is_aarch64_feature_detected!("crc") { + if std::arch::is_aarch64_feature_detected!("crc") { // SAFETY: The conditions above ensure that all // required instructions are supported by the CPU. Some(Self { state }) diff -Nru cargo-0.58.0/vendor/crc32fast/src/table.rs cargo-0.60.0ubuntu1/vendor/crc32fast/src/table.rs --- cargo-0.58.0/vendor/crc32fast/src/table.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crc32fast/src/table.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,4 +1,7 @@ -pub const CRC32_TABLE: [[u32; 256]; 16] = [ +// NOTE: This is static instead of const to ensure that indexing into this table +// doesn't result in large memmoves when in debug mode, which can significantly +// impact performance. +pub static CRC32_TABLE: [[u32; 256]; 16] = [ [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, diff -Nru cargo-0.58.0/vendor/crossbeam-utils/build.rs cargo-0.60.0ubuntu1/vendor/crossbeam-utils/build.rs --- cargo-0.58.0/vendor/crossbeam-utils/build.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,9 +1,3 @@ -#![warn(rust_2018_idioms)] - -use std::env; - -include!("no_atomic.rs"); - // The rustc-cfg listed below are considered public API, but it is *unstable* // and outside of the normal semver guarantees: // @@ -25,10 +19,15 @@ // 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. +// With the exceptions mentioned above, the rustc-cfg emitted by the build +// script are *not* public API. + +#![warn(rust_2018_idioms)] + +use std::env; + +include!("no_atomic.rs"); + fn main() { let target = match env::var("TARGET") { Ok(target) => target, @@ -55,7 +54,7 @@ } else if NO_ATOMIC_64.contains(&&*target) { println!("cargo:rustc-cfg=crossbeam_no_atomic_64"); } else { - // Otherwise, assuming `"max-atomic-width" == 64`. + // Otherwise, assuming `"max-atomic-width" == 64` or `"max-atomic-width" == 128`. } println!("cargo:rerun-if-changed=no_atomic.rs"); diff -Nru cargo-0.58.0/vendor/crossbeam-utils/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/crossbeam-utils/.cargo-checksum.json --- cargo-0.58.0/vendor/crossbeam-utils/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120"} \ No newline at end of file +{"files":{},"package":"0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/crossbeam-utils/Cargo.toml cargo-0.60.0ubuntu1/vendor/crossbeam-utils/Cargo.toml --- cargo-0.58.0/vendor/crossbeam-utils/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -13,19 +13,31 @@ edition = "2018" rust-version = "1.36" name = "crossbeam-utils" -version = "0.8.6" +version = "0.8.8" description = "Utilities for concurrent programming" homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-utils" -keywords = ["scoped", "thread", "atomic", "cache"] -categories = ["algorithms", "concurrency", "data-structures", "no-std"] +keywords = [ + "scoped", + "thread", + "atomic", + "cache", +] +categories = [ + "algorithms", + "concurrency", + "data-structures", + "no-std", +] license = "MIT OR Apache-2.0" repository = "https://github.com/crossbeam-rs/crossbeam" + [dependencies.cfg-if] version = "1" [dependencies.lazy_static] version = "1.4.0" optional = true + [dev-dependencies.rand] version = ">= 0.7, < 0.9" @@ -36,6 +48,7 @@ default = ["std"] nightly = [] std = ["lazy_static"] -[target."cfg(crossbeam_loom)".dependencies.loom] -version = "0.5" -optional = true + +#[target."cfg(crossbeam_loom)".dependencies.loom] +#version = "0.5" +#optional = true diff -Nru cargo-0.58.0/vendor/crossbeam-utils/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/crossbeam-utils/CHANGELOG.md --- cargo-0.58.0/vendor/crossbeam-utils/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/CHANGELOG.md 2022-04-20 13:48:09.000000000 +0000 @@ -1,23 +1,43 @@ +# Version 0.8.8 + +- Fix a bug when unstable `loom` support is enabled. (#787) + +# Version 0.8.7 + +- Add `AtomicCell<{i*,u*}>::{fetch_max,fetch_min}`. (#785) +- Add `AtomicCell<{i*,u*,bool}>::fetch_nand`. (#785) +- Fix unsoundness of `AtomicCell<{i,u}64>` arithmetics on 32-bit targets that support `Atomic{I,U}64` (#781) + # Version 0.8.6 +**Note**: This release has been yanked. See [#781](https://github.com/crossbeam-rs/crossbeam/issues/781) for details. + - 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 +**Note**: This release has been yanked. See [#781](https://github.com/crossbeam-rs/crossbeam/issues/781) for details. + - Add `AtomicCell::fetch_update`. (#704) - Support targets that do not have atomic CAS on stable Rust. (#698) # Version 0.8.4 +**Note**: This release has been yanked. See [#781](https://github.com/crossbeam-rs/crossbeam/issues/781) for details. + - Bump `loom` dependency to version 0.5. (#686) # Version 0.8.3 +**Note**: This release has been yanked. See [#781](https://github.com/crossbeam-rs/crossbeam/issues/781) for details. + - Make `loom` dependency optional. (#666) # Version 0.8.2 +**Note**: This release has been yanked. See [#781](https://github.com/crossbeam-rs/crossbeam/issues/781) for details. + - Deprecate `AtomicCell::compare_and_swap`. Use `AtomicCell::compare_exchange` instead. (#619) - Add `Parker::park_deadline`. (#563) - Improve implementation of `CachePadded`. (#636) @@ -25,6 +45,8 @@ # Version 0.8.1 +**Note**: This release has been yanked. See [#781](https://github.com/crossbeam-rs/crossbeam/issues/781) for details. + - Make `AtomicCell::is_lock_free` always const fn. (#600) - Fix a bug in `seq_lock_wide`. (#596) - Remove `const_fn` dependency. (#600) @@ -32,6 +54,8 @@ # Version 0.8.0 +**Note**: This release has been yanked. See [#781](https://github.com/crossbeam-rs/crossbeam/issues/781) for details. + - Bump the minimum supported Rust version to 1.36. - Remove deprecated `AtomicCell::get_mut()` and `Backoff::is_complete()` methods. - Remove `alloc` feature. diff -Nru cargo-0.58.0/vendor/crossbeam-utils/debian/patches/disable-loom.diff cargo-0.60.0ubuntu1/vendor/crossbeam-utils/debian/patches/disable-loom.diff --- cargo-0.58.0/vendor/crossbeam-utils/debian/patches/disable-loom.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/debian/patches/disable-loom.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,14 @@ +Index: crossbeam-utils/Cargo.toml +=================================================================== +--- crossbeam-utils.orig/Cargo.toml ++++ crossbeam-utils/Cargo.toml +@@ -35,6 +35,6 @@ version = ">= 0.7, < 0.9" + nightly = [] + std = ["lazy_static"] + +-[target."cfg(crossbeam_loom)".dependencies.loom] +-version = "0.5" +-optional = true ++#[target."cfg(crossbeam_loom)".dependencies.loom] ++#version = "0.5" ++#optional = true diff -Nru cargo-0.58.0/vendor/crossbeam-utils/debian/patches/disable-loom.diff.orig cargo-0.60.0ubuntu1/vendor/crossbeam-utils/debian/patches/disable-loom.diff.orig --- cargo-0.58.0/vendor/crossbeam-utils/debian/patches/disable-loom.diff.orig 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/debian/patches/disable-loom.diff.orig 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,14 @@ +Index: crossbeam-utils/Cargo.toml +=================================================================== +--- crossbeam-utils.orig/Cargo.toml ++++ crossbeam-utils/Cargo.toml +@@ -35,6 +35,6 @@ version = ">= 0.7, < 0.9" + default = ["std"] + nightly = [] + std = ["lazy_static"] +-[target."cfg(crossbeam_loom)".dependencies.loom] +-version = "0.5" +-optional = true ++#[target."cfg(crossbeam_loom)".dependencies.loom] ++#version = "0.5" ++#optional = true diff -Nru cargo-0.58.0/vendor/crossbeam-utils/debian/patches/series cargo-0.60.0ubuntu1/vendor/crossbeam-utils/debian/patches/series --- cargo-0.58.0/vendor/crossbeam-utils/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1,2 @@ relax-dep.diff +disable-loom.diff diff -Nru cargo-0.58.0/vendor/crossbeam-utils/no_atomic.rs cargo-0.60.0ubuntu1/vendor/crossbeam-utils/no_atomic.rs --- cargo-0.58.0/vendor/crossbeam-utils/no_atomic.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/no_atomic.rs 2022-04-20 13:48:09.000000000 +0000 @@ -7,11 +7,13 @@ "bpfel-unknown-none", "msp430-none-elf", "riscv32i-unknown-none-elf", + "riscv32im-unknown-none-elf", "riscv32imc-unknown-none-elf", "thumbv4t-none-eabi", "thumbv6m-none-eabi", ]; -#[allow(dead_code)] + +#[allow(dead_code)] // Only crossbeam-utils uses this. const NO_ATOMIC_64: &[&str] = &[ "arm-linux-androideabi", "armebv7r-none-eabi", @@ -20,19 +22,23 @@ "armv5te-unknown-linux-gnueabi", "armv5te-unknown-linux-musleabi", "armv5te-unknown-linux-uclibceabi", + "armv6k-nintendo-3ds", "armv7r-none-eabi", "armv7r-none-eabihf", + "avr-unknown-gnu-atmega328", "hexagon-unknown-linux-musl", "m68k-unknown-linux-gnu", "mips-unknown-linux-gnu", "mips-unknown-linux-musl", "mips-unknown-linux-uclibc", + "mipsel-sony-psp", "mipsel-unknown-linux-gnu", "mipsel-unknown-linux-musl", "mipsel-unknown-linux-uclibc", "mipsel-unknown-none", "mipsisa32r6-unknown-linux-gnu", "mipsisa32r6el-unknown-linux-gnu", + "msp430-none-elf", "powerpc-unknown-freebsd", "powerpc-unknown-linux-gnu", "powerpc-unknown-linux-gnuspe", @@ -43,23 +49,25 @@ "powerpc-wrs-vxworks-spe", "riscv32gc-unknown-linux-gnu", "riscv32gc-unknown-linux-musl", + "riscv32i-unknown-none-elf", + "riscv32im-unknown-none-elf", "riscv32imac-unknown-none-elf", - "riscv32imc-esp-espidf", + "riscv32imc-unknown-none-elf", + "thumbv4t-none-eabi", + "thumbv6m-none-eabi", "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", ]; -#[allow(dead_code)] + +#[allow(dead_code)] // Only crossbeam-utils uses this. const NO_ATOMIC: &[&str] = &[ "avr-unknown-gnu-atmega328", "msp430-none-elf", "riscv32i-unknown-none-elf", + "riscv32im-unknown-none-elf", "riscv32imc-unknown-none-elf", ]; diff -Nru cargo-0.58.0/vendor/crossbeam-utils/src/atomic/atomic_cell.rs cargo-0.60.0ubuntu1/vendor/crossbeam-utils/src/atomic/atomic_cell.rs --- cargo-0.58.0/vendor/crossbeam-utils/src/atomic/atomic_cell.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/src/atomic/atomic_cell.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,20 +1,18 @@ // Necessary for implementing atomic methods for `AtomicUnit` #![allow(clippy::unit_arg)] -#![allow(clippy::let_unit_value)] use crate::primitive::sync::atomic::{self, AtomicBool}; use core::cell::UnsafeCell; +use core::cmp; use core::fmt; use core::mem; use core::sync::atomic::Ordering; -#[cfg(not(crossbeam_loom))] use core::ptr; #[cfg(feature = "std")] use std::panic::{RefUnwindSafe, UnwindSafe}; -#[cfg(not(crossbeam_loom))] use super::seq_lock::SeqLock; /// A thread-safe mutable memory location. @@ -313,19 +311,11 @@ /// ``` #[inline] pub fn fetch_add(&self, val: $t) -> $t { - #[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; - *value = value.wrapping_add(val); - old - } + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = value.wrapping_add(val); + old } /// Decrements the current value by `val` and returns the previous value. @@ -344,19 +334,11 @@ /// ``` #[inline] pub fn fetch_sub(&self, val: $t) -> $t { - #[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; - *value = value.wrapping_sub(val); - old - } + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = value.wrapping_sub(val); + old } /// Applies bitwise "and" to the current value and returns the previous value. @@ -373,19 +355,32 @@ /// ``` #[inline] pub fn fetch_and(&self, val: $t) -> $t { - #[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; - *value &= val; - old - } + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value &= val; + old + } + + /// Applies bitwise "nand" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_nand(3), 7); + /// assert_eq!(a.load(), !(7 & 3)); + /// ``` + #[inline] + pub fn fetch_nand(&self, val: $t) -> $t { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = !(old & val); + old } /// Applies bitwise "or" to the current value and returns the previous value. @@ -402,19 +397,11 @@ /// ``` #[inline] pub fn fetch_or(&self, val: $t) -> $t { - #[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; - *value |= val; - old - } + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value |= val; + old } /// Applies bitwise "xor" to the current value and returns the previous value. @@ -431,19 +418,55 @@ /// ``` #[inline] pub fn fetch_xor(&self, val: $t) -> $t { - #[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; - *value ^= val; - old - } + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value ^= val; + old + } + + /// Compares and sets the maximum of the current value and `val`, + /// and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_max(2), 7); + /// assert_eq!(a.load(), 7); + /// ``` + #[inline] + pub fn fetch_max(&self, val: $t) -> $t { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = cmp::max(old, val); + old + } + + /// Compares and sets the minimum of the current value and `val`, + /// and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_min(2), 7); + /// assert_eq!(a.load(), 2); + /// ``` + #[inline] + pub fn fetch_min(&self, val: $t) -> $t { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = cmp::min(old, val); + old } } }; @@ -465,8 +488,16 @@ /// ``` #[inline] pub fn fetch_add(&self, val: $t) -> $t { - let a = unsafe { &*(self.value.get() as *const $atomic) }; - a.fetch_add(val, Ordering::AcqRel) + if can_transmute::<$t, $atomic>() { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_add(val, Ordering::AcqRel) + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = value.wrapping_add(val); + old + } } /// Decrements the current value by `val` and returns the previous value. @@ -485,8 +516,16 @@ /// ``` #[inline] pub fn fetch_sub(&self, val: $t) -> $t { - let a = unsafe { &*(self.value.get() as *const $atomic) }; - a.fetch_sub(val, Ordering::AcqRel) + if can_transmute::<$t, $atomic>() { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_sub(val, Ordering::AcqRel) + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = value.wrapping_sub(val); + old + } } /// Applies bitwise "and" to the current value and returns the previous value. @@ -503,8 +542,42 @@ /// ``` #[inline] pub fn fetch_and(&self, val: $t) -> $t { - let a = unsafe { &*(self.value.get() as *const $atomic) }; - a.fetch_and(val, Ordering::AcqRel) + if can_transmute::<$t, $atomic>() { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_and(val, Ordering::AcqRel) + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value &= val; + old + } + } + + /// Applies bitwise "nand" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_nand(3), 7); + /// assert_eq!(a.load(), !(7 & 3)); + /// ``` + #[inline] + pub fn fetch_nand(&self, val: $t) -> $t { + if can_transmute::<$t, $atomic>() { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_nand(val, Ordering::AcqRel) + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = !(old & val); + old + } } /// Applies bitwise "or" to the current value and returns the previous value. @@ -521,8 +594,16 @@ /// ``` #[inline] pub fn fetch_or(&self, val: $t) -> $t { - let a = unsafe { &*(self.value.get() as *const $atomic) }; - a.fetch_or(val, Ordering::AcqRel) + if can_transmute::<$t, $atomic>() { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_or(val, Ordering::AcqRel) + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value |= val; + old + } } /// Applies bitwise "xor" to the current value and returns the previous value. @@ -539,8 +620,70 @@ /// ``` #[inline] pub fn fetch_xor(&self, val: $t) -> $t { - let a = unsafe { &*(self.value.get() as *const $atomic) }; - a.fetch_xor(val, Ordering::AcqRel) + if can_transmute::<$t, $atomic>() { + let a = unsafe { &*(self.value.get() as *const $atomic) }; + a.fetch_xor(val, Ordering::AcqRel) + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value ^= val; + old + } + } + + /// Compares and sets the maximum of the current value and `val`, + /// and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_max(9), 7); + /// assert_eq!(a.load(), 9); + /// ``` + #[inline] + pub fn fetch_max(&self, val: $t) -> $t { + if can_transmute::<$t, $atomic>() { + // TODO: Atomic*::fetch_max requires Rust 1.45. + self.fetch_update(|old| Some(cmp::max(old, val))).unwrap() + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = cmp::max(old, val); + old + } + } + + /// Compares and sets the minimum of the current value and `val`, + /// and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + #[doc = $example] + /// + /// assert_eq!(a.fetch_min(2), 7); + /// assert_eq!(a.load(), 2); + /// ``` + #[inline] + pub fn fetch_min(&self, val: $t) -> $t { + if can_transmute::<$t, $atomic>() { + // TODO: Atomic*::fetch_min requires Rust 1.45. + self.fetch_update(|old| Some(cmp::min(old, val))).unwrap() + } else { + let _guard = lock(self.value.get() as usize).write(); + let value = unsafe { &mut *(self.value.get()) }; + let old = *value; + *value = cmp::min(old, val); + old + } } } }; @@ -599,6 +742,30 @@ a.fetch_and(val, Ordering::AcqRel) } + /// Applies logical "nand" to the current value and returns the previous value. + /// + /// # Examples + /// + /// ``` + /// use crossbeam_utils::atomic::AtomicCell; + /// + /// let a = AtomicCell::new(true); + /// + /// assert_eq!(a.fetch_nand(false), true); + /// assert_eq!(a.load(), true); + /// + /// assert_eq!(a.fetch_nand(true), true); + /// assert_eq!(a.load(), false); + /// + /// assert_eq!(a.fetch_nand(false), false); + /// assert_eq!(a.load(), true); + /// ``` + #[inline] + pub fn fetch_nand(&self, val: bool) -> bool { + let a = unsafe { &*(self.value.get() as *const AtomicBool) }; + a.fetch_nand(val, Ordering::AcqRel) + } + /// Applies logical "or" to the current value and returns the previous value. /// /// # Examples @@ -679,7 +846,6 @@ /// scalability. #[inline] #[must_use] -#[cfg(not(crossbeam_loom))] fn lock(addr: usize) -> &'static SeqLock { // The number of locks is a prime number because we want to make sure `addr % LEN` gets // dispersed across all locks. @@ -733,7 +899,6 @@ #[inline] fn swap(&self, _val: (), _order: Ordering) {} - #[allow(clippy::unnecessary_wraps)] // This is intentional. #[inline] fn compare_exchange_weak( &self, @@ -771,9 +936,6 @@ // TODO: AtomicU128 is unstable // atomic!(@check, $t, atomic::AtomicU128, $a, $atomic_op); - #[cfg(crossbeam_loom)] - unimplemented!("loom does not support non-atomic atomic ops"); - #[cfg(not(crossbeam_loom))] break $fallback_op; } }; diff -Nru cargo-0.58.0/vendor/crossbeam-utils/src/atomic/mod.rs cargo-0.60.0ubuntu1/vendor/crossbeam-utils/src/atomic/mod.rs --- cargo-0.58.0/vendor/crossbeam-utils/src/atomic/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/src/atomic/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -24,9 +24,14 @@ } #[cfg(not(crossbeam_no_atomic_cas))] +// We cannot provide AtomicCell under cfg(crossbeam_loom) because loom's atomic +// types have a different in-memory representation than the underlying type. +// TODO: The latest loom supports fences, so fallback using seqlock may be available. +#[cfg(not(crossbeam_loom))] mod atomic_cell; mod consume; #[cfg(not(crossbeam_no_atomic_cas))] +#[cfg(not(crossbeam_loom))] pub use self::atomic_cell::AtomicCell; pub use self::consume::AtomicConsume; diff -Nru cargo-0.58.0/vendor/crossbeam-utils/tests/atomic_cell.rs cargo-0.60.0ubuntu1/vendor/crossbeam-utils/tests/atomic_cell.rs --- cargo-0.58.0/vendor/crossbeam-utils/tests/atomic_cell.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/crossbeam-utils/tests/atomic_cell.rs 2022-04-20 13:48:09.000000000 +0000 @@ -265,6 +265,50 @@ assert_eq!(CELL.load(), 1); } +// https://github.com/crossbeam-rs/crossbeam/pull/767 +macro_rules! test_arithmetic { + ($test_name:ident, $ty:ident) => { + #[test] + fn $test_name() { + let a: AtomicCell<$ty> = AtomicCell::new(7); + + assert_eq!(a.fetch_add(3), 7); + assert_eq!(a.load(), 10); + + assert_eq!(a.fetch_sub(3), 10); + assert_eq!(a.load(), 7); + + assert_eq!(a.fetch_and(3), 7); + assert_eq!(a.load(), 3); + + assert_eq!(a.fetch_or(16), 3); + assert_eq!(a.load(), 19); + + assert_eq!(a.fetch_xor(2), 19); + assert_eq!(a.load(), 17); + + assert_eq!(a.fetch_max(18), 17); + assert_eq!(a.load(), 18); + + assert_eq!(a.fetch_min(17), 18); + assert_eq!(a.load(), 17); + + assert_eq!(a.fetch_nand(7), 17); + assert_eq!(a.load(), !(17 & 7)); + } + }; +} +test_arithmetic!(arithmetic_u8, u8); +test_arithmetic!(arithmetic_i8, i8); +test_arithmetic!(arithmetic_u16, u16); +test_arithmetic!(arithmetic_i16, i16); +test_arithmetic!(arithmetic_u32, u32); +test_arithmetic!(arithmetic_i32, i32); +test_arithmetic!(arithmetic_u64, u64); +test_arithmetic!(arithmetic_i64, i64); +test_arithmetic!(arithmetic_u128, u128); +test_arithmetic!(arithmetic_i128, i128); + // https://github.com/crossbeam-rs/crossbeam/issues/748 #[cfg_attr(miri, ignore)] // TODO #[rustversion::since(1.37)] // #[repr(align(N))] requires Rust 1.37 @@ -279,7 +323,10 @@ } assert_eq!(mem::size_of::(), 8); - assert!(AtomicCell::::is_lock_free()); + assert_eq!( + AtomicCell::::is_lock_free(), + cfg!(not(crossbeam_no_atomic_64)) + ); let x = AtomicCell::new(Test::FieldLess); assert_eq!(x.load(), Test::FieldLess); } diff -Nru cargo-0.58.0/vendor/curl/build.rs cargo-0.60.0ubuntu1/vendor/curl/build.rs --- cargo-0.58.0/vendor/curl/build.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,13 +1,12 @@ use std::env; -use std::str::FromStr; fn main() { // OpenSSL >= 1.1.0 can be initialized concurrently and is initialized correctly by libcurl. // <= 1.0.2 need locking callbacks, which are provided by openssl_sys::init(). - let use_openssl = match env::var("DEP_OPENSSL_VERSION") { - Ok(ver) => { - let ver = u32::from_str(&ver).unwrap(); - if ver < 110 { + let use_openssl = match env::var("DEP_OPENSSL_VERSION_NUMBER") { + Ok(version) => { + let version = u64::from_str_radix(&version, 16).unwrap(); + if version < 0x1_01_00_00_0 { println!("cargo:rustc-cfg=need_openssl_init"); } true diff -Nru cargo-0.58.0/vendor/curl/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/curl/.cargo-checksum.json --- cargo-0.58.0/vendor/curl/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"aaa3b8db7f3341ddef15786d250106334d4a6c4b0ae4a46cd77082777d9849b9"} \ No newline at end of file +{"files":{},"package":"37d855aeef205b43f65a5001e0997d81f8efca7badad4fad7d897aa7f0d0651f"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/curl/Cargo.lock cargo-0.60.0ubuntu1/vendor/curl/Cargo.lock --- cargo-0.58.0/vendor/curl/Cargo.lock 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -3,30 +3,10 @@ version = 3 [[package]] -name = "aho-corasick" -version = "0.7.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" -dependencies = [ - "memchr", -] - -[[package]] name = "anyhow" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0df63cb2955042487fad3aefd2c6e3ae7389ac5dc1beb28921de0b69f779d4" - -[[package]] -name = "atty" -version = "0.2.14" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi 0.3.9", -] +checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" [[package]] name = "autocfg" @@ -36,36 +16,27 @@ [[package]] name = "base64" -version = "0.10.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -dependencies = [ - "byteorder", -] +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bumpalo" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" - -[[package]] -name = "byteorder" -version = "1.3.4" +version = "3.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" [[package]] name = "cc" -version = "1.0.66" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" [[package]] name = "cfg-if" @@ -80,26 +51,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] name = "cmake" -version = "0.1.45" +version = "0.1.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" +checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" dependencies = [ "cc", ] [[package]] name = "curl" -version = "0.4.39" +version = "0.4.43" dependencies = [ "anyhow", "curl-sys", @@ -115,45 +77,22 @@ [[package]] name = "curl-sys" -version = "0.4.49+curl-7.79.1" +version = "0.4.53+curl-7.82.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0f44960aea24a786a46907b8824ebc0e66ca06bf4e4978408c7499620343483" +checksum = "8092905a5a9502c312f223b2775f57ec5c5b715f9a15ee9d2a8591d1364a0352" dependencies = [ "cc", "libc", "libnghttp2-sys", "libz-sys", - "mesalink", "openssl-sys", "pkg-config", + "rustls-ffi", "vcpkg", "winapi 0.3.9", ] [[package]] -name = "enum_to_u8_slice_derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8479a225129affae259452fd418b67af025ac86f60663a893baa407bc9897f43" -dependencies = [ - "quote 0.3.15", - "syn 0.11.11", -] - -[[package]] -name = "env_logger" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - -[[package]] name = "fuchsia-zircon" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -170,24 +109,6 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] -name = "hermit-abi" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" -dependencies = [ - "libc", -] - -[[package]] -name = "humantime" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -dependencies = [ - "quick-error", -] - -[[package]] name = "iovec" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -198,9 +119,9 @@ [[package]] name = "js-sys" -version = "0.3.46" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" dependencies = [ "wasm-bindgen", ] @@ -229,15 +150,15 @@ [[package]] name = "libc" -version = "0.2.92" +version = "0.2.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" [[package]] name = "libnghttp2-sys" -version = "0.1.6+1.43.0" +version = "0.1.7+1.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0af55541a8827e138d59ec9e5877fb6095ece63fb6f4da45e7491b4fbd262855" +checksum = "57ed28aba195b38d5ff02b9170cbff627e336a20925e43b4945390401c5dc93f" dependencies = [ "cc", "libc", @@ -245,9 +166,9 @@ [[package]] name = "libz-sys" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" +checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" dependencies = [ "cc", "cmake", @@ -257,55 +178,12 @@ ] [[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] - -[[package]] name = "log" -version = "0.4.11" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 0.1.10", -] - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memchr" -version = "2.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" - -[[package]] -name = "mesalink" -version = "1.1.0-cratesio" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05616fdd96cc48e233f660ce28e936950163b21f28bde25649acf55de411970a" -dependencies = [ - "base64", - "bitflags", - "enum_to_u8_slice_derive", - "env_logger", - "lazy_static", - "libc", - "parking_lot", - "ring", - "rustls", - "sct", - "untrusted", - "walkdir", - "webpki", - "webpki-roots", + "cfg-if 1.0.0", ] [[package]] @@ -353,9 +231,9 @@ [[package]] name = "net2" -version = "0.2.36" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7cf75f38f16cb05ea017784dc6dbfd354f76c223dba37701734c4f5a9337d02" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ "cfg-if 0.1.10", "libc", @@ -363,31 +241,52 @@ ] [[package]] +name = "num_enum" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "720d3ea1055e4e4574c0c0b0f8c3fd4f24c4cdaf465948206dea090b57b526ad" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d992b768490d7fe0d8586d9b5745f6c49f557da6d81dc982b1d167ad4edbb21" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "once_cell" -version = "1.5.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] name = "openssl-probe" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" +checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" [[package]] name = "openssl-src" -version = "111.12.0+1.1.1h" +version = "111.17.0+1.1.1m" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "858a4132194f8570a7ee9eb8629e85b23cbc4565f2d4a162e87556e5956abf61" +checksum = "05d6a336abd10814198f66e2a91ccd7336611f30334119ca8ce300536666fcf4" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.58" +version = "0.9.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" +checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" dependencies = [ "autocfg", "cc", @@ -398,96 +297,44 @@ ] [[package]] -name = "parking_lot" -version = "0.9.0" +name = "pkg-config" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api", - "parking_lot_core", - "rustc_version", -] +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" [[package]] -name = "parking_lot_core" -version = "0.6.2" +name = "proc-macro-crate" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall", - "rustc_version", - "smallvec", - "winapi 0.3.9", + "thiserror", + "toml", ] [[package]] -name = "pkg-config" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" - -[[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ - "unicode-xid 0.2.1", + "unicode-xid", ] [[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] name = "quote" -version = "0.3.15" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" - -[[package]] -name = "quote" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" dependencies = [ "proc-macro2", ] [[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "regex" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-syntax" -version = "0.6.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" - -[[package]] name = "ring" -version = "0.16.19" +version = "0.16.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "024a1e66fea74c66c66624ee5622a7ff0e4b73a13b4f5c326ddb50c708944226" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ "cc", "libc", @@ -499,34 +346,39 @@ ] [[package]] -name = "rustc_version" -version = "0.2.3" +name = "rustls" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84" dependencies = [ - "semver", + "log", + "ring", + "sct", + "webpki", ] [[package]] -name = "rustls" -version = "0.16.0" +name = "rustls-ffi" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e" +checksum = "9da52707cca59e6eef8a78f3ad8d04024254a168ed1b41eb4dfa9616eace781a" dependencies = [ - "base64", + "libc", "log", - "ring", + "num_enum", + "rustls", + "rustls-pemfile", "sct", "webpki", ] [[package]] -name = "same-file" -version = "1.0.6" +name = "rustls-pemfile" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" dependencies = [ - "winapi-util", + "base64", ] [[package]] @@ -540,56 +392,32 @@ ] [[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] name = "sct" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ "ring", "untrusted", ] [[package]] -name = "semver" -version = "0.9.0" +name = "serde" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" [[package]] name = "slab" -version = "0.4.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "socket2" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" dependencies = [ "libc", "winapi 0.3.9", @@ -603,64 +431,49 @@ [[package]] name = "syn" -version = "0.11.11" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -dependencies = [ - "quote 0.3.15", - "synom", - "unicode-xid 0.0.4", -] - -[[package]] -name = "syn" -version = "1.0.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" +checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" dependencies = [ "proc-macro2", - "quote 1.0.7", - "unicode-xid 0.2.1", + "quote", + "unicode-xid", ] [[package]] -name = "synom" -version = "0.11.3" +name = "thiserror" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ - "unicode-xid 0.0.4", + "thiserror-impl", ] [[package]] -name = "termcolor" -version = "1.1.2" +name = "thiserror-impl" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" dependencies = [ - "winapi-util", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "thread_local" -version = "1.0.1" +name = "toml" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ - "lazy_static", + "serde", ] [[package]] name = "unicode-xid" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" - -[[package]] -name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "untrusted" @@ -670,26 +483,15 @@ [[package]] name = "vcpkg" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" - -[[package]] -name = "walkdir" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" -dependencies = [ - "same-file", - "winapi 0.3.9", - "winapi-util", -] +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "wasm-bindgen" -version = "0.2.69" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -697,53 +499,53 @@ [[package]] name = "wasm-bindgen-backend" -version = "0.2.69" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" dependencies = [ "bumpalo", "lazy_static", "log", "proc-macro2", - "quote 1.0.7", - "syn 1.0.54", + "quote", + "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.69" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ - "quote 1.0.7", + "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.69" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ "proc-macro2", - "quote 1.0.7", - "syn 1.0.54", + "quote", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.69" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" [[package]] name = "web-sys" -version = "0.3.46" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" dependencies = [ "js-sys", "wasm-bindgen", @@ -751,24 +553,15 @@ [[package]] name = "webpki" -version = "0.21.4" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" dependencies = [ "ring", "untrusted", ] [[package]] -name = "webpki-roots" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a262ae37dd9d60f60dd473d1158f9fbebf110ba7b6a5051c8160460f6043718b" -dependencies = [ - "webpki", -] - -[[package]] name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -797,15 +590,6 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi 0.3.9", -] - -[[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff -Nru cargo-0.58.0/vendor/curl/Cargo.toml cargo-0.60.0ubuntu1/vendor/curl/Cargo.toml --- cargo-0.58.0/vendor/curl/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "curl" -version = "0.4.39" +version = "0.4.43" authors = ["Alex Crichton "] autotests = true description = "Rust bindings to libcurl for making HTTP requests" @@ -24,6 +24,10 @@ repository = "https://github.com/alexcrichton/curl-rust" [[example]] +name = "https" +path = "examples/https.rs" + +[[example]] name = "ssl_proxy" path = "examples/ssl_proxy.rs" required-features = ["ssl"] @@ -38,11 +42,16 @@ path = "examples/aws_sigv4.rs" required-features = ["static-curl", "ssl"] +[[example]] +name = "multi-dl" +path = "examples/multi-dl.rs" +required-features = ["ssl"] + [[test]] name = "atexit" harness = false [dependencies.curl-sys] -version = "0.4.49" +version = "0.4.53" default-features = false [dependencies.libc] @@ -63,6 +72,7 @@ default = ["ssl"] force-system-lib-on-osx = ["curl-sys/force-system-lib-on-osx"] http2 = ["curl-sys/http2"] +rustls = ["curl-sys/rustls"] ssl = ["openssl-sys", "openssl-probe", "curl-sys/ssl"] static-curl = ["curl-sys/static-curl"] static-ssl = ["curl-sys/static-ssl"] diff -Nru cargo-0.58.0/vendor/curl/ci/run.sh cargo-0.60.0ubuntu1/vendor/curl/ci/run.sh --- cargo-0.58.0/vendor/curl/ci/run.sh 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/ci/run.sh 2022-04-20 13:48:09.000000000 +0000 @@ -5,8 +5,10 @@ cargo test --target $TARGET --no-run # First test with no extra protocols enabled. cargo test --target $TARGET --no-run --features static-curl +# Then with rustls TLS backend. +cargo test --target $TARGET --no-run --features rustls,static-curl # Then with all extra protocols enabled. -cargo test --target $TARGET --no-run --features static-curl,protocol-ftp +cargo test --target $TARGET --no-run --features static-curl,protocol-ftp,ntlm if [ -z "$NO_RUN" ]; then cargo test --target $TARGET cargo test --target $TARGET --features static-curl diff -Nru cargo-0.58.0/vendor/curl/debian/patches/disable-features.patch cargo-0.60.0ubuntu1/vendor/curl/debian/patches/disable-features.patch --- cargo-0.58.0/vendor/curl/debian/patches/disable-features.patch 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/debian/patches/disable-features.patch 2022-04-20 13:48:09.000000000 +0000 @@ -2,11 +2,14 @@ --- a/Cargo.toml +++ b/Cargo.toml -@@ -63,13 +63,9 @@ +@@ -63,16 +63,10 @@ default = ["ssl"] force-system-lib-on-osx = ["curl-sys/force-system-lib-on-osx"] http2 = ["curl-sys/http2"] +-ntlm = ["curl-sys/ntlm"] +-poll_7_68_0 = ["curl-sys/poll_7_68_0"] -protocol-ftp = ["curl-sys/protocol-ftp"] + rustls = ["curl-sys/rustls"] -spnego = ["curl-sys/spnego"] ssl = ["openssl-sys", "openssl-probe", "curl-sys/ssl"] static-curl = ["curl-sys/static-curl"] diff -Nru cargo-0.58.0/vendor/curl/debian/patches/disable-features.patch.orig cargo-0.60.0ubuntu1/vendor/curl/debian/patches/disable-features.patch.orig --- cargo-0.58.0/vendor/curl/debian/patches/disable-features.patch.orig 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/debian/patches/disable-features.patch.orig 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,18 @@ +Description: for now, disable some features to avoid NEW trip + +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -63,13 +63,9 @@ + default = ["ssl"] + force-system-lib-on-osx = ["curl-sys/force-system-lib-on-osx"] + http2 = ["curl-sys/http2"] +-protocol-ftp = ["curl-sys/protocol-ftp"] +-spnego = ["curl-sys/spnego"] + ssl = ["openssl-sys", "openssl-probe", "curl-sys/ssl"] + static-curl = ["curl-sys/static-curl"] + static-ssl = ["curl-sys/static-ssl"] +-upkeep_7_62_0 = ["curl-sys/upkeep_7_62_0"] +-zlib-ng-compat = ["curl-sys/zlib-ng-compat", "static-curl"] + [target."cfg(all(unix, not(target_os = \"macos\")))".dependencies.openssl-probe] + version = "0.1.2" + optional = true diff -Nru cargo-0.58.0/vendor/curl/debian/patches/disable-mesalink.patch cargo-0.60.0ubuntu1/vendor/curl/debian/patches/disable-mesalink.patch --- cargo-0.58.0/vendor/curl/debian/patches/disable-mesalink.patch 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/debian/patches/disable-mesalink.patch 2022-04-20 13:48:09.000000000 +0000 @@ -6,6 +6,6 @@ force-system-lib-on-osx = ["curl-sys/force-system-lib-on-osx"] http2 = ["curl-sys/http2"] -mesalink = ["curl-sys/mesalink"] + ntlm = ["curl-sys/ntlm"] + poll_7_68_0 = ["curl-sys/poll_7_68_0"] protocol-ftp = ["curl-sys/protocol-ftp"] - spnego = ["curl-sys/spnego"] - ssl = ["openssl-sys", "openssl-probe", "curl-sys/ssl"] diff -Nru cargo-0.58.0/vendor/curl/debian/patches/disable-mesalink.patch.orig cargo-0.60.0ubuntu1/vendor/curl/debian/patches/disable-mesalink.patch.orig --- cargo-0.58.0/vendor/curl/debian/patches/disable-mesalink.patch.orig 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/debian/patches/disable-mesalink.patch.orig 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,11 @@ +Description: for now, disable mesalink as it has some extra deps +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -44,7 +44,6 @@ + default = ["ssl"] + force-system-lib-on-osx = ["curl-sys/force-system-lib-on-osx"] + http2 = ["curl-sys/http2"] +-mesalink = ["curl-sys/mesalink"] + protocol-ftp = ["curl-sys/protocol-ftp"] + spnego = ["curl-sys/spnego"] + ssl = ["openssl-sys", "openssl-probe", "curl-sys/ssl"] diff -Nru cargo-0.58.0/vendor/curl/examples/doh.rs cargo-0.60.0ubuntu1/vendor/curl/examples/doh.rs --- cargo-0.58.0/vendor/curl/examples/doh.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/examples/doh.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,17 @@ +use curl::easy::Easy; +use std::io::{stdout, Write}; + +fn main() -> Result<(), curl::Error> { + let mut curl = Easy::new(); + + curl.url("https://example.com")?; + curl.doh_url(Some("https://cloudflare-dns.com/dns-query"))?; + curl.write_function(|data| { + stdout().write_all(data).unwrap(); + Ok(data.len()) + })?; + + curl.perform()?; + + Ok(()) +} diff -Nru cargo-0.58.0/vendor/curl/examples/https.rs cargo-0.60.0ubuntu1/vendor/curl/examples/https.rs --- cargo-0.58.0/vendor/curl/examples/https.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/examples/https.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,23 @@ +//! Simple HTTPS GET +//! +//! This example is a Rust adaptation of the [C example of the same +//! name](https://curl.se/libcurl/c/https.html). + +extern crate curl; + +use curl::easy::Easy; +use std::io::{stdout, Write}; + +fn main() -> Result<(), curl::Error> { + let mut curl = Easy::new(); + + curl.url("https://example.com/")?; + curl.write_function(|data| { + stdout().write_all(data).unwrap(); + Ok(data.len()) + })?; + + curl.perform()?; + + Ok(()) +} diff -Nru cargo-0.58.0/vendor/curl/examples/multi-dl.rs cargo-0.60.0ubuntu1/vendor/curl/examples/multi-dl.rs --- cargo-0.58.0/vendor/curl/examples/multi-dl.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/examples/multi-dl.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,88 @@ +use std::collections::HashMap; +use std::time::Duration; + +use anyhow::Result; + +use curl::easy::{Easy2, Handler, WriteError}; +use curl::multi::{Easy2Handle, Multi}; + +const URLS: &[&str] = &[ + "https://www.microsoft.com", + "https://www.google.com", + "https://www.amazon.com", + "https://www.apple.com", +]; + +struct Collector(Vec); +impl Handler for Collector { + fn write(&mut self, data: &[u8]) -> Result { + self.0.extend_from_slice(data); + Ok(data.len()) + } +} + +fn download(multi: &mut Multi, token: usize, url: &str) -> Result> { + let version = curl::Version::get(); + let mut request = Easy2::new(Collector(Vec::new())); + request.url(&url)?; + request.useragent(&format!("curl/{}", version.version()))?; + + let mut handle = multi.add2(request)?; + handle.set_token(token)?; + Ok(handle) +} + +fn main() -> Result<()> { + let mut multi = Multi::new(); + let mut handles = URLS + .iter() + .enumerate() + .map(|(token, url)| Ok((token, download(&mut multi, token, url)?))) + .collect::>>()?; + + let mut still_alive = true; + while still_alive { + // We still need to process the last messages when + // `Multi::perform` returns "0". + if multi.perform()? == 0 { + still_alive = false; + } + + multi.messages(|message| { + let token = message.token().expect("failed to get the token"); + let handle = handles + .get_mut(&token) + .expect("the download value should exist in the HashMap"); + + match message + .result_for2(&handle) + .expect("token mismatch with the `EasyHandle`") + { + Ok(()) => { + let http_status = handle + .response_code() + .expect("HTTP request finished without status code"); + + println!( + "R: Transfer succeeded (Status: {}) {} (Download length: {})", + http_status, + URLS[token], + handle.get_ref().0.len() + ); + } + Err(error) => { + println!("E: {} - <{}>", error, URLS[token]); + } + } + }); + + if still_alive { + // The sleeping time could be reduced to allow other processing. + // For instance, a thread could check a condition signalling the + // thread shutdown. + multi.wait(&mut [], Duration::from_secs(60))?; + } + } + + Ok(()) +} diff -Nru cargo-0.58.0/vendor/curl/examples/ssl_proxy.rs cargo-0.60.0ubuntu1/vendor/curl/examples/ssl_proxy.rs --- cargo-0.58.0/vendor/curl/examples/ssl_proxy.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/examples/ssl_proxy.rs 2022-04-20 13:48:09.000000000 +0000 @@ -16,9 +16,9 @@ handle.proxy(proxy_url)?; handle.proxy_port(proxy_port)?; - handle.proxy_cainfo(&cainfo)?; - handle.proxy_sslcert(&sslcert)?; - handle.proxy_sslkey(&sslkey)?; + handle.proxy_cainfo(cainfo)?; + handle.proxy_sslcert(sslcert)?; + handle.proxy_sslkey(sslkey)?; println!("ssl proxy setup done"); handle.perform()?; diff -Nru cargo-0.58.0/vendor/curl/README.md cargo-0.60.0ubuntu1/vendor/curl/README.md --- cargo-0.58.0/vendor/curl/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -123,12 +123,16 @@ with various Cargo features: - `ssl`: Enable SSL/TLS support using the platform-default TLS backend. On Windows this is [Schannel], on macOS [Secure Transport], and [OpenSSL] (or equivalent) on all other platforms. Enabled by default. -- `mesalink`: Enable SSL/TLS support via [MesaLink], an alternative TLS backend written in Rust based on [Rustls]. MesaLink is always statically linked. Disabled by default. +- `rustls` Enable SSL/TLS support via [Rustls], a well-received alternative TLS backend written in Rust. Rustls is always statically linked. Disabled by default. + + Note that Rustls support is experimental within Curl itself and may have significant bugs, so we don't offer any sort of stability guarantee with this feature. - `http2`: Enable HTTP/2 support via libnghttp2. Disabled by default. - `static-curl`: Use a bundled libcurl version and statically link to it. Disabled by default. - `static-ssl`: Use a bundled OpenSSL version and statically link to it. Only applies on platforms that use OpenSSL. Disabled by default. - `spnego`: Enable SPNEGO support. Disabled by default. - `upkeep_7_62_0`: Enable curl_easy_upkeep() support, introduced in curl 7.62.0. Disabled by default. +- `poll_7_68_0`: Enable curl_multi_poll()/curl_multi_wakeup() support, requires curl 7.68.0 or later. Disabled by default. +- `ntlm`: Enable NTLM support in curl. Disabled by default. ## Version Support @@ -164,7 +168,6 @@ [libcurl]: https://curl.haxx.se/libcurl/ -[MesaLink]: https://mesalink.io/ [OpenSSL]: https://www.openssl.org/ [Rustls]: https://github.com/ctz/rustls [Schannel]: https://docs.microsoft.com/en-us/windows/win32/com/schannel diff -Nru cargo-0.58.0/vendor/curl/src/easy/handler.rs cargo-0.60.0ubuntu1/vendor/curl/src/easy/handler.rs --- cargo-0.58.0/vendor/curl/src/easy/handler.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/src/easy/handler.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1049,6 +1049,123 @@ self.setopt_long(curl_sys::CURLOPT_DNS_CACHE_TIMEOUT, dur.as_secs() as c_long) } + /// Provide the DNS-over-HTTPS URL. + /// + /// The parameter must be URL-encoded in the following format: + /// `https://host:port/path`. It **must** specify a HTTPS URL. + /// + /// libcurl does not validate the syntax or use this variable until the + /// transfer is issued. Even if you set a crazy value here, this method will + /// still return [`Ok`]. + /// + /// curl sends `POST` requests to the given DNS-over-HTTPS URL. + /// + /// To find the DoH server itself, which might be specified using a name, + /// libcurl will use the default name lookup function. You can bootstrap + /// that by providing the address for the DoH server with + /// [`Easy2::resolve`]. + /// + /// Disable DoH use again by setting this option to [`None`]. + /// + /// By default this option is not set and corresponds to `CURLOPT_DOH_URL`. + pub fn doh_url(&mut self, url: Option<&str>) -> Result<(), Error> { + if let Some(url) = url { + let url = CString::new(url)?; + self.setopt_str(curl_sys::CURLOPT_DOH_URL, &url) + } else { + self.setopt_ptr(curl_sys::CURLOPT_DOH_URL, ptr::null()) + } + } + + /// This option tells curl to verify the authenticity of the DoH + /// (DNS-over-HTTPS) server's certificate. A value of `true` means curl + /// verifies; `false` means it does not. + /// + /// This option is the DoH equivalent of [`Easy2::ssl_verify_peer`] and only + /// affects requests to the DoH server. + /// + /// When negotiating a TLS or SSL connection, the server sends a certificate + /// indicating its identity. Curl verifies whether the certificate is + /// authentic, i.e. that you can trust that the server is who the + /// certificate says it is. This trust is based on a chain of digital + /// signatures, rooted in certification authority (CA) certificates you + /// supply. curl uses a default bundle of CA certificates (the path for that + /// is determined at build time) and you can specify alternate certificates + /// with the [`Easy2::cainfo`] option or the [`Easy2::capath`] option. + /// + /// When `doh_ssl_verify_peer` is enabled, and the verification fails to + /// prove that the certificate is authentic, the connection fails. When the + /// option is zero, the peer certificate verification succeeds regardless. + /// + /// Authenticating the certificate is not enough to be sure about the + /// server. You typically also want to ensure that the server is the server + /// you mean to be talking to. Use [`Easy2::doh_ssl_verify_host`] for that. + /// The check that the host name in the certificate is valid for the host + /// name you are connecting to is done independently of the + /// `doh_ssl_verify_peer` option. + /// + /// **WARNING:** disabling verification of the certificate allows bad guys + /// to man-in-the-middle the communication without you knowing it. Disabling + /// verification makes the communication insecure. Just having encryption on + /// a transfer is not enough as you cannot be sure that you are + /// communicating with the correct end-point. + /// + /// By default this option is set to `true` and corresponds to + /// `CURLOPT_DOH_SSL_VERIFYPEER`. + pub fn doh_ssl_verify_peer(&mut self, verify: bool) -> Result<(), Error> { + self.setopt_long(curl_sys::CURLOPT_DOH_SSL_VERIFYPEER, verify.into()) + } + + /// Tells curl to verify the DoH (DNS-over-HTTPS) server's certificate name + /// fields against the host name. + /// + /// This option is the DoH equivalent of [`Easy2::ssl_verify_host`] and only + /// affects requests to the DoH server. + /// + /// When `doh_ssl_verify_host` is `true`, the SSL certificate provided by + /// the DoH server must indicate that the server name is the same as the + /// server name to which you meant to connect to, or the connection fails. + /// + /// Curl considers the DoH server the intended one when the Common Name + /// field or a Subject Alternate Name field in the certificate matches the + /// host name in the DoH URL to which you told Curl to connect. + /// + /// When the verify value is set to `false`, the connection succeeds + /// regardless of the names used in the certificate. Use that ability with + /// caution! + /// + /// See also [`Easy2::doh_ssl_verify_peer`] to verify the digital signature + /// of the DoH server certificate. If libcurl is built against NSS and + /// [`Easy2::doh_ssl_verify_peer`] is `false`, `doh_ssl_verify_host` is also + /// set to `false` and cannot be overridden. + /// + /// By default this option is set to `true` and corresponds to + /// `CURLOPT_DOH_SSL_VERIFYHOST`. + pub fn doh_ssl_verify_host(&mut self, verify: bool) -> Result<(), Error> { + self.setopt_long( + curl_sys::CURLOPT_DOH_SSL_VERIFYHOST, + if verify { 2 } else { 0 }, + ) + } + + /// Pass a long as parameter set to 1 to enable or 0 to disable. + /// + /// This option determines whether libcurl verifies the status of the DoH + /// (DNS-over-HTTPS) server cert using the "Certificate Status Request" TLS + /// extension (aka. OCSP stapling). + /// + /// This option is the DoH equivalent of CURLOPT_SSL_VERIFYSTATUS and only + /// affects requests to the DoH server. + /// + /// Note that if this option is enabled but the server does not support the + /// TLS extension, the verification will fail. + /// + /// By default this option is set to `false` and corresponds to + /// `CURLOPT_DOH_SSL_VERIFYSTATUS`. + pub fn doh_ssl_verify_status(&mut self, verify: bool) -> Result<(), Error> { + self.setopt_long(curl_sys::CURLOPT_DOH_SSL_VERIFYSTATUS, verify.into()) + } + /// Specify the preferred receive buffer size, in bytes. /// /// This is treated as a request, not an order, and the main point of this @@ -1343,7 +1460,7 @@ /// `CURLOPT_POSTFIELDSIZE_LARGE`. pub fn post_field_size(&mut self, size: u64) -> Result<(), Error> { // Clear anything previous to ensure we don't read past a buffer - self.setopt_ptr(curl_sys::CURLOPT_POSTFIELDS, 0 as *const _)?; + self.setopt_ptr(curl_sys::CURLOPT_POSTFIELDS, ptr::null())?; self.setopt_off_t( curl_sys::CURLOPT_POSTFIELDSIZE_LARGE, size as curl_sys::curl_off_t, @@ -1738,7 +1855,7 @@ pub fn timeout(&mut self, timeout: Duration) -> Result<(), Error> { // TODO: checked arithmetic and casts // TODO: use CURLOPT_TIMEOUT if the timeout is too great - let ms = timeout.as_secs() * 1000 + (timeout.subsec_nanos() / 1_000_000) as u64; + let ms = timeout.as_secs() * 1000 + timeout.subsec_millis() as u64; self.setopt_long(curl_sys::CURLOPT_TIMEOUT_MS, ms as c_long) } @@ -1860,7 +1977,7 @@ /// By default this value is 300 seconds and corresponds to /// `CURLOPT_CONNECTTIMEOUT_MS`. pub fn connect_timeout(&mut self, timeout: Duration) -> Result<(), Error> { - let ms = timeout.as_secs() * 1000 + (timeout.subsec_nanos() / 1_000_000) as u64; + let ms = timeout.as_secs() * 1000 + timeout.subsec_millis() as u64; self.setopt_long(curl_sys::CURLOPT_CONNECTTIMEOUT_MS, ms as c_long) } @@ -2073,6 +2190,18 @@ self.setopt_str(curl_sys::CURLOPT_KEYPASSWD, &password) } + /// Set the SSL Certificate Authorities using an in-memory blob. + /// + /// The specified byte buffer should contain the binary content of one + /// or more PEM-encoded CA certificates, which will be copied into + /// the handle. + /// + /// By default this option is not set and corresponds to + /// `CURLOPT_CAINFO_BLOB`. + pub fn ssl_cainfo_blob(&mut self, blob: &[u8]) -> Result<(), Error> { + self.setopt_blob(curl_sys::CURLOPT_CAINFO_BLOB, blob) + } + /// Set the SSL engine identifier. /// /// This will be used as the identifier for the crypto engine you want to @@ -2411,7 +2540,7 @@ /// By default this option is not set and corresponds to /// `CURLOPT_EXPECT_100_TIMEOUT_MS`. pub fn expect_100_timeout(&mut self, timeout: Duration) -> Result<(), Error> { - let ms = timeout.as_secs() * 1000 + (timeout.subsec_nanos() / 1_000_000) as u64; + let ms = timeout.as_secs() * 1000 + timeout.subsec_millis() as u64; self.setopt_long(curl_sys::CURLOPT_EXPECT_100_TIMEOUT_MS, ms as c_long) } @@ -2422,15 +2551,8 @@ //// This corresponds to `CURLINFO_CONDITION_UNMET` and may return an error if the /// option is not supported pub fn time_condition_unmet(&mut self) -> Result { - self.getopt_long(curl_sys::CURLINFO_CONDITION_UNMET).map( - |r| { - if r == 0 { - false - } else { - true - } - }, - ) + self.getopt_long(curl_sys::CURLINFO_CONDITION_UNMET) + .map(|r| r != 0) } /// Get the last used URL @@ -2894,7 +3016,7 @@ /// URL encodes a string `s` pub fn url_encode(&mut self, s: &[u8]) -> String { - if s.len() == 0 { + if s.is_empty() { return String::new(); } unsafe { @@ -2913,7 +3035,7 @@ /// URL decodes a string `s`, returning `None` if it fails pub fn url_decode(&mut self, s: &str) -> Vec { - if s.len() == 0 { + if s.is_empty() { return Vec::new(); } @@ -3078,7 +3200,7 @@ fn getopt_ptr(&mut self, opt: curl_sys::CURLINFO) -> Result<*const c_char, Error> { unsafe { - let mut p = 0 as *const c_char; + let mut p = ptr::null(); let rc = curl_sys::curl_easy_getinfo(self.inner.handle, opt, &mut p); self.cvt(rc)?; Ok(p) diff -Nru cargo-0.58.0/vendor/curl/src/easy/handle.rs cargo-0.60.0ubuntu1/vendor/curl/src/easy/handle.rs --- cargo-0.58.0/vendor/curl/src/easy/handle.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/src/easy/handle.rs 2022-04-20 13:48:09.000000000 +0000 @@ -648,6 +648,26 @@ self.inner.dns_cache_timeout(dur) } + /// Same as [`Easy2::doh_url`](struct.Easy2.html#method.doh_url) + pub fn doh_url(&mut self, url: Option<&str>) -> Result<(), Error> { + self.inner.doh_url(url) + } + + /// Same as [`Easy2::doh_ssl_verify_peer`](struct.Easy2.html#method.doh_ssl_verify_peer) + pub fn doh_ssl_verify_peer(&mut self, verify: bool) -> Result<(), Error> { + self.inner.doh_ssl_verify_peer(verify) + } + + /// Same as [`Easy2::doh_ssl_verify_host`](struct.Easy2.html#method.doh_ssl_verify_host) + pub fn doh_ssl_verify_host(&mut self, verify: bool) -> Result<(), Error> { + self.inner.doh_ssl_verify_host(verify) + } + + /// Same as [`Easy2::doh_ssl_verify_status`](struct.Easy2.html#method.doh_ssl_verify_status) + pub fn doh_ssl_verify_status(&mut self, verify: bool) -> Result<(), Error> { + self.inner.doh_ssl_verify_status(verify) + } + /// Same as [`Easy2::buffer_size`](struct.Easy2.html#method.buffer_size) pub fn buffer_size(&mut self, size: usize) -> Result<(), Error> { self.inner.buffer_size(size) @@ -1003,6 +1023,11 @@ self.inner.key_password(password) } + /// Same as [`Easy2::ssl_cainfo_blob`](struct.Easy2.html#method.ssl_cainfo_blob) + pub fn ssl_cainfo_blob(&mut self, blob: &[u8]) -> Result<(), Error> { + self.inner.ssl_cainfo_blob(blob) + } + /// Same as [`Easy2::ssl_engine`](struct.Easy2.html#method.ssl_engine) pub fn ssl_engine(&mut self, engine: &str) -> Result<(), Error> { self.inner.ssl_engine(engine) diff -Nru cargo-0.58.0/vendor/curl/src/error.rs cargo-0.60.0ubuntu1/vendor/curl/src/error.rs --- cargo-0.58.0/vendor/curl/src/error.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/src/error.rs 2022-04-20 13:48:09.000000000 +0000 @@ -4,8 +4,6 @@ use std::io; use std::str; -use curl_sys; - /// An error returned from various "easy" operations. /// /// This structure wraps a `CURLcode`. diff -Nru cargo-0.58.0/vendor/curl/src/lib.rs cargo-0.60.0ubuntu1/vendor/curl/src/lib.rs --- cargo-0.58.0/vendor/curl/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -70,6 +70,9 @@ pub mod multi; mod panic; +#[cfg(test)] +static INITIALIZED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); + /// Initializes the underlying libcurl library. /// /// The underlying libcurl library must be initialized before use, and must be @@ -90,46 +93,62 @@ /// Used to prevent concurrent or duplicate initialization. static INIT: Once = Once::new(); - /// An exported constructor function. On supported platforms, this will be - /// invoked automatically before the program's `main` is called. - #[cfg_attr( - any(target_os = "linux", target_os = "freebsd", target_os = "android"), - link_section = ".init_array" - )] - #[cfg_attr(target_os = "macos", link_section = "__DATA,__mod_init_func")] - #[cfg_attr(target_os = "windows", link_section = ".CRT$XCU")] - static INIT_CTOR: extern "C" fn() = init_inner; + INIT.call_once(|| { + #[cfg(need_openssl_init)] + openssl_probe::init_ssl_cert_env_vars(); + #[cfg(need_openssl_init)] + openssl_sys::init(); + + unsafe { + assert_eq!(curl_sys::curl_global_init(curl_sys::CURL_GLOBAL_ALL), 0); + } + + #[cfg(test)] + { + INITIALIZED.store(true, std::sync::atomic::Ordering::SeqCst); + } + + // Note that we explicitly don't schedule a call to + // `curl_global_cleanup`. The documentation for that function says + // + // > You must not call it when any other thread in the program (i.e. a + // > thread sharing the same memory) is running. This doesn't just mean + // > no other thread that is using libcurl. + // + // We can't ever be sure of that, so unfortunately we can't call the + // function. + }); +} +/// An exported constructor function. On supported platforms, this will be +/// invoked automatically before the program's `main` is called. This is done +/// for the convenience of library users since otherwise the thread-safety rules +/// around initialization can be difficult to fulfill. +/// +/// This is a hidden public item to ensure the symbol isn't optimized away by a +/// rustc/LLVM bug: https://github.com/rust-lang/rust/issues/47384. As long as +/// any item in this module is used by the final binary (which `init` will be) +/// then this symbol should be preserved. +#[used] +#[doc(hidden)] +#[cfg_attr( + any(target_os = "linux", target_os = "freebsd", target_os = "android"), + link_section = ".init_array" +)] +#[cfg_attr(target_os = "macos", link_section = "__DATA,__mod_init_func")] +#[cfg_attr(target_os = "windows", link_section = ".CRT$XCU")] +pub static INIT_CTOR: extern "C" fn() = { /// This is the body of our constructor function. #[cfg_attr( any(target_os = "linux", target_os = "android"), link_section = ".text.startup" )] - extern "C" fn init_inner() { - INIT.call_once(|| { - #[cfg(need_openssl_init)] - openssl_sys::init(); - - unsafe { - assert_eq!(curl_sys::curl_global_init(curl_sys::CURL_GLOBAL_ALL), 0); - } - - // Note that we explicitly don't schedule a call to - // `curl_global_cleanup`. The documentation for that function says - // - // > You must not call it when any other thread in the program (i.e. - // > a thread sharing the same memory) is running. This doesn't just - // > mean no other thread that is using libcurl. - // - // We can't ever be sure of that, so unfortunately we can't call the - // function. - }); + extern "C" fn init_ctor() { + init(); } - // We invoke our init function through our static to ensure the symbol isn't - // optimized away by a bug: https://github.com/rust-lang/rust/issues/47384 - INIT_CTOR(); -} + init_ctor +}; unsafe fn opt_str<'a>(ptr: *const libc::c_char) -> Option<&'a str> { if ptr.is_null() { @@ -146,3 +165,20 @@ Err(Error::new(r)) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + #[cfg(any( + target_os = "linux", + target_os = "macos", + target_os = "windows", + target_os = "freebsd", + target_os = "android" + ))] + fn is_initialized_before_main() { + assert!(INITIALIZED.load(std::sync::atomic::Ordering::SeqCst)); + } +} diff -Nru cargo-0.58.0/vendor/curl/src/multi.rs cargo-0.60.0ubuntu1/vendor/curl/src/multi.rs --- cargo-0.58.0/vendor/curl/src/multi.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/src/multi.rs 2022-04-20 13:48:09.000000000 +0000 @@ -3,6 +3,7 @@ use std::fmt; use std::marker; use std::ptr; +use std::sync::Arc; use std::time::Duration; use curl_sys; @@ -29,10 +30,15 @@ /// /// [multi tutorial]: https://curl.haxx.se/libcurl/c/libcurl-multi.html pub struct Multi { - raw: *mut curl_sys::CURLM, + raw: Arc, data: Box, } +#[derive(Debug)] +struct RawMulti { + handle: *mut curl_sys::CURLM, +} + struct MultiData { socket: Box, timer: Box) -> bool + Send>, @@ -52,6 +58,8 @@ /// be used via `perform`. This handle is also used to remove the easy handle /// from the multi handle when desired. pub struct EasyHandle { + // Safety: This *must* be before `easy` as it must be dropped first. + guard: DetachGuard, easy: Easy, // This is now effectively bound to a `Multi`, so it is no longer sendable. _marker: marker::PhantomData<&'static Multi>, @@ -63,11 +71,20 @@ /// be used via `perform`. This handle is also used to remove the easy handle /// from the multi handle when desired. pub struct Easy2Handle { + // Safety: This *must* be before `easy` as it must be dropped first. + guard: DetachGuard, easy: Easy2, // This is now effectively bound to a `Multi`, so it is no longer sendable. _marker: marker::PhantomData<&'static Multi>, } +/// A guard struct which guarantees that `curl_multi_remove_handle` will be +/// called on an easy handle, either manually or on drop. +struct DetachGuard { + multi: Arc, + easy: *mut curl_sys::CURL, +} + /// Notification of the events that have happened on a socket. /// /// This type is passed as an argument to the `action` method on a multi handle @@ -92,6 +109,20 @@ inner: curl_sys::curl_waitfd, } +/// A handle that can be used to wake up a thread that's blocked in [Multi::poll]. +/// The handle can be passed to and used from any thread. +#[cfg(feature = "poll_7_68_0")] +#[derive(Debug, Clone)] +pub struct MultiWaker { + raw: std::sync::Weak, +} + +#[cfg(feature = "poll_7_68_0")] +unsafe impl Send for MultiWaker {} + +#[cfg(feature = "poll_7_68_0")] +unsafe impl Sync for MultiWaker {} + impl Multi { /// Creates a new multi session through which multiple HTTP transfers can be /// initiated. @@ -101,7 +132,7 @@ let ptr = curl_sys::curl_multi_init(); assert!(!ptr.is_null()); Multi { - raw: ptr, + raw: Arc::new(RawMulti { handle: ptr }), data: Box::new(MultiData { socket: Box::new(|_, _, _| ()), timer: Box::new(|_| true), @@ -196,7 +227,7 @@ pub fn assign(&self, socket: Socket, token: usize) -> Result<(), MultiError> { unsafe { cvt(curl_sys::curl_multi_assign( - self.raw, + self.raw.handle, socket, token as *mut _, ))?; @@ -341,7 +372,7 @@ } fn setopt_long(&mut self, opt: curl_sys::CURLMoption, val: c_long) -> Result<(), MultiError> { - unsafe { cvt(curl_sys::curl_multi_setopt(self.raw, opt, val)) } + unsafe { cvt(curl_sys::curl_multi_setopt(self.raw.handle, opt, val)) } } fn setopt_ptr( @@ -349,7 +380,7 @@ opt: curl_sys::CURLMoption, val: *const c_char, ) -> Result<(), MultiError> { - unsafe { cvt(curl_sys::curl_multi_setopt(self.raw, opt, val)) } + unsafe { cvt(curl_sys::curl_multi_setopt(self.raw.handle, opt, val)) } } /// Add an easy handle to a multi session @@ -377,9 +408,13 @@ easy.transfer(); unsafe { - cvt(curl_sys::curl_multi_add_handle(self.raw, easy.raw()))?; + cvt(curl_sys::curl_multi_add_handle(self.raw.handle, easy.raw()))?; } Ok(EasyHandle { + guard: DetachGuard { + multi: self.raw.clone(), + easy: easy.raw(), + }, easy, _marker: marker::PhantomData, }) @@ -388,9 +423,13 @@ /// Same as `add`, but works with the `Easy2` type. pub fn add2(&self, easy: Easy2) -> Result, MultiError> { unsafe { - cvt(curl_sys::curl_multi_add_handle(self.raw, easy.raw()))?; + cvt(curl_sys::curl_multi_add_handle(self.raw.handle, easy.raw()))?; } Ok(Easy2Handle { + guard: DetachGuard { + multi: self.raw.clone(), + easy: easy.raw(), + }, easy, _marker: marker::PhantomData, }) @@ -407,24 +446,14 @@ /// Removing an easy handle while being used is perfectly legal and will /// effectively halt the transfer in progress involving that easy handle. /// All other easy handles and transfers will remain unaffected. - pub fn remove(&self, easy: EasyHandle) -> Result { - unsafe { - cvt(curl_sys::curl_multi_remove_handle( - self.raw, - easy.easy.raw(), - ))?; - } + pub fn remove(&self, mut easy: EasyHandle) -> Result { + easy.guard.detach()?; Ok(easy.easy) } /// Same as `remove`, but for `Easy2Handle`. - pub fn remove2(&self, easy: Easy2Handle) -> Result, MultiError> { - unsafe { - cvt(curl_sys::curl_multi_remove_handle( - self.raw, - easy.easy.raw(), - ))?; - } + pub fn remove2(&self, mut easy: Easy2Handle) -> Result, MultiError> { + easy.guard.detach()?; Ok(easy.easy) } @@ -445,7 +474,7 @@ let mut queue = 0; unsafe { loop { - let ptr = curl_sys::curl_multi_info_read(self.raw, &mut queue); + let ptr = curl_sys::curl_multi_info_read(self.raw.handle, &mut queue); if ptr.is_null() { break; } @@ -479,7 +508,7 @@ let mut remaining = 0; unsafe { cvt(curl_sys::curl_multi_socket_action( - self.raw, + self.raw.handle, socket, events.bits, &mut remaining, @@ -507,7 +536,7 @@ let mut remaining = 0; unsafe { cvt(curl_sys::curl_multi_socket_action( - self.raw, + self.raw.handle, curl_sys::CURL_SOCKET_BAD, 0, &mut remaining, @@ -536,7 +565,7 @@ pub fn get_timeout(&self) -> Result, MultiError> { let mut ms = 0; unsafe { - cvt(curl_sys::curl_multi_timeout(self.raw, &mut ms))?; + cvt(curl_sys::curl_multi_timeout(self.raw.handle, &mut ms))?; if ms == -1 { Ok(None) } else { @@ -571,19 +600,72 @@ /// } /// ``` pub fn wait(&self, waitfds: &mut [WaitFd], timeout: Duration) -> Result { - let timeout_ms = { - let secs = timeout.as_secs(); - if secs > (i32::max_value() / 1000) as u64 { - // Duration too large, clamp at maximum value. - i32::max_value() - } else { - secs as i32 * 1000 + timeout.subsec_nanos() as i32 / 1_000_000 - } - }; + let timeout_ms = Multi::timeout_i32(timeout); unsafe { let mut ret = 0; cvt(curl_sys::curl_multi_wait( - self.raw, + self.raw.handle, + waitfds.as_mut_ptr() as *mut _, + waitfds.len() as u32, + timeout_ms, + &mut ret, + ))?; + Ok(ret as u32) + } + } + + fn timeout_i32(timeout: Duration) -> i32 { + let secs = timeout.as_secs(); + if secs > (i32::MAX / 1000) as u64 { + // Duration too large, clamp at maximum value. + i32::MAX + } else { + secs as i32 * 1000 + timeout.subsec_nanos() as i32 / 1_000_000 + } + } + + /// Block until activity is detected or a timeout passes. + /// + /// The timeout is used in millisecond-precision. Large durations are + /// clamped at the maximum value curl accepts. + /// + /// The returned integer will contain the number of internal file + /// descriptors on which interesting events occurred. + /// + /// This function is a simpler alternative to using `fdset()` and `select()` + /// and does not suffer from file descriptor limits. + /// + /// While this method is similar to [Multi::wait], with the following + /// distinctions: + /// * If there are no handles added to the multi, poll will honor the + /// provided timeout, while [Multi::wait] returns immediately. + /// * If poll has blocked due to there being no activity on the handles in + /// the Multi, it can be woken up from any thread and at any time before + /// the timeout expires. + /// + /// Requires libcurl 7.66.0 or later. + /// + /// # Example + /// + /// ``` + /// use curl::multi::Multi; + /// use std::time::Duration; + /// + /// let m = Multi::new(); + /// + /// // Add some Easy handles... + /// + /// while m.perform().unwrap() > 0 { + /// m.poll(&mut [], Duration::from_secs(1)).unwrap(); + /// } + /// ``` + #[cfg(feature = "poll_7_68_0")] + pub fn poll(&self, waitfds: &mut [WaitFd], timeout: Duration) -> Result { + let timeout_ms = Multi::timeout_i32(timeout); + unsafe { + let mut ret = 0; + cvt(curl_sys::curl_multi_poll( + self.raw.handle, waitfds.as_mut_ptr() as *mut _, waitfds.len() as u32, timeout_ms, @@ -593,6 +675,13 @@ } } + /// Returns a new [MultiWaker] that can be used to wake up a thread that's + /// currently blocked in [Multi::poll]. + #[cfg(feature = "poll_7_68_0")] + pub fn waker(&self) -> MultiWaker { + MultiWaker::new(Arc::downgrade(&self.raw)) + } + /// Reads/writes available data from each easy handle. /// /// This function handles transfers on all the added handles that need @@ -636,7 +725,7 @@ pub fn perform(&self) -> Result { unsafe { let mut ret = 0; - cvt(curl_sys::curl_multi_perform(self.raw, &mut ret))?; + cvt(curl_sys::curl_multi_perform(self.raw.handle, &mut ret))?; Ok(ret as u32) } } @@ -684,7 +773,11 @@ let write = write.map(|r| r as *mut _).unwrap_or(ptr::null_mut()); let except = except.map(|r| r as *mut _).unwrap_or(ptr::null_mut()); cvt(curl_sys::curl_multi_fdset( - self.raw, read, write, except, &mut ret, + self.raw.handle, + read, + write, + except, + &mut ret, ))?; if ret == -1 { Ok(None) @@ -710,11 +803,38 @@ /// Get a pointer to the raw underlying CURLM handle. pub fn raw(&self) -> *mut curl_sys::CURLM { - self.raw + self.raw.handle } +} - unsafe fn close_impl(&self) -> Result<(), MultiError> { - cvt(curl_sys::curl_multi_cleanup(self.raw)) +impl Drop for RawMulti { + fn drop(&mut self) { + unsafe { + let _ = cvt(curl_sys::curl_multi_cleanup(self.handle)); + } + } +} + +#[cfg(feature = "poll_7_68_0")] +impl MultiWaker { + /// Creates a new MultiWaker handle. + fn new(raw: std::sync::Weak) -> Self { + Self { raw } + } + + /// Wakes up a thread that is blocked in [Multi::poll]. This method can be + /// invoked from any thread. + /// + /// Will return an error if the RawMulti has already been dropped. + /// + /// Requires libcurl 7.68.0 or later. + pub fn wakeup(&self) -> Result<(), MultiError> { + if let Some(raw) = self.raw.upgrade() { + unsafe { cvt(curl_sys::curl_multi_wakeup(raw.handle)) } + } else { + // This happens if the RawMulti has already been dropped: + Err(MultiError::new(curl_sys::CURLM_BAD_HANDLE)) + } } } @@ -732,12 +852,6 @@ } } -impl Drop for Multi { - fn drop(&mut self) { - let _ = unsafe { self.close_impl() }; - } -} - macro_rules! impl_easy_getters { () => { impl_easy_getters! { @@ -913,6 +1027,32 @@ } } +impl DetachGuard { + /// Detach the referenced easy handle from its multi handle manually. + /// Subsequent calls to this method will have no effect. + fn detach(&mut self) -> Result<(), MultiError> { + if !self.easy.is_null() { + unsafe { + cvt(curl_sys::curl_multi_remove_handle( + self.multi.handle, + self.easy, + ))? + } + + // Set easy to null to signify that the handle was removed. + self.easy = ptr::null_mut(); + } + + Ok(()) + } +} + +impl Drop for DetachGuard { + fn drop(&mut self) { + let _ = self.detach(); + } +} + impl<'multi> Message<'multi> { /// If this message indicates that a transfer has finished, returns the /// result of the transfer in `Some`. diff -Nru cargo-0.58.0/vendor/curl/src/version.rs cargo-0.60.0ubuntu1/vendor/curl/src/version.rs --- cargo-0.58.0/vendor/curl/src/version.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/src/version.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,7 +2,6 @@ use std::fmt; use std::str; -use curl_sys; use libc::{c_char, c_int}; /// Version information about libcurl and the capabilities that it supports. diff -Nru cargo-0.58.0/vendor/curl/tests/easy.rs cargo-0.60.0ubuntu1/vendor/curl/tests/easy.rs --- cargo-0.58.0/vendor/curl/tests/easy.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/tests/easy.rs 2022-04-20 13:48:09.000000000 +0000 @@ -22,7 +22,7 @@ fn handle() -> Easy { let mut e = Easy::new(); t!(e.timeout(Duration::new(20, 0))); - return e; + e } fn sink(data: &[u8]) -> Result { diff -Nru cargo-0.58.0/vendor/curl/tests/multi.rs cargo-0.60.0ubuntu1/vendor/curl/tests/multi.rs --- cargo-0.58.0/vendor/curl/tests/multi.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/tests/multi.rs 2022-04-20 13:48:09.000000000 +0000 @@ -150,10 +150,8 @@ while running { let n = t!(poll.poll(&mut events, cur_timeout)); - if n == 0 { - if t!(m.timeout()) == 0 { - running = false; - } + if n == 0 && t!(m.timeout()) == 0 { + running = false; } for event in events.iter() { @@ -167,10 +165,10 @@ } else { let mut e = mio::Ready::empty(); if events.input() { - e = e | mio::Ready::readable(); + e |= mio::Ready::readable(); } if events.output() { - e = e | mio::Ready::writable(); + e |= mio::Ready::writable(); } if token == 0 { let token = next_token; @@ -261,5 +259,39 @@ assert_eq!(events, 3); for waitfd in waitfds { assert!(waitfd.received_read()); + } +} + +// Tests passing raw file descriptors to Multi::wait. The test is limited to Linux only as the +// semantics of the underlying poll(2) system call used by curl apparently differ on other +// platforms, making the test fail. +#[cfg(feature = "poll_7_68_0")] +#[cfg(target_os = "linux")] +#[test] +fn pollfds() { + use curl::multi::WaitFd; + use std::fs::File; + use std::os::unix::io::AsRawFd; + + let filenames = ["/dev/null", "/dev/zero", "/dev/urandom"]; + let files: Vec = filenames + .iter() + .map(|filename| File::open(filename).unwrap()) + .collect(); + let mut waitfds: Vec = files + .iter() + .map(|f| { + let mut waitfd = WaitFd::new(); + waitfd.set_fd(f.as_raw_fd()); + waitfd.poll_on_read(true); + waitfd + }) + .collect(); + + let m = Multi::new(); + let events = t!(m.poll(&mut waitfds, Duration::from_secs(1))); + assert_eq!(events, 3); + for waitfd in waitfds { + assert!(waitfd.received_read()); } } diff -Nru cargo-0.58.0/vendor/curl/tests/post.rs cargo-0.60.0ubuntu1/vendor/curl/tests/post.rs --- cargo-0.58.0/vendor/curl/tests/post.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/tests/post.rs 2022-04-20 13:48:09.000000000 +0000 @@ -20,7 +20,7 @@ let mut list = List::new(); t!(list.append("Expect:")); t!(e.http_headers(list)); - return e; + e } #[test] diff -Nru cargo-0.58.0/vendor/curl/tests/server/mod.rs cargo-0.60.0ubuntu1/vendor/curl/tests/server/mod.rs --- cargo-0.58.0/vendor/curl/tests/server/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl/tests/server/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -31,7 +31,7 @@ Message::Read(ref expected) => { let mut expected = &expected[..]; let mut expected_headers = HashSet::new(); - while let Some(i) = expected.find("\n") { + while let Some(i) = expected.find('\n') { let line = &expected[..i + 1]; expected = &expected[i + 1..]; expected_headers.insert(line); @@ -41,11 +41,11 @@ } let mut expected_len = None; - while expected_headers.len() > 0 { + while !expected_headers.is_empty() { let mut actual = String::new(); t!(socket.read_line(&mut actual)); if actual.starts_with("Content-Length") { - let len = actual.split(": ").skip(1).next().unwrap(); + let len = actual.split(": ").nth(1).unwrap(); expected_len = len.trim().parse().ok(); } // various versions of libcurl do different things here @@ -84,13 +84,13 @@ while socket.limit() > 0 { line.truncate(0); t!(socket.read_line(&mut line)); - if line.len() == 0 { + if line.is_empty() { break; } - if expected.len() == 0 { + if expected.is_empty() { panic!("unexpected line: {:?}", line); } - let i = expected.find("\n").unwrap_or(expected.len() - 1); + let i = expected.find('\n').unwrap_or(expected.len() - 1); let expected_line = &expected[..i + 1]; expected = &expected[i + 1..]; if lines_match(expected_line, &line) { @@ -103,7 +103,7 @@ expected_line, line ) } - if expected.len() != 0 { + if !expected.is_empty() { println!("didn't get expected data: {:?}", expected); } } diff -Nru cargo-0.58.0/vendor/curl-sys/build.rs cargo-0.60.0ubuntu1/vendor/curl-sys/build.rs --- cargo-0.58.0/vendor/curl-sys/build.rs 2022-01-21 02:49:38.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl-sys/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -4,11 +4,14 @@ use std::process::Command; fn main() { - println!("cargo:rerun-if-changed=curl"); let host = env::var("HOST").unwrap(); let target = env::var("TARGET").unwrap(); let windows = target.contains("windows"); + if cfg!(feature = "mesalink") { + println!("cargo:warning=MesaLink support has been removed as of curl 7.82.0, will use default TLS backend instead."); + } + // This feature trumps all others, and is largely set by rustbuild to force // usage of the system library to ensure that we're always building an // ABI-compatible Cargo. @@ -117,7 +120,6 @@ .define("CURL_DISABLE_IMAP", None) .define("CURL_DISABLE_LDAP", None) .define("CURL_DISABLE_LDAPS", None) - .define("CURL_DISABLE_NTLM", None) .define("CURL_DISABLE_POP3", None) .define("CURL_DISABLE_RTSP", None) .define("CURL_DISABLE_SMB", None) @@ -160,12 +162,10 @@ .file("curl/lib/hash.c") .file("curl/lib/hmac.c") .file("curl/lib/hostasyn.c") - .file("curl/lib/hostcheck.c") .file("curl/lib/hostip.c") .file("curl/lib/hostip6.c") .file("curl/lib/hsts.c") .file("curl/lib/http.c") - .file("curl/lib/http2.c") .file("curl/lib/http_aws_sigv4.c") .file("curl/lib/http_chunks.c") .file("curl/lib/http_digest.c") @@ -207,6 +207,7 @@ .file("curl/lib/version.c") .file("curl/lib/vauth/digest.c") .file("curl/lib/vauth/vauth.c") + .file("curl/lib/vtls/hostcheck.c") .file("curl/lib/vtls/keylog.c") .file("curl/lib/vtls/vtls.c") .file("curl/lib/warnless.c") @@ -216,6 +217,20 @@ .define("HAVE_GETSOCKNAME", None) .warnings(false); + if cfg!(feature = "ntlm") { + cfg.file("curl/lib/curl_des.c") + .file("curl/lib/curl_endian.c") + .file("curl/lib/curl_gethostname.c") + .file("curl/lib/curl_ntlm_core.c") + .file("curl/lib/curl_ntlm_wb.c") + .file("curl/lib/http_ntlm.c") + .file("curl/lib/md4.c") + .file("curl/lib/vauth/ntlm.c") + .file("curl/lib/vauth/ntlm_sspi.c"); + } else { + cfg.define("CURL_DISABLE_NTLM", None); + } + if cfg!(feature = "protocol-ftp") { cfg.file("curl/lib/curl_fnmatch.c") .file("curl/lib/ftp.c") @@ -227,7 +242,9 @@ if cfg!(feature = "http2") { cfg.define("USE_NGHTTP2", None) - .define("NGHTTP2_STATICLIB", None); + .define("NGHTTP2_STATICLIB", None) + .file("curl/lib/h2h3.c") + .file("curl/lib/http2.c"); println!("cargo:rustc-cfg=link_libnghttp2"); if let Some(path) = env::var_os("DEP_NGHTTP2_ROOT") { @@ -249,19 +266,10 @@ // Configure TLS backend. Since Cargo does not support mutually exclusive // features, make sure we only compile one vtls. - if cfg!(feature = "mesalink") { - cfg.define("USE_MESALINK", None) - .file("curl/lib/vtls/mesalink.c"); - - if let Some(path) = env::var_os("DEP_MESALINK_INCLUDE") { - cfg.include(path); - } - - if windows { - cfg.define("HAVE_WINDOWS", None); - } else { - cfg.define("HAVE_UNIX", None); - } + if cfg!(feature = "rustls") { + cfg.define("USE_RUSTLS", None) + .file("curl/lib/vtls/rustls.c") + .include(env::var_os("DEP_RUSTLS_FFI_INCLUDE").unwrap()); } else if cfg!(feature = "ssl") { if windows { // For windows, spnego feature is auto on in case ssl feature is on. @@ -269,17 +277,17 @@ cfg.define("USE_WINDOWS_SSPI", None) .define("USE_SCHANNEL", None) .file("curl/lib/http_negotiate.c") - .file("curl/lib/x509asn1.c") .file("curl/lib/curl_sspi.c") .file("curl/lib/socks_sspi.c") .file("curl/lib/vauth/spnego_sspi.c") .file("curl/lib/vauth/vauth.c") .file("curl/lib/vtls/schannel.c") - .file("curl/lib/vtls/schannel_verify.c"); + .file("curl/lib/vtls/schannel_verify.c") + .file("curl/lib/vtls/x509asn1.c"); } else if target.contains("-apple-") { cfg.define("USE_SECTRANSP", None) - .file("curl/lib/x509asn1.c") - .file("curl/lib/vtls/sectransp.c"); + .file("curl/lib/vtls/sectransp.c") + .file("curl/lib/vtls/x509asn1.c"); if xcode_major_version().map_or(true, |v| v >= 9) { // On earlier Xcode versions (<9), defining HAVE_BUILTIN_AVAILABLE // would cause __bultin_available() to fail to compile due to @@ -498,14 +506,17 @@ } fn xcode_major_version() -> Option { - let output = Command::new("xcodebuild").arg("-version").output().ok()?; - if output.status.success() { - let stdout = String::from_utf8_lossy(&output.stdout); - println!("xcode version: {}", stdout); - let mut words = stdout.split_whitespace(); - if words.next()? == "Xcode" { - let version = words.next()?; - return version[..version.find('.')?].parse().ok(); + let status = Command::new("xcode-select").arg("-p").status().ok()?; + if status.success() { + let output = Command::new("xcodebuild").arg("-version").output().ok()?; + if output.status.success() { + let stdout = String::from_utf8_lossy(&output.stdout); + println!("xcode version: {}", stdout); + let mut words = stdout.split_whitespace(); + if words.next()? == "Xcode" { + let version = words.next()?; + return version[..version.find('.')?].parse().ok(); + } } } println!("unable to determine Xcode version, assuming >= 9"); @@ -552,8 +563,10 @@ let stdout = String::from_utf8_lossy(&output.stdout); for line in stdout.lines() { if line.contains("libraries: =") { - let path = line.split('=').skip(1).next()?; - return Some(format!("{}/lib/darwin", path)); + let path = line.split('=').nth(1)?; + if !path.is_empty() { + return Some(format!("{}/lib/darwin", path)); + } } } diff -Nru cargo-0.58.0/vendor/curl-sys/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/curl-sys/.cargo-checksum.json --- cargo-0.58.0/vendor/curl-sys/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl-sys/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"e0f44960aea24a786a46907b8824ebc0e66ca06bf4e4978408c7499620343483"} \ No newline at end of file +{"files":{},"package":"8092905a5a9502c312f223b2775f57ec5c5b715f9a15ee9d2a8591d1364a0352"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/curl-sys/Cargo.toml cargo-0.60.0ubuntu1/vendor/curl-sys/Cargo.toml --- cargo-0.58.0/vendor/curl-sys/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl-sys/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "curl-sys" -version = "0.4.49+curl-7.79.1" +version = "0.4.53+curl-7.82.0" authors = ["Alex Crichton "] build = "build.rs" links = "curl" @@ -32,6 +32,10 @@ version = "0.1.3" optional = true +[dependencies.rustls-ffi] +version = "0.8" +features = ["no_log_capture"] +optional = true [build-dependencies.cc] version = "1.0" @@ -42,7 +46,11 @@ default = ["ssl"] force-system-lib-on-osx = [] http2 = ["libnghttp2-sys"] +mesalink = [] +ntlm = [] +poll_7_68_0 = [] protocol-ftp = [] +rustls = ["rustls-ffi"] spnego = [] ssl = ["openssl-sys"] static-curl = [] diff -Nru cargo-0.58.0/vendor/curl-sys/debian/patches/avoid-spurious-rebuilds.patch cargo-0.60.0ubuntu1/vendor/curl-sys/debian/patches/avoid-spurious-rebuilds.patch --- cargo-0.58.0/vendor/curl-sys/debian/patches/avoid-spurious-rebuilds.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl-sys/debian/patches/avoid-spurious-rebuilds.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,12 @@ +Since we excluded the "curl" source code directory, this check is no longer +applicable and would always lead to rebuilds since the file is non-existent. +--- a/build.rs ++++ b/build.rs +@@ -4,7 +4,6 @@ + use std::process::Command; + + fn main() { +- println!("cargo:rerun-if-changed=curl"); + let host = env::var("HOST").unwrap(); + let target = env::var("TARGET").unwrap(); + let windows = target.contains("windows"); diff -Nru cargo-0.58.0/vendor/curl-sys/debian/patches/disable-libz-sys.patch cargo-0.60.0ubuntu1/vendor/curl-sys/debian/patches/disable-libz-sys.patch --- cargo-0.58.0/vendor/curl-sys/debian/patches/disable-libz-sys.patch 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl-sys/debian/patches/disable-libz-sys.patch 2022-04-20 13:48:09.000000000 +0000 @@ -11,9 +11,9 @@ -features = ["libc"] -default-features = false - - [build-dependencies.cc] - version = "1.0" - + [dependencies.rustls-ffi] + version = "0.8" + features = ["no_log_capture"] @@ -53,7 +48,6 @@ static-curl = [] static-ssl = ["openssl-sys"] diff -Nru cargo-0.58.0/vendor/curl-sys/debian/patches/series cargo-0.60.0ubuntu1/vendor/curl-sys/debian/patches/series --- cargo-0.58.0/vendor/curl-sys/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl-sys/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,3 @@ -disable-mesalink.patch +avoid-spurious-rebuilds.patch disable-vendor.patch disable-libz-sys.patch diff -Nru cargo-0.58.0/vendor/curl-sys/lib.rs cargo-0.60.0ubuntu1/vendor/curl-sys/lib.rs --- cargo-0.58.0/vendor/curl-sys/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/curl-sys/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -6,10 +6,10 @@ extern crate libnghttp2_sys; #[cfg(link_libz)] extern crate libz_sys; -#[cfg(feature = "mesalink")] -extern crate mesalink; #[cfg(link_openssl)] extern crate openssl_sys; +#[cfg(feature = "rustls")] +extern crate rustls_ffi; use libc::c_ulong; use libc::{c_char, c_double, c_int, c_long, c_short, c_uint, c_void, size_t, time_t}; @@ -595,6 +595,7 @@ pub const CURLOPT_PROXY_SSLCERT: CURLoption = CURLOPTTYPE_OBJECTPOINT + 254; pub const CURLOPT_PROXY_SSLKEY: CURLoption = CURLOPTTYPE_OBJECTPOINT + 256; +pub const CURLOPT_DOH_URL: CURLoption = CURLOPTTYPE_OBJECTPOINT + 279; pub const CURLOPT_UPLOAD_BUFFERSIZE: CURLoption = CURLOPTTYPE_LONG + 280; pub const CURLOPT_MAXAGE_CONN: CURLoption = CURLOPTTYPE_LONG + 288; @@ -607,6 +608,11 @@ pub const CURLOPT_AWS_SIGV4: CURLoption = CURLOPTTYPE_OBJECTPOINT + 305; +pub const CURLOPT_DOH_SSL_VERIFYPEER: CURLoption = CURLOPTTYPE_LONG + 306; +pub const CURLOPT_DOH_SSL_VERIFYHOST: CURLoption = CURLOPTTYPE_LONG + 307; +pub const CURLOPT_DOH_SSL_VERIFYSTATUS: CURLoption = CURLOPTTYPE_LONG + 308; +pub const CURLOPT_CAINFO_BLOB: CURLoption = CURLOPTTYPE_BLOB + 309; + pub const CURL_IPRESOLVE_WHATEVER: c_int = 0; pub const CURL_IPRESOLVE_V4: c_int = 1; pub const CURL_IPRESOLVE_V6: c_int = 2; @@ -1079,6 +1085,19 @@ timeout_ms: c_int, ret: *mut c_int, ) -> CURLMcode; + + #[cfg(feature = "poll_7_68_0")] + pub fn curl_multi_poll( + multi_handle: *mut CURLM, + extra_fds: *mut curl_waitfd, + extra_nfds: c_uint, + timeout_ms: c_int, + ret: *mut c_int, + ) -> CURLMcode; + + #[cfg(feature = "poll_7_68_0")] + pub fn curl_multi_wakeup(multi_handle: *mut CURLM) -> CURLMcode; + pub fn curl_multi_perform(multi_handle: *mut CURLM, running_handles: *mut c_int) -> CURLMcode; pub fn curl_multi_cleanup(multi_handle: *mut CURLM) -> CURLMcode; pub fn curl_multi_info_read( diff -Nru cargo-0.58.0/vendor/fastrand/benches/bench.rs cargo-0.60.0ubuntu1/vendor/fastrand/benches/bench.rs --- cargo-0.58.0/vendor/fastrand/benches/bench.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/benches/bench.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,75 @@ +#![feature(test)] + +extern crate test; + +use rand::prelude::*; +use test::Bencher; +use wyhash::WyRng; + +#[bench] +fn shuffle_wyhash(b: &mut Bencher) { + let mut rng = WyRng::from_rng(thread_rng()).unwrap(); + let mut x = (0..100).collect::>(); + b.iter(|| { + x.shuffle(&mut rng); + x[0] + }) +} + +#[bench] +fn shuffle_fastrand(b: &mut Bencher) { + let rng = fastrand::Rng::new(); + let mut x = (0..100).collect::>(); + b.iter(|| { + rng.shuffle(&mut x); + x[0] + }) +} + +#[bench] +fn u8_wyhash(b: &mut Bencher) { + let mut rng = WyRng::from_rng(thread_rng()).unwrap(); + b.iter(|| { + let mut sum = 0u8; + for _ in 0..10_000 { + sum = sum.wrapping_add(rng.gen::()); + } + sum + }) +} + +#[bench] +fn u8_fastrand(b: &mut Bencher) { + let rng = fastrand::Rng::new(); + b.iter(|| { + let mut sum = 0u8; + for _ in 0..10_000 { + sum = sum.wrapping_add(rng.u8(..)); + } + sum + }) +} + +#[bench] +fn u32_wyhash(b: &mut Bencher) { + let mut rng = WyRng::from_rng(thread_rng()).unwrap(); + b.iter(|| { + let mut sum = 0u32; + for _ in 0..10_000 { + sum = sum.wrapping_add(rng.gen::()); + } + sum + }) +} + +#[bench] +fn u32_fastrand(b: &mut Bencher) { + let rng = fastrand::Rng::new(); + b.iter(|| { + let mut sum = 0u32; + for _ in 0..10_000 { + sum = sum.wrapping_add(rng.u32(..)); + } + sum + }) +} diff -Nru cargo-0.58.0/vendor/fastrand/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/fastrand/.cargo-checksum.json --- cargo-0.58.0/vendor/fastrand/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1 @@ +{"files":{},"package":"c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/fastrand/Cargo.toml cargo-0.60.0ubuntu1/vendor/fastrand/Cargo.toml --- cargo-0.58.0/vendor/fastrand/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,31 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +rust-version = "1.34" +name = "fastrand" +version = "1.7.0" +authors = ["Stjepan Glavina "] +exclude = ["/.*"] +description = "A simple and fast random number generator" +keywords = ["simple", "fast", "rand", "random", "wyrand"] +categories = ["algorithms"] +license = "Apache-2.0 OR MIT" +repository = "https://github.com/smol-rs/fastrand" +[dev-dependencies.getrandom] +version = "0.2" + +[dev-dependencies.rand] +version = "0.8" + +[dev-dependencies.wyhash] +version = "0.5" diff -Nru cargo-0.58.0/vendor/fastrand/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/fastrand/CHANGELOG.md --- cargo-0.58.0/vendor/fastrand/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/CHANGELOG.md 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,77 @@ +# Version 1.7.0 + +- Add `char()` and `Rng::char()` (#25) + +# Version 1.6.0 + +- Implement `PartialEq` and `Eq` for `Rng` (#23) + +# Version 1.5.0 + +- Switch to Wyrand (#14) + +# Version 1.4.1 + +- Fix bug when generating a signed integer within a range (#16) + +# Version 1.4.0 + +- Add wasm support. + +# Version 1.3.5 + +- Reword docs. +- Add `Rng::with_seed()`. + +# Version 1.3.4 + +- Implement `Clone` for `Rng`. + +# Version 1.3.3 + +- Forbid unsafe code. + +# Version 1.3.2 + +- Support older Rust versions. + +# Version 1.3.1 + +- Tweak Cargo keywords. + +# Version 1.3.0 + +- Add `f32()` and `f64()`. +- Add `lowercase()`, `uppercase()`, `alphabetic()`, and `digit()`. + +# Version 1.2.4 + +- Switch to PCG XSH RR 64/32. +- Fix a bug in `gen_mod_u128`. +- Fix bias in ranges. + +# Version 1.2.3 + +- Support Rust 1.32.0 + +# Version 1.2.2 + +- Use `std::$t::MAX` rather than `$t::MAX` to support older Rust versions. + +# Version 1.2.1 + +- Inline all functions. + +# Version 1.2.0 + +- Add `Rng` struct. + +# Version 1.1.0 + +- Switch to PCG implementation. +- Add `alphanumeric()`. +- Add `seed()`. + +# Version 1.0.0 + +- Initial version diff -Nru cargo-0.58.0/vendor/fastrand/debian/patches/no-wasm.patch cargo-0.60.0ubuntu1/vendor/fastrand/debian/patches/no-wasm.patch --- cargo-0.58.0/vendor/fastrand/debian/patches/no-wasm.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/debian/patches/no-wasm.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,18 @@ +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -31,15 +31,3 @@ version = "0.7.3" + + [dev-dependencies.wyhash] + version = "0.5" +-[target."cfg(target_arch = \"wasm32\")".dependencies.instant] +-version = "0.1" +-[target."cfg(target_arch = \"wasm32\")".dev-dependencies.getrandom] +-version = "0.2" +-features = ["js"] +- +-[target."cfg(target_arch = \"wasm32\")".dev-dependencies.instant] +-version = "0.1" +-features = ["wasm-bindgen"] +- +-[target."cfg(target_arch = \"wasm32\")".dev-dependencies.wasm-bindgen-test] +-version = "0.3" diff -Nru cargo-0.58.0/vendor/fastrand/debian/patches/no-wasm.patch.orig cargo-0.60.0ubuntu1/vendor/fastrand/debian/patches/no-wasm.patch.orig --- cargo-0.58.0/vendor/fastrand/debian/patches/no-wasm.patch.orig 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/debian/patches/no-wasm.patch.orig 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,8 @@ +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -31,5 +31,3 @@ version = "0.7.3" + + [dev-dependencies.rand_pcg] + version = "0.2.1" +-[target."cfg(target_arch = \"wasm32\")".dependencies.instant] +-version = "0.1" diff -Nru cargo-0.58.0/vendor/fastrand/debian/patches/series cargo-0.60.0ubuntu1/vendor/fastrand/debian/patches/series --- cargo-0.58.0/vendor/fastrand/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1 @@ +no-wasm.patch diff -Nru cargo-0.58.0/vendor/fastrand/LICENSE-APACHE cargo-0.60.0ubuntu1/vendor/fastrand/LICENSE-APACHE --- cargo-0.58.0/vendor/fastrand/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/LICENSE-APACHE 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff -Nru cargo-0.58.0/vendor/fastrand/LICENSE-MIT cargo-0.60.0ubuntu1/vendor/fastrand/LICENSE-MIT --- cargo-0.58.0/vendor/fastrand/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/LICENSE-MIT 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,23 @@ +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.58.0/vendor/fastrand/README.md cargo-0.60.0ubuntu1/vendor/fastrand/README.md --- cargo-0.58.0/vendor/fastrand/README.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,92 @@ +# fastrand + +[![Build](https://github.com/smol-rs/fastrand/workflows/Build%20and%20test/badge.svg)]( +https://github.com/smol-rs/fastrand/actions) +[![License](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)]( +https://github.com/smol-rs/fastrand) +[![Cargo](https://img.shields.io/crates/v/fastrand.svg)]( +https://crates.io/crates/fastrand) +[![Documentation](https://docs.rs/fastrand/badge.svg)]( +https://docs.rs/fastrand) + +A simple and fast random number generator. + +The implementation uses [Wyrand](https://github.com/wangyi-fudan/wyhash), a simple and fast +generator but **not** cryptographically secure. + +## Examples + +Flip a coin: + +```rust +if fastrand::bool() { + println!("heads"); +} else { + println!("tails"); +} +``` + +Generate a random `i32`: + +```rust +let num = fastrand::i32(..); +``` + +Choose a random element in an array: + +```rust +let v = vec![1, 2, 3, 4, 5]; +let i = fastrand::usize(..v.len()); +let elem = v[i]; +``` + +Shuffle an array: + +```rust +let mut v = vec![1, 2, 3, 4, 5]; +fastrand::shuffle(&mut v); +``` + +Generate a random `Vec` or `String`: + +```rust +use std::iter::repeat_with; + +let v: Vec = repeat_with(|| fastrand::i32(..)).take(10).collect(); +let s: String = repeat_with(fastrand::alphanumeric).take(10).collect(); +``` + +To get reproducible results on every run, initialize the generator with a seed: + +```rust +// Pick an arbitrary number as seed. +fastrand::seed(7); + +// Now this prints the same number on every run: +println!("{}", fastrand::u32(..)); +``` + +To be more efficient, create a new `Rng` instance instead of using the thread-local +generator: + +```rust +use std::iter::repeat_with; + +let rng = fastrand::Rng::new(); +let mut bytes: Vec = repeat_with(|| rng.u8(..)).take(10_000).collect(); +``` + +## License + +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) + +at your option. + +#### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff -Nru cargo-0.58.0/vendor/fastrand/src/lib.rs cargo-0.60.0ubuntu1/vendor/fastrand/src/lib.rs --- cargo-0.58.0/vendor/fastrand/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,668 @@ +//! A simple and fast random number generator. +//! +//! The implementation uses [Wyrand](https://github.com/wangyi-fudan/wyhash), a simple and fast +//! generator but **not** cryptographically secure. +//! +//! # Examples +//! +//! Flip a coin: +//! +//! ``` +//! if fastrand::bool() { +//! println!("heads"); +//! } else { +//! println!("tails"); +//! } +//! ``` +//! +//! Generate a random `i32`: +//! +//! ``` +//! let num = fastrand::i32(..); +//! ``` +//! +//! Choose a random element in an array: +//! +//! ``` +//! let v = vec![1, 2, 3, 4, 5]; +//! let i = fastrand::usize(..v.len()); +//! let elem = v[i]; +//! ``` +//! +//! Shuffle an array: +//! +//! ``` +//! let mut v = vec![1, 2, 3, 4, 5]; +//! fastrand::shuffle(&mut v); +//! ``` +//! +//! Generate a random [`Vec`] or [`String`]: +//! +//! ``` +//! use std::iter::repeat_with; +//! +//! let v: Vec = repeat_with(|| fastrand::i32(..)).take(10).collect(); +//! let s: String = repeat_with(fastrand::alphanumeric).take(10).collect(); +//! ``` +//! +//! To get reproducible results on every run, initialize the generator with a seed: +//! +//! ``` +//! // Pick an arbitrary number as seed. +//! fastrand::seed(7); +//! +//! // Now this prints the same number on every run: +//! println!("{}", fastrand::u32(..)); +//! ``` +//! +//! To be more efficient, create a new [`Rng`] instance instead of using the thread-local +//! generator: +//! +//! ``` +//! use std::iter::repeat_with; +//! +//! let rng = fastrand::Rng::new(); +//! let mut bytes: Vec = repeat_with(|| rng.u8(..)).take(10_000).collect(); +//! ``` + +#![forbid(unsafe_code)] +#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)] + +use std::cell::Cell; +use std::collections::hash_map::DefaultHasher; +use std::hash::{Hash, Hasher}; +use std::ops::{Bound, RangeBounds}; +use std::thread; + +#[cfg(target_arch = "wasm32")] +use instant::Instant; +#[cfg(not(target_arch = "wasm32"))] +use std::time::Instant; + +/// A random number generator. +#[derive(Debug, PartialEq, Eq)] +pub struct Rng(Cell); + +impl Default for Rng { + #[inline] + fn default() -> Rng { + Rng::new() + } +} + +impl Clone for Rng { + /// Clones the generator by deterministically deriving a new generator based on the initial + /// seed. + /// + /// # Example + /// + /// ``` + /// // Seed two generators equally, and clone both of them. + /// let base1 = fastrand::Rng::new(); + /// base1.seed(0x4d595df4d0f33173); + /// base1.bool(); // Use the generator once. + /// + /// let base2 = fastrand::Rng::new(); + /// base2.seed(0x4d595df4d0f33173); + /// base2.bool(); // Use the generator once. + /// + /// let rng1 = base1.clone(); + /// let rng2 = base2.clone(); + /// + /// assert_eq!(rng1.u64(..), rng2.u64(..), "the cloned generators are identical"); + /// ``` + fn clone(&self) -> Rng { + Rng::with_seed(self.gen_u64()) + } +} + +impl Rng { + /// Generates a random `u32`. + #[inline] + fn gen_u32(&self) -> u32 { + self.gen_u64() as u32 + } + + /// Generates a random `u64`. + #[inline] + fn gen_u64(&self) -> u64 { + let s = self.0.get().wrapping_add(0xA0761D6478BD642F); + self.0.set(s); + let t = u128::from(s) * u128::from(s ^ 0xE7037ED1A0B428DB); + (t as u64) ^ (t >> 64) as u64 + } + + /// Generates a random `u128`. + #[inline] + fn gen_u128(&self) -> u128 { + (u128::from(self.gen_u64()) << 64) | u128::from(self.gen_u64()) + } + + /// Generates a random `u32` in `0..n`. + #[inline] + fn gen_mod_u32(&self, n: u32) -> u32 { + // Adapted from: https://lemire.me/blog/2016/06/30/fast-random-shuffling/ + let mut r = self.gen_u32(); + let mut hi = mul_high_u32(r, n); + let mut lo = r.wrapping_mul(n); + if lo < n { + let t = n.wrapping_neg() % n; + while lo < t { + r = self.gen_u32(); + hi = mul_high_u32(r, n); + lo = r.wrapping_mul(n); + } + } + hi + } + + /// Generates a random `u64` in `0..n`. + #[inline] + fn gen_mod_u64(&self, n: u64) -> u64 { + // Adapted from: https://lemire.me/blog/2016/06/30/fast-random-shuffling/ + let mut r = self.gen_u64(); + let mut hi = mul_high_u64(r, n); + let mut lo = r.wrapping_mul(n); + if lo < n { + let t = n.wrapping_neg() % n; + while lo < t { + r = self.gen_u64(); + hi = mul_high_u64(r, n); + lo = r.wrapping_mul(n); + } + } + hi + } + + /// Generates a random `u128` in `0..n`. + #[inline] + fn gen_mod_u128(&self, n: u128) -> u128 { + // Adapted from: https://lemire.me/blog/2016/06/30/fast-random-shuffling/ + let mut r = self.gen_u128(); + let mut hi = mul_high_u128(r, n); + let mut lo = r.wrapping_mul(n); + if lo < n { + let t = n.wrapping_neg() % n; + while lo < t { + r = self.gen_u128(); + hi = mul_high_u128(r, n); + lo = r.wrapping_mul(n); + } + } + hi + } +} + +thread_local! { + static RNG: Rng = Rng(Cell::new({ + let mut hasher = DefaultHasher::new(); + Instant::now().hash(&mut hasher); + thread::current().id().hash(&mut hasher); + let hash = hasher.finish(); + (hash << 1) | 1 + })); +} + +/// Computes `(a * b) >> 32`. +#[inline] +fn mul_high_u32(a: u32, b: u32) -> u32 { + (((a as u64) * (b as u64)) >> 32) as u32 +} + +/// Computes `(a * b) >> 64`. +#[inline] +fn mul_high_u64(a: u64, b: u64) -> u64 { + (((a as u128) * (b as u128)) >> 64) as u64 +} + +/// Computes `(a * b) >> 128`. +#[inline] +fn mul_high_u128(a: u128, b: u128) -> u128 { + // Adapted from: https://stackoverflow.com/a/28904636 + let a_lo = a as u64 as u128; + let a_hi = (a >> 64) as u64 as u128; + let b_lo = b as u64 as u128; + let b_hi = (b >> 64) as u64 as u128; + let carry = (a_lo * b_lo) >> 64; + let carry = ((a_hi * b_lo) as u64 as u128 + (a_lo * b_hi) as u64 as u128 + carry) >> 64; + a_hi * b_hi + ((a_hi * b_lo) >> 64) + ((a_lo * b_hi) >> 64) + carry +} + +macro_rules! rng_integer { + ($t:tt, $unsigned_t:tt, $gen:tt, $mod:tt, $doc:tt) => { + #[doc = $doc] + /// + /// Panics if the range is empty. + #[inline] + pub fn $t(&self, range: impl RangeBounds<$t>) -> $t { + let panic_empty_range = || { + panic!( + "empty range: {:?}..{:?}", + range.start_bound(), + range.end_bound() + ) + }; + + let low = match range.start_bound() { + Bound::Unbounded => std::$t::MIN, + Bound::Included(&x) => x, + Bound::Excluded(&x) => x.checked_add(1).unwrap_or_else(panic_empty_range), + }; + + let high = match range.end_bound() { + Bound::Unbounded => std::$t::MAX, + Bound::Included(&x) => x, + Bound::Excluded(&x) => x.checked_sub(1).unwrap_or_else(panic_empty_range), + }; + + if low > high { + panic_empty_range(); + } + + if low == std::$t::MIN && high == std::$t::MAX { + self.$gen() as $t + } else { + let len = high.wrapping_sub(low).wrapping_add(1); + low.wrapping_add(self.$mod(len as $unsigned_t as _) as $t) + } + } + }; +} + +impl Rng { + /// Creates a new random number generator. + #[inline] + pub fn new() -> Rng { + Rng::with_seed( + RNG.try_with(|rng| rng.u64(..)) + .unwrap_or(0x4d595df4d0f33173), + ) + } + + /// Creates a new random number generator with the initial seed. + #[inline] + pub fn with_seed(seed: u64) -> Self { + let rng = Rng(Cell::new(0)); + + rng.seed(seed); + rng + } + + /// Generates a random `char` in ranges a-z and A-Z. + #[inline] + pub fn alphabetic(&self) -> char { + const CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + let len = CHARS.len() as u8; + let i = self.u8(..len); + CHARS[i as usize] as char + } + + /// Generates a random `char` in ranges a-z, A-Z and 0-9. + #[inline] + pub fn alphanumeric(&self) -> char { + const CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + let len = CHARS.len() as u8; + let i = self.u8(..len); + CHARS[i as usize] as char + } + + /// Generates a random `bool`. + #[inline] + pub fn bool(&self) -> bool { + self.u8(..) % 2 == 0 + } + + /// Generates a random digit in the given `base`. + /// + /// Digits are represented by `char`s in ranges 0-9 and a-z. + /// + /// Panics if the base is zero or greater than 36. + #[inline] + pub fn digit(&self, base: u32) -> char { + if base == 0 { + panic!("base cannot be zero"); + } + if base > 36 { + panic!("base cannot be larger than 36"); + } + let num = self.u8(..base as u8); + if num < 10 { + (b'0' + num) as char + } else { + (b'a' + num - 10) as char + } + } + + /// Generates a random `f32` in range `0..1`. + pub fn f32(&self) -> f32 { + let b = 32; + let f = std::f32::MANTISSA_DIGITS - 1; + f32::from_bits((1 << (b - 2)) - (1 << f) + (self.u32(..) >> (b - f))) - 1.0 + } + + /// Generates a random `f64` in range `0..1`. + pub fn f64(&self) -> f64 { + let b = 64; + let f = std::f64::MANTISSA_DIGITS - 1; + f64::from_bits((1 << (b - 2)) - (1 << f) + (self.u64(..) >> (b - f))) - 1.0 + } + + rng_integer!( + i8, + u8, + gen_u32, + gen_mod_u32, + "Generates a random `i8` in the given range." + ); + + rng_integer!( + i16, + u16, + gen_u32, + gen_mod_u32, + "Generates a random `i16` in the given range." + ); + + rng_integer!( + i32, + u32, + gen_u32, + gen_mod_u32, + "Generates a random `i32` in the given range." + ); + + rng_integer!( + i64, + u64, + gen_u64, + gen_mod_u64, + "Generates a random `i64` in the given range." + ); + + rng_integer!( + i128, + u128, + gen_u128, + gen_mod_u128, + "Generates a random `i128` in the given range." + ); + + #[cfg(target_pointer_width = "16")] + rng_integer!( + isize, + usize, + gen_u32, + gen_mod_u32, + "Generates a random `isize` in the given range." + ); + #[cfg(target_pointer_width = "32")] + rng_integer!( + isize, + usize, + gen_u32, + gen_mod_u32, + "Generates a random `isize` in the given range." + ); + #[cfg(target_pointer_width = "64")] + rng_integer!( + isize, + usize, + gen_u64, + gen_mod_u64, + "Generates a random `isize` in the given range." + ); + + /// Generates a random `char` in range a-z. + #[inline] + pub fn lowercase(&self) -> char { + const CHARS: &[u8] = b"abcdefghijklmnopqrstuvwxyz"; + let len = CHARS.len() as u8; + let i = self.u8(..len); + CHARS[i as usize] as char + } + + /// Initializes this generator with the given seed. + #[inline] + pub fn seed(&self, seed: u64) { + self.0.set(seed); + } + + /// Shuffles a slice randomly. + #[inline] + pub fn shuffle(&self, slice: &mut [T]) { + for i in 1..slice.len() { + slice.swap(i, self.usize(..=i)); + } + } + + rng_integer!( + u8, + u8, + gen_u32, + gen_mod_u32, + "Generates a random `u8` in the given range." + ); + + rng_integer!( + u16, + u16, + gen_u32, + gen_mod_u32, + "Generates a random `u16` in the given range." + ); + + rng_integer!( + u32, + u32, + gen_u32, + gen_mod_u32, + "Generates a random `u32` in the given range." + ); + + rng_integer!( + u64, + u64, + gen_u64, + gen_mod_u64, + "Generates a random `u64` in the given range." + ); + + rng_integer!( + u128, + u128, + gen_u128, + gen_mod_u128, + "Generates a random `u128` in the given range." + ); + + #[cfg(target_pointer_width = "16")] + rng_integer!( + usize, + usize, + gen_u32, + gen_mod_u32, + "Generates a random `usize` in the given range." + ); + #[cfg(target_pointer_width = "32")] + rng_integer!( + usize, + usize, + gen_u32, + gen_mod_u32, + "Generates a random `usize` in the given range." + ); + #[cfg(target_pointer_width = "64")] + rng_integer!( + usize, + usize, + gen_u64, + gen_mod_u64, + "Generates a random `usize` in the given range." + ); + #[cfg(target_pointer_width = "128")] + rng_integer!( + usize, + usize, + gen_u128, + gen_mod_u128, + "Generates a random `usize` in the given range." + ); + + /// Generates a random `char` in range A-Z. + #[inline] + pub fn uppercase(&self) -> char { + const CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + let len = CHARS.len() as u8; + let i = self.u8(..len); + CHARS[i as usize] as char + } + + /// Generates a random `char` in the given range. + /// + /// Panics if the range is empty. + #[inline] + pub fn char(&self, range: impl RangeBounds) -> char { + use std::convert::{TryFrom, TryInto}; + + let panic_empty_range = || { + panic!( + "empty range: {:?}..{:?}", + range.start_bound(), + range.end_bound() + ) + }; + + let surrogate_start = 0xd800u32; + let surrogate_len = 0x800u32; + + let low = match range.start_bound() { + Bound::Unbounded => 0u8 as char, + Bound::Included(&x) => x, + Bound::Excluded(&x) => { + let scalar = if x as u32 == surrogate_start - 1 { + surrogate_start + surrogate_len + } else { + x as u32 + 1 + }; + char::try_from(scalar).unwrap_or_else(|_| panic_empty_range()) + } + }; + + let high = match range.end_bound() { + Bound::Unbounded => std::char::MAX, + Bound::Included(&x) => x, + Bound::Excluded(&x) => { + let scalar = if x as u32 == surrogate_start + surrogate_len { + surrogate_start - 1 + } else { + (x as u32).wrapping_sub(1) + }; + char::try_from(scalar).unwrap_or_else(|_| panic_empty_range()) + } + }; + + if low > high { + panic_empty_range(); + } + + let gap = if (low as u32) < surrogate_start && (high as u32) >= surrogate_start { + surrogate_len + } else { + 0 + }; + let range = high as u32 - low as u32 - gap; + let mut val = self.u32(0..=range) + low as u32; + if val >= surrogate_start { + val += gap; + } + val.try_into().unwrap() + } +} + +/// Initializes the thread-local generator with the given seed. +#[inline] +pub fn seed(seed: u64) { + RNG.with(|rng| rng.seed(seed)) +} + +/// Generates a random `bool`. +#[inline] +pub fn bool() -> bool { + RNG.with(|rng| rng.bool()) +} + +/// Generates a random `char` in ranges a-z and A-Z. +#[inline] +pub fn alphabetic() -> char { + RNG.with(|rng| rng.alphabetic()) +} + +/// Generates a random `char` in ranges a-z, A-Z and 0-9. +#[inline] +pub fn alphanumeric() -> char { + RNG.with(|rng| rng.alphanumeric()) +} + +/// Generates a random `char` in range a-z. +#[inline] +pub fn lowercase() -> char { + RNG.with(|rng| rng.lowercase()) +} + +/// Generates a random `char` in range A-Z. +#[inline] +pub fn uppercase() -> char { + RNG.with(|rng| rng.uppercase()) +} + +/// Generates a random digit in the given `base`. +/// +/// Digits are represented by `char`s in ranges 0-9 and a-z. +/// +/// Panics if the base is zero or greater than 36. +#[inline] +pub fn digit(base: u32) -> char { + RNG.with(|rng| rng.digit(base)) +} + +/// Shuffles a slice randomly. +#[inline] +pub fn shuffle(slice: &mut [T]) { + RNG.with(|rng| rng.shuffle(slice)) +} + +macro_rules! integer { + ($t:tt, $doc:tt) => { + #[doc = $doc] + /// + /// Panics if the range is empty. + #[inline] + pub fn $t(range: impl RangeBounds<$t>) -> $t { + RNG.with(|rng| rng.$t(range)) + } + }; +} + +integer!(u8, "Generates a random `u8` in the given range."); +integer!(i8, "Generates a random `i8` in the given range."); +integer!(u16, "Generates a random `u16` in the given range."); +integer!(i16, "Generates a random `i16` in the given range."); +integer!(u32, "Generates a random `u32` in the given range."); +integer!(i32, "Generates a random `i32` in the given range."); +integer!(u64, "Generates a random `u64` in the given range."); +integer!(i64, "Generates a random `i64` in the given range."); +integer!(u128, "Generates a random `u128` in the given range."); +integer!(i128, "Generates a random `i128` in the given range."); +integer!(usize, "Generates a random `usize` in the given range."); +integer!(isize, "Generates a random `isize` in the given range."); +integer!(char, "Generates a random `char` in the given range."); + +/// Generates a random `f32` in range `0..1`. +pub fn f32() -> f32 { + RNG.with(|rng| rng.f32()) +} + +/// Generates a random `f64` in range `0..1`. +pub fn f64() -> f64 { + RNG.with(|rng| rng.f64()) +} diff -Nru cargo-0.58.0/vendor/fastrand/tests/char.rs cargo-0.60.0ubuntu1/vendor/fastrand/tests/char.rs --- cargo-0.58.0/vendor/fastrand/tests/char.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/tests/char.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,44 @@ +use std::convert::TryFrom; +use std::ops::RangeBounds; + +fn test_char_coverage(n: usize, range: R) +where + R: Iterator + RangeBounds + Clone, +{ + use std::collections::HashSet; + + let all: HashSet = range.clone().collect(); + let mut covered = HashSet::new(); + for _ in 0..n { + let c = fastrand::char(range.clone()); + assert!(all.contains(&c)); + covered.insert(c); + } + assert_eq!(covered, all); +} + +#[test] +fn test_char() { + // ASCII control chars. + let nul = 0u8 as char; + let soh = 1u8 as char; + let stx = 2u8 as char; + // Some undefined Hangul Jamo codepoints just before + // the surrogate area. + let last_jamo = char::try_from(0xd7ffu32).unwrap(); + let penultimate_jamo = char::try_from(last_jamo as u32 - 1).unwrap(); + // Private-use codepoints just after the surrogate area. + let first_private = char::try_from(0xe000u32).unwrap(); + let second_private = char::try_from(first_private as u32 + 1).unwrap(); + // Private-use codepoints at the end of Unicode space. + let last_private = std::char::MAX; + let penultimate_private = char::try_from(last_private as u32 - 1).unwrap(); + + test_char_coverage(100, nul..stx); + test_char_coverage(100, nul..=soh); + + test_char_coverage(400, penultimate_jamo..second_private); + test_char_coverage(400, penultimate_jamo..=second_private); + + test_char_coverage(100, penultimate_private..=last_private); +} diff -Nru cargo-0.58.0/vendor/fastrand/tests/smoke.rs cargo-0.60.0ubuntu1/vendor/fastrand/tests/smoke.rs --- cargo-0.58.0/vendor/fastrand/tests/smoke.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/fastrand/tests/smoke.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,117 @@ +#[cfg(target_arch = "wasm32")] +use wasm_bindgen_test::*; + +#[cfg(target_arch = "wasm32")] +wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); + +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn bool() { + for x in &[false, true] { + while fastrand::bool() != *x {} + } +} + +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn u8() { + for x in 0..10 { + while fastrand::u8(..10) != x {} + } + + for x in 200..=u8::MAX { + while fastrand::u8(200..) != x {} + } +} + +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn i8() { + for x in -128..-120 { + while fastrand::i8(..-120) != x {} + } + + for x in 120..=127 { + while fastrand::i8(120..) != x {} + } +} + +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn u32() { + for n in 1u32..10_000 { + let n = n.wrapping_mul(n); + let n = n.wrapping_mul(n); + if n != 0 { + for _ in 0..1000 { + assert!(fastrand::u32(..n) < n); + } + } + } +} + +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn u64() { + for n in 1u64..10_000 { + let n = n.wrapping_mul(n); + let n = n.wrapping_mul(n); + let n = n.wrapping_mul(n); + if n != 0 { + for _ in 0..1000 { + assert!(fastrand::u64(..n) < n); + } + } + } +} + +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn u128() { + for n in 1u128..10_000 { + let n = n.wrapping_mul(n); + let n = n.wrapping_mul(n); + let n = n.wrapping_mul(n); + let n = n.wrapping_mul(n); + if n != 0 { + for _ in 0..1000 { + assert!(fastrand::u128(..n) < n); + } + } + } +} + +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn rng() { + let r = fastrand::Rng::new(); + + assert_ne!(r.u64(..), r.u64(..)); + + r.seed(7); + let a = r.u64(..); + r.seed(7); + let b = r.u64(..); + assert_eq!(a, b); +} + +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn rng_init() { + let a = fastrand::Rng::new(); + let b = fastrand::Rng::new(); + assert_ne!(a.u64(..), b.u64(..)); + + a.seed(7); + b.seed(7); + assert_eq!(a.u64(..), b.u64(..)); +} + +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn with_seed() { + let a = fastrand::Rng::with_seed(7); + let b = fastrand::Rng::new(); + b.seed(7); + assert_eq!(a.u64(..), b.u64(..)); +} diff -Nru cargo-0.58.0/vendor/filetime/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/filetime/.cargo-checksum.json --- cargo-0.58.0/vendor/filetime/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/filetime/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98"} \ No newline at end of file +{"files":{},"package":"c0408e2626025178a6a7f7ffc05a25bc47103229f19c113755de7bf63816290c"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/filetime/Cargo.toml cargo-0.60.0ubuntu1/vendor/filetime/Cargo.toml --- cargo-0.58.0/vendor/filetime/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/filetime/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -3,33 +3,46 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "filetime" -version = "0.2.15" +version = "0.2.16" authors = ["Alex Crichton "] -description = "Platform-agnostic accessors of timestamps in File metadata\n" +description = """ +Platform-agnostic accessors of timestamps in File metadata +""" homepage = "https://github.com/alexcrichton/filetime" documentation = "https://docs.rs/filetime" readme = "README.md" -keywords = ["timestamp", "mtime"] +keywords = [ + "timestamp", + "mtime", +] license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/filetime" + [dependencies.cfg-if] version = "1.0.0" + [dev-dependencies.tempfile] version = "3" + [target."cfg(target_os = \"redox\")".dependencies.redox_syscall] version = "0.2.9" + [target."cfg(unix)".dependencies.libc] version = "0.2.27" + [target."cfg(windows)".dependencies.winapi] version = "0.3" -features = ["fileapi", "minwindef", "winbase"] +features = [ + "fileapi", + "minwindef", + "winbase", +] diff -Nru cargo-0.58.0/vendor/filetime/src/lib.rs cargo-0.60.0ubuntu1/vendor/filetime/src/lib.rs --- cargo-0.58.0/vendor/filetime/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/filetime/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -71,14 +71,14 @@ /// Creates a new timestamp representing a 0 time. /// /// Useful for creating the base of a cmp::max chain of times. - pub fn zero() -> FileTime { + pub const fn zero() -> FileTime { FileTime { seconds: 0, nanos: 0, } } - fn emulate_second_only_system(self) -> FileTime { + const fn emulate_second_only_system(self) -> FileTime { if cfg!(emulate_second_only_system) { FileTime { seconds: self.seconds, @@ -118,7 +118,7 @@ /// from, but on Windows the native time stamp is relative to January 1, /// 1601 so the return value of `seconds` from the returned `FileTime` /// instance may not be the same as that passed in. - pub fn from_unix_time(seconds: i64, nanos: u32) -> FileTime { + pub const fn from_unix_time(seconds: i64, nanos: u32) -> FileTime { FileTime { seconds: seconds + if cfg!(windows) { 11644473600 } else { 0 }, nanos, @@ -193,7 +193,7 @@ /// Note that this value's meaning is **platform specific**. On Unix /// platform time stamps are typically relative to January 1, 1970, but on /// Windows platforms time stamps are relative to January 1, 1601. - pub fn seconds(&self) -> i64 { + pub const fn seconds(&self) -> i64 { self.seconds } @@ -202,7 +202,7 @@ /// /// Note that this does not return the same value as `seconds` for Windows /// platforms as seconds are relative to a different date there. - pub fn unix_seconds(&self) -> i64 { + pub const fn unix_seconds(&self) -> i64 { self.seconds - if cfg!(windows) { 11644473600 } else { 0 } } @@ -211,7 +211,7 @@ /// The returned value is always less than one billion and represents a /// portion of a second forward from the seconds returned by the `seconds` /// method. - pub fn nanoseconds(&self) -> u32 { + pub const fn nanoseconds(&self) -> u32 { self.nanos } } @@ -630,7 +630,7 @@ fn set_symlink_dir_times_test() { let td = Builder::new().prefix("filetime").tempdir().unwrap(); let path = td.path().join("foo"); - fs::create_dir(&path); + fs::create_dir(&path).unwrap(); let metadata = fs::metadata(&path).unwrap(); let mtime = FileTime::from_last_modification_time(&metadata); diff -Nru cargo-0.58.0/vendor/filetime/src/unix/android.rs cargo-0.60.0ubuntu1/vendor/filetime/src/unix/android.rs --- cargo-0.58.0/vendor/filetime/src/unix/android.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/filetime/src/unix/android.rs 2022-04-20 13:48:09.000000000 +0000 @@ -37,7 +37,7 @@ } pub fn set_symlink_file_times(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { - set_times(p, Some(atime), Some(mtime), false) + set_times(p, Some(atime), Some(mtime), true) } fn set_times( diff -Nru cargo-0.58.0/vendor/filetime/src/unix/utimes.rs cargo-0.60.0ubuntu1/vendor/filetime/src/unix/utimes.rs --- cargo-0.58.0/vendor/filetime/src/unix/utimes.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/filetime/src/unix/utimes.rs 2022-04-20 13:48:09.000000000 +0000 @@ -118,6 +118,7 @@ } } +#[cfg(target_env = "uclibc")] fn to_timespec(ft: &FileTime) -> libc::timespec { libc::timespec { tv_sec: ft.seconds() as libc::time_t, diff -Nru cargo-0.58.0/vendor/flate2/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/flate2/.cargo-checksum.json --- cargo-0.58.0/vendor/flate2/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f"} \ No newline at end of file +{"files":{},"package":"b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/flate2/Cargo.lock cargo-0.60.0ubuntu1/vendor/flate2/Cargo.lock --- cargo-0.58.0/vendor/flate2/Cargo.lock 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -4,49 +4,15 @@ [[package]] name = "adler" -version = "0.2.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "cc" -version = "1.0.67" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cfg-if" @@ -55,15 +21,6 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - -[[package]] name = "cloudflare-zlib-sys" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -74,173 +31,59 @@ [[package]] name = "cmake" -version = "0.1.45" +version = "0.1.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" +checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" dependencies = [ "cc", ] [[package]] name = "crc32fast" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "crossbeam-deque" -version = "0.7.3" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", + "cfg-if", ] [[package]] name = "flate2" -version = "1.0.22" +version = "1.0.23" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cloudflare-zlib-sys", "crc32fast", - "futures", "libc", "libz-sys", "miniz-sys", "miniz_oxide", "quickcheck", "rand", - "tokio-io", - "tokio-tcp", - "tokio-threadpool", ] [[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" - -[[package]] name = "getrandom" -version = "0.1.15" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ - "cfg-if 0.1.10", + "cfg-if", "libc", "wasi", ] [[package]] -name = "hermit-abi" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" -dependencies = [ - "libc", -] - -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] name = "libc" -version = "0.2.81" +version = "0.2.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" +checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259" [[package]] name = "libz-sys" -version = "1.1.2" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" +checksum = "6f35facd4a5673cb5a48822be2be1d4236c1c99cb4113cab7061ac720d5bf859" dependencies = [ "cc", "cmake", @@ -250,39 +93,6 @@ ] [[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if 0.1.10", -] - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - -[[package]] name = "miniz-sys" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -294,132 +104,50 @@ [[package]] name = "miniz_oxide" -version = "0.4.3" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" dependencies = [ "adler", - "autocfg", -] - -[[package]] -name = "mio" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow", - "net2", - "slab", - "winapi 0.2.8", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", -] - -[[package]] -name = "net2" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "winapi 0.3.9", -] - -[[package]] -name = "num_cpus" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api", - "parking_lot_core", - "rustc_version", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall", - "rustc_version", - "smallvec", - "winapi 0.3.9", ] [[package]] name = "pkg-config" -version = "0.3.19" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "quickcheck" -version = "0.9.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f" +checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ "rand", - "rand_core", ] [[package]] name = "rand" -version = "0.7.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "getrandom", "libc", "rand_chacha", "rand_core", - "rand_hc", ] [[package]] name = "rand_chacha" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core", @@ -427,206 +155,21 @@ [[package]] name = "rand_core" -version = "0.5.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ "getrandom", ] [[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils", - "futures", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes", - "futures", - "log", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils", - "futures", - "lazy_static", - "log", - "mio", - "num_cpus", - "parking_lot", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes", - "futures", - "iovec", - "mio", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" -dependencies = [ - "crossbeam-deque", - "crossbeam-queue", - "crossbeam-utils", - "futures", - "lazy_static", - "log", - "num_cpus", - "slab", - "tokio-executor", -] - -[[package]] name = "vcpkg" -version = "0.2.11" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" -version = "0.3.9" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" diff -Nru cargo-0.58.0/vendor/flate2/Cargo.toml cargo-0.60.0ubuntu1/vendor/flate2/Cargo.toml --- cargo-0.58.0/vendor/flate2/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "flate2" -version = "1.0.22" +version = "1.0.23" authors = ["Alex Crichton ", "Josh Triplett "] description = "DEFLATE compression and decompression exposed as Read/BufRead/Write streams.\nSupports miniz_oxide, miniz.c, and multiple zlib implementations. Supports\nzlib, gzip, and raw deflate streams.\n" homepage = "https://github.com/rust-lang/flate2-rs" @@ -37,16 +37,15 @@ default-features = false [dependencies.miniz_oxide] -version = "0.4.0" +version = "0.5.0" optional = true default-features = false - [dev-dependencies.quickcheck] -version = "0.9" +version = "1.0" default-features = false [dev-dependencies.rand] -version = "0.7" +version = "0.8" [features] default = ["rust_backend"] @@ -54,5 +53,5 @@ miniz-sys = ["zlib"] zlib = ["libz-sys"] [target."cfg(all(target_arch = \"wasm32\", not(target_os = \"emscripten\")))".dependencies.miniz_oxide] -version = "0.4.0" +version = "0.5.0" default-features = false diff -Nru cargo-0.58.0/vendor/flate2/debian/patches/disable-miniz.patch cargo-0.60.0ubuntu1/vendor/flate2/debian/patches/disable-miniz.patch --- cargo-0.58.0/vendor/flate2/debian/patches/disable-miniz.patch 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/debian/patches/disable-miniz.patch 2022-04-20 13:48:09.000000000 +0000 @@ -18,6 +18,6 @@ default = ["rust_backend"] rust_backend = ["miniz_oxide"] +miniz-sys = ["zlib"] - tokio = ["tokio-io", "futures"] zlib = ["any_zlib", "libz-sys"] zlib-ng-compat = ["zlib", "libz-sys/zlib-ng"] + [target."cfg(all(target_arch = \"wasm32\", not(target_os = \"emscripten\")))".dependencies.miniz_oxide] diff -Nru cargo-0.58.0/vendor/flate2/debian/patches/disable-miniz.patch.orig cargo-0.60.0ubuntu1/vendor/flate2/debian/patches/disable-miniz.patch.orig --- cargo-0.58.0/vendor/flate2/debian/patches/disable-miniz.patch.orig 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/debian/patches/disable-miniz.patch.orig 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,23 @@ +Index: flate2/Cargo.toml +=================================================================== +--- flate2.orig/Cargo.toml ++++ flate2/Cargo.toml +@@ -44,10 +44,6 @@ version = "1.1.0" + optional = true + default-features = false + +-[dependencies.miniz-sys] +-version = "0.1.11" +-optional = true +- + [dependencies.miniz_oxide] + version = "0.4.0" + optional = true +@@ -80,6 +76,7 @@ any_zlib = [] + cloudflare_zlib = ["any_zlib", "cloudflare-zlib-sys"] + default = ["rust_backend"] + rust_backend = ["miniz_oxide"] ++miniz-sys = ["zlib"] + tokio = ["tokio-io", "futures"] + zlib = ["any_zlib", "libz-sys"] + zlib-ng-compat = ["zlib", "libz-sys/zlib-ng"] diff -Nru cargo-0.58.0/vendor/flate2/debian/patches/series cargo-0.60.0ubuntu1/vendor/flate2/debian/patches/series --- cargo-0.58.0/vendor/flate2/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -1,5 +1,4 @@ disable-miniz.patch -remove-futures-and-tokio.patch disable-cloudflare-zlib.patch disable-zlib-ng.patch eliminate-any-zlib.patch diff -Nru cargo-0.58.0/vendor/flate2/examples/deflateencoder-read.rs cargo-0.60.0ubuntu1/vendor/flate2/examples/deflateencoder-read.rs --- cargo-0.58.0/vendor/flate2/examples/deflateencoder-read.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/examples/deflateencoder-read.rs 2022-04-20 13:48:09.000000000 +0000 @@ -10,7 +10,7 @@ println!("{:?}", deflateencoder_read_hello_world().unwrap()); } -// Return a vector containing the Defalte compressed version of hello world +// Return a vector containing the Deflate compressed version of hello world fn deflateencoder_read_hello_world() -> io::Result> { let mut result = Vec::new(); let c = b"hello world"; diff -Nru cargo-0.58.0/vendor/flate2/examples/gzbuilder.rs cargo-0.60.0ubuntu1/vendor/flate2/examples/gzbuilder.rs --- cargo-0.58.0/vendor/flate2/examples/gzbuilder.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/examples/gzbuilder.rs 2022-04-20 13:48:09.000000000 +0000 @@ -6,14 +6,14 @@ use std::io; use std::io::prelude::*; -// Open file and debug print the contents compressed with gzip +// Compresses content of a text file into a gzip file fn main() { sample_builder().unwrap(); } // GzBuilder opens a file and writes a sample string using Builder pattern fn sample_builder() -> Result<(), io::Error> { - let f = File::create("examples/hello_world.gz")?; + let f = File::create("examples/hello_world.txt.gz")?; let mut gz = GzBuilder::new() .filename("hello_world.txt") .comment("test file, please delete") diff -Nru cargo-0.58.0/vendor/flate2/examples/gzdecoder-bufread.rs cargo-0.60.0ubuntu1/vendor/flate2/examples/gzdecoder-bufread.rs --- cargo-0.58.0/vendor/flate2/examples/gzdecoder-bufread.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/examples/gzdecoder-bufread.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,8 +1,7 @@ extern crate flate2; -use flate2::bufread::GzDecoder; use flate2::write::GzEncoder; -use flate2::Compression; +use flate2::{bufread, Compression}; use std::io; use std::io::prelude::*; @@ -17,7 +16,7 @@ // Uncompresses a Gz Encoded vector of bytes and returns a string or error // Here &[u8] implements BufRead fn decode_reader(bytes: Vec) -> io::Result { - let mut gz = GzDecoder::new(&bytes[..]); + let mut gz = bufread::GzDecoder::new(&bytes[..]); let mut s = String::new(); gz.read_to_string(&mut s)?; Ok(s) diff -Nru cargo-0.58.0/vendor/flate2/examples/gzdecoder-read.rs cargo-0.60.0ubuntu1/vendor/flate2/examples/gzdecoder-read.rs --- cargo-0.58.0/vendor/flate2/examples/gzdecoder-read.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/examples/gzdecoder-read.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,8 +1,7 @@ extern crate flate2; -use flate2::read::GzDecoder; use flate2::write::GzEncoder; -use flate2::Compression; +use flate2::{read, Compression}; use std::io; use std::io::prelude::*; @@ -17,7 +16,7 @@ // Uncompresses a Gz Encoded vector of bytes and returns a string or error // Here &[u8] implements Read fn decode_reader(bytes: Vec) -> io::Result { - let mut gz = GzDecoder::new(&bytes[..]); + let mut gz = read::GzDecoder::new(&bytes[..]); let mut s = String::new(); gz.read_to_string(&mut s)?; Ok(s) diff -Nru cargo-0.58.0/vendor/flate2/README.md cargo-0.60.0ubuntu1/vendor/flate2/README.md --- cargo-0.58.0/vendor/flate2/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -77,7 +77,7 @@ For compatibility with previous versions of `flate2`, the cloudflare optimized version of zlib is available, via the `cloudflare_zlib` feature. It's not as -fast as zlib-ng, but it's faster than stock zlib. It requires a x86-64 CPU with +fast as zlib-ng, but it's faster than stock zlib. It requires an x86-64 CPU with SSE 4.2 or ARM64 with NEON & CRC. It does not support 32-bit CPUs at all and is incompatible with mingw. For more information check the [crate documentation](https://crates.io/crates/cloudflare-zlib-sys). Note that diff -Nru cargo-0.58.0/vendor/flate2/src/bufreader.rs cargo-0.60.0ubuntu1/vendor/flate2/src/bufreader.rs --- cargo-0.58.0/vendor/flate2/src/bufreader.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/bufreader.rs 2022-04-20 13:48:09.000000000 +0000 @@ -42,7 +42,7 @@ pub fn with_buf(buf: Vec, inner: R) -> BufReader { BufReader { - inner: inner, + inner, buf: buf.into_boxed_slice(), pos: 0, cap: 0, diff -Nru cargo-0.58.0/vendor/flate2/src/crc.rs cargo-0.60.0ubuntu1/vendor/flate2/src/crc.rs --- cargo-0.58.0/vendor/flate2/src/crc.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/crc.rs 2022-04-20 13:48:09.000000000 +0000 @@ -23,6 +23,12 @@ crc: Crc, } +impl Default for Crc { + fn default() -> Self { + Self::new() + } +} + impl Crc { /// Create a new CRC. pub fn new() -> Crc { diff -Nru cargo-0.58.0/vendor/flate2/src/deflate/bufread.rs cargo-0.60.0ubuntu1/vendor/flate2/src/deflate/bufread.rs --- cargo-0.58.0/vendor/flate2/src/deflate/bufread.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/deflate/bufread.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,11 +2,6 @@ use std::io::prelude::*; use std::mem; -#[cfg(feature = "tokio")] -use futures::Poll; -#[cfg(feature = "tokio")] -use tokio_io::{AsyncRead, AsyncWrite}; - use crate::zio; use crate::{Compress, Decompress}; @@ -116,9 +111,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for DeflateEncoder {} - impl Write for DeflateEncoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -129,13 +121,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for DeflateEncoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} - /// A DEFLATE decoder, or decompressor. /// /// This structure consumes a [`BufRead`] interface, reading compressed data @@ -247,9 +232,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for DeflateDecoder {} - impl Write for DeflateDecoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -259,10 +241,3 @@ self.get_mut().flush() } } - -#[cfg(feature = "tokio")] -impl AsyncWrite for DeflateDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} diff -Nru cargo-0.58.0/vendor/flate2/src/deflate/mod.rs cargo-0.60.0ubuntu1/vendor/flate2/src/deflate/mod.rs --- cargo-0.58.0/vendor/flate2/src/deflate/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/deflate/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -17,7 +17,7 @@ let mut w = write::DeflateEncoder::new(Vec::new(), Compression::default()); let v = crate::random_bytes().take(1024).collect::>(); for _ in 0..200 { - let to_write = &v[..thread_rng().gen_range(0, v.len())]; + let to_write = &v[..thread_rng().gen_range(0..v.len())]; real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } @@ -46,7 +46,7 @@ let mut w = write::DeflateEncoder::new(Vec::new(), Compression::default()); let v = crate::random_bytes().take(1024).collect::>(); for _ in 0..200 { - let to_write = &v[..thread_rng().gen_range(0, v.len())]; + let to_write = &v[..thread_rng().gen_range(0..v.len())]; real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } diff -Nru cargo-0.58.0/vendor/flate2/src/deflate/read.rs cargo-0.60.0ubuntu1/vendor/flate2/src/deflate/read.rs --- cargo-0.58.0/vendor/flate2/src/deflate/read.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/deflate/read.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,11 +1,6 @@ use std::io; use std::io::prelude::*; -#[cfg(feature = "tokio")] -use futures::Poll; -#[cfg(feature = "tokio")] -use tokio_io::{AsyncRead, AsyncWrite}; - use super::bufread; use crate::bufreader::BufReader; @@ -113,9 +108,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for DeflateEncoder {} - impl Write for DeflateEncoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -126,13 +118,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for DeflateEncoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} - /// A DEFLATE decoder, or decompressor. /// /// This structure implements a [`Read`] interface and takes a stream of @@ -245,9 +230,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for DeflateDecoder {} - impl Write for DeflateDecoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -257,10 +239,3 @@ self.get_mut().flush() } } - -#[cfg(feature = "tokio")] -impl AsyncWrite for DeflateDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} diff -Nru cargo-0.58.0/vendor/flate2/src/deflate/write.rs cargo-0.60.0ubuntu1/vendor/flate2/src/deflate/write.rs --- cargo-0.58.0/vendor/flate2/src/deflate/write.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/deflate/write.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,11 +1,6 @@ use std::io; use std::io::prelude::*; -#[cfg(feature = "tokio")] -use futures::Poll; -#[cfg(feature = "tokio")] -use tokio_io::{AsyncRead, AsyncWrite}; - use crate::zio; use crate::{Compress, Decompress}; @@ -139,7 +134,7 @@ Ok(self.inner.take_inner()) } - /// Returns the number of bytes that have been written to this compresor. + /// Returns the number of bytes that have been written to this compressor. /// /// Note that not all bytes written to this object may be accounted for, /// there may still be some active buffering. @@ -166,23 +161,12 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for DeflateEncoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.inner.finish()?; - self.inner.get_mut().shutdown() - } -} - impl Read for DeflateEncoder { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.get_mut().read(buf) } } -#[cfg(feature = "tokio")] -impl AsyncRead for DeflateEncoder {} - /// A DEFLATE decoder, or decompressor. /// /// This structure implements a [`Write`] and will emit a stream of decompressed @@ -331,19 +315,8 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for DeflateDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.inner.finish()?; - self.inner.get_mut().shutdown() - } -} - impl Read for DeflateDecoder { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.get_mut().read(buf) } } - -#[cfg(feature = "tokio")] -impl AsyncRead for DeflateDecoder {} diff -Nru cargo-0.58.0/vendor/flate2/src/ffi/c.rs cargo-0.60.0ubuntu1/vendor/flate2/src/ffi/c.rs --- cargo-0.58.0/vendor/flate2/src/ffi/c.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/ffi/c.rs 2022-04-20 13:48:09.000000000 +0000 @@ -109,7 +109,7 @@ extern "C" fn zfree(_ptr: *mut c_void, address: *mut c_void) { unsafe { - // Move our address being free'd back one pointer, read the size we + // Move our address being freed back one pointer, read the size we // stored in `zalloc`, and then free it using the standard Rust // allocator. let ptr = (address as *mut usize).offset(-1); diff -Nru cargo-0.58.0/vendor/flate2/src/gz/bufread.rs cargo-0.60.0ubuntu1/vendor/flate2/src/gz/bufread.rs --- cargo-0.58.0/vendor/flate2/src/gz/bufread.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/gz/bufread.rs 2022-04-20 13:48:09.000000000 +0000 @@ -3,11 +3,6 @@ use std::io::prelude::*; use std::mem; -#[cfg(feature = "tokio")] -use futures::Poll; -#[cfg(feature = "tokio")] -use tokio_io::{AsyncRead, AsyncWrite}; - use super::{GzBuilder, GzHeader}; use super::{FCOMMENT, FEXTRA, FHCRC, FNAME}; use crate::crc::{Crc, CrcReader}; @@ -20,7 +15,7 @@ *slot = *val; } *pos += min; - return min; + min } pub(crate) fn corrupt() -> io::Error { @@ -126,15 +121,7 @@ let mut reader = Buffer::new(&mut part, r); read_gz_header_part(&mut reader) }; - - match result { - Ok(()) => { - return Ok(part.take_header()); - } - Err(err) => { - return Err(err); - } - }; + result.map(|()| part.take_header()) } /// A gzip streaming encoder @@ -179,7 +166,7 @@ let crc = CrcReader::new(r); GzEncoder { inner: deflate::bufread::DeflateEncoder::new(crc, lvl), - header: header, + header, pos: 0, eof: false, } @@ -363,7 +350,7 @@ } pub fn take_header(self) -> GzHeader { - return self.header; + self.header } } @@ -443,7 +430,7 @@ self.part.buf.truncate(0); self.buf_cur = 0; self.buf_max = 0; - return Ok(rlen); + Ok(rlen) } } @@ -523,7 +510,7 @@ let mut reader = Buffer::new(&mut part, reader.get_mut().get_mut()); read_gz_header_part(&mut reader) }; - let state = match result { + match result { Ok(()) => { *header = Some(part.take_header()); GzState::Body @@ -533,8 +520,7 @@ return Err(err); } Err(err) => return Err(err), - }; - state + } } GzState::Body => { if into.is_empty() { @@ -619,9 +605,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for GzDecoder {} - impl Write for GzDecoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -632,13 +615,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for GzDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} - /// A gzip streaming decoder that decodes all members of a multistream /// /// A gzip member consists of a header, compressed data and a trailer. The [gzip @@ -722,26 +698,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for MultiGzDecoder {} - -impl Write for MultiGzDecoder { - fn write(&mut self, buf: &[u8]) -> io::Result { - self.get_mut().write(buf) - } - - fn flush(&mut self) -> io::Result<()> { - self.get_mut().flush() - } -} - -#[cfg(feature = "tokio")] -impl AsyncWrite for MultiGzDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} - #[cfg(test)] pub mod tests { use crate::gz::bufread::*; @@ -870,7 +826,7 @@ } r.set_position(pos2); - // Fourth read : now succesful for 7 bytes + // Fourth read : now successful for 7 bytes let mut reader3 = Buffer::new(&mut part, &mut r); match reader3.read_and_forget(&mut out) { Ok(7) => { @@ -882,7 +838,7 @@ } } - // Fifth read : succesful for one more byte + // Fifth read : successful for one more byte out.resize(1, 0); match reader3.read_and_forget(&mut out) { Ok(1) => { diff -Nru cargo-0.58.0/vendor/flate2/src/gz/mod.rs cargo-0.60.0ubuntu1/vendor/flate2/src/gz/mod.rs --- cargo-0.58.0/vendor/flate2/src/gz/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/gz/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -117,6 +117,12 @@ mtime: u32, } +impl Default for GzBuilder { + fn default() -> Self { + Self::new() + } +} + impl GzBuilder { /// Create a new blank builder with no header by default. pub fn new() -> GzBuilder { @@ -204,28 +210,19 @@ } = self; let mut flg = 0; let mut header = vec![0u8; 10]; - match extra { - Some(v) => { - flg |= FEXTRA; - header.push((v.len() >> 0) as u8); - header.push((v.len() >> 8) as u8); - header.extend(v); - } - None => {} + if let Some(v) = extra { + flg |= FEXTRA; + header.push((v.len() >> 0) as u8); + header.push((v.len() >> 8) as u8); + header.extend(v); } - match filename { - Some(filename) => { - flg |= FNAME; - header.extend(filename.as_bytes_with_nul().iter().map(|x| *x)); - } - None => {} + if let Some(filename) = filename { + flg |= FNAME; + header.extend(filename.as_bytes_with_nul().iter().map(|x| *x)); } - match comment { - Some(comment) => { - flg |= FCOMMENT; - header.extend(comment.as_bytes_with_nul().iter().map(|x| *x)); - } - None => {} + if let Some(comment) = comment { + flg |= FCOMMENT; + header.extend(comment.as_bytes_with_nul().iter().map(|x| *x)); } header[0] = 0x1f; header[1] = 0x8b; @@ -248,7 +245,7 @@ // default this value to 255. I'm not sure that if we "correctly" set // this it'd do anything anyway... header[9] = operating_system.unwrap_or(255); - return header; + header } } @@ -287,7 +284,7 @@ let mut w = write::GzEncoder::new(Vec::new(), Compression::default()); let v = crate::random_bytes().take(1024).collect::>(); for _ in 0..200 { - let to_write = &v[..thread_rng().gen_range(0, v.len())]; + let to_write = &v[..thread_rng().gen_range(0..v.len())]; real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } diff -Nru cargo-0.58.0/vendor/flate2/src/gz/read.rs cargo-0.60.0ubuntu1/vendor/flate2/src/gz/read.rs --- cargo-0.58.0/vendor/flate2/src/gz/read.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/gz/read.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,11 +1,6 @@ use std::io; use std::io::prelude::*; -#[cfg(feature = "tokio")] -use futures::Poll; -#[cfg(feature = "tokio")] -use tokio_io::{AsyncRead, AsyncWrite}; - use super::bufread; use super::{GzBuilder, GzHeader}; use crate::bufreader::BufReader; @@ -43,7 +38,7 @@ } pub fn gz_encoder(inner: bufread::GzEncoder>) -> GzEncoder { - GzEncoder { inner: inner } + GzEncoder { inner } } impl GzEncoder { @@ -175,9 +170,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for GzDecoder {} - impl Write for GzDecoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -188,13 +180,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for GzDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} - /// A gzip streaming decoder that decodes all members of a multistream /// /// A gzip member consists of a header, compressed data and a trailer. The [gzip @@ -282,9 +267,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for MultiGzDecoder {} - impl Write for MultiGzDecoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -294,10 +276,3 @@ self.get_mut().flush() } } - -#[cfg(feature = "tokio")] -impl AsyncWrite for MultiGzDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} diff -Nru cargo-0.58.0/vendor/flate2/src/gz/write.rs cargo-0.60.0ubuntu1/vendor/flate2/src/gz/write.rs --- cargo-0.58.0/vendor/flate2/src/gz/write.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/gz/write.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,11 +2,6 @@ use std::io; use std::io::prelude::*; -#[cfg(feature = "tokio")] -use futures::Poll; -#[cfg(feature = "tokio")] -use tokio_io::{AsyncRead, AsyncWrite}; - use super::bufread::{corrupt, read_gz_header}; use super::{GzBuilder, GzHeader}; use crate::crc::{Crc, CrcWriter}; @@ -47,7 +42,7 @@ GzEncoder { inner: zio::Writer::new(w, Compress::new(lvl, false)), crc: Crc::new(), - header: header, + header, crc_bytes_written: 0, } } @@ -134,7 +129,7 @@ } fn write_header(&mut self) -> io::Result<()> { - while self.header.len() > 0 { + while !self.header.is_empty() { let n = self.inner.get_mut().write(&self.header)?; self.header.drain(..n); } @@ -158,23 +153,12 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for GzEncoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.try_finish()?; - self.get_mut().shutdown() - } -} - impl Read for GzEncoder { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.get_mut().read(buf) } } -#[cfg(feature = "tokio")] -impl AsyncRead for GzEncoder {} - impl Drop for GzEncoder { fn drop(&mut self) { if self.inner.is_present() { @@ -368,13 +352,11 @@ } else { let (n, status) = self.inner.write_with_status(buf)?; - if status == Status::StreamEnd { - if n < buf.len() && self.crc_bytes.len() < 8 { - let remaining = buf.len() - n; - let crc_bytes = cmp::min(remaining, CRC_BYTES_LEN - self.crc_bytes.len()); - self.crc_bytes.extend(&buf[n..n + crc_bytes]); - return Ok(n + crc_bytes); - } + if status == Status::StreamEnd && n < buf.len() && self.crc_bytes.len() < 8 { + let remaining = buf.len() - n; + let crc_bytes = cmp::min(remaining, CRC_BYTES_LEN - self.crc_bytes.len()); + self.crc_bytes.extend(&buf[n..n + crc_bytes]); + return Ok(n + crc_bytes); } Ok(n) } @@ -385,23 +367,12 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for GzDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.try_finish()?; - self.inner.get_mut().get_mut().shutdown() - } -} - impl Read for GzDecoder { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.get_mut().get_mut().read(buf) } } -#[cfg(feature = "tokio")] -impl AsyncRead for GzDecoder {} - #[cfg(test)] mod tests { use super::*; diff -Nru cargo-0.58.0/vendor/flate2/src/lib.rs cargo-0.60.0ubuntu1/vendor/flate2/src/lib.rs --- cargo-0.58.0/vendor/flate2/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -77,30 +77,6 @@ //! [read]: https://doc.rust-lang.org/std/io/trait.Read.html //! [write]: https://doc.rust-lang.org/std/io/trait.Write.html //! [bufread]: https://doc.rust-lang.org/std/io/trait.BufRead.html -//! -//! # Async I/O -//! -//! This crate optionally can support async I/O streams with the [Tokio stack] via -//! the `tokio` feature of this crate: -//! -//! [Tokio stack]: https://tokio.rs/ -//! -//! ```toml -//! flate2 = { version = "0.2", features = ["tokio"] } -//! ``` -//! -//! All methods are internally capable of working with streams that may return -//! [`ErrorKind::WouldBlock`] when they're not ready to perform the particular -//! operation. -//! -//! [`ErrorKind::WouldBlock`]: https://doc.rust-lang.org/std/io/enum.ErrorKind.html -//! -//! Note that care needs to be taken when using these objects, however. The -//! Tokio runtime, in particular, requires that data is fully flushed before -//! dropping streams. For compatibility with blocking streams all streams are -//! flushed/written when they are dropped, and this is not always a suitable -//! time to perform I/O. If I/O streams are flushed before drop, however, then -//! these operations will be a noop. #![doc(html_root_url = "https://docs.rs/flate2/0.2")] #![deny(missing_docs)] #![deny(missing_debug_implementations)] diff -Nru cargo-0.58.0/vendor/flate2/src/mem.rs cargo-0.60.0ubuntu1/vendor/flate2/src/mem.rs --- cargo-0.58.0/vendor/flate2/src/mem.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/mem.rs 2022-04-20 13:48:09.000000000 +0000 @@ -64,7 +64,7 @@ /// All of the input data so far will be available to the decompressor (as /// with `Flush::Sync`. This completes the current deflate block and follows /// it with an empty fixed codes block that is 10 bites long, and it assures - /// that enough bytes are output in order for the decompessor to finish the + /// that enough bytes are output in order for the decompressor to finish the /// block before the empty fixed code block. Partial = ffi::MZ_PARTIAL_FLUSH as isize, @@ -283,7 +283,7 @@ let stream = &mut *self.inner.inner.stream_wrapper; stream.msg = std::ptr::null_mut(); let rc = unsafe { - assert!(dictionary.len() < ffi::uInt::max_value() as usize); + assert!(dictionary.len() < ffi::uInt::MAX as usize); ffi::deflateSetDictionary(stream, dictionary.as_ptr(), dictionary.len() as ffi::uInt) }; @@ -367,7 +367,7 @@ self.compress(input, out, flush) }; output.set_len((self.total_out() - before) as usize + len); - return ret; + ret } } } @@ -411,7 +411,7 @@ /// Creates a new object ready for decompressing data that it's given. /// - /// The Deompress object produced by this constructor expects gzip headers + /// The Decompress object produced by this constructor expects gzip headers /// for the compressed data. /// /// # Panics @@ -508,7 +508,7 @@ self.decompress(input, out, flush) }; output.set_len((self.total_out() - before) as usize + len); - return ret; + ret } } @@ -518,7 +518,7 @@ let stream = &mut *self.inner.inner.stream_wrapper; stream.msg = std::ptr::null_mut(); let rc = unsafe { - assert!(dictionary.len() < ffi::uInt::max_value() as usize); + assert!(dictionary.len() < ffi::uInt::MAX as usize); ffi::inflateSetDictionary(stream, dictionary.as_ptr(), dictionary.len() as ffi::uInt) }; diff -Nru cargo-0.58.0/vendor/flate2/src/zio.rs cargo-0.60.0ubuntu1/vendor/flate2/src/zio.rs --- cargo-0.58.0/vendor/flate2/src/zio.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/zio.rs 2022-04-20 13:48:09.000000000 +0000 @@ -143,7 +143,9 @@ // then we need to keep asking for more data because if we // return that 0 bytes of data have been read then it will // be interpreted as EOF. - Ok(Status::Ok) | Ok(Status::BufError) if read == 0 && !eof && dst.len() > 0 => continue, + Ok(Status::Ok) | Ok(Status::BufError) if read == 0 && !eof && !dst.is_empty() => { + continue + } Ok(Status::Ok) | Ok(Status::BufError) | Ok(Status::StreamEnd) => return Ok(read), Err(..) => { @@ -216,13 +218,9 @@ let before_in = self.data.total_in(); let ret = self.data.run_vec(buf, &mut self.buf, D::Flush::none()); let written = (self.data.total_in() - before_in) as usize; + let is_stream_end = matches!(ret, Ok(Status::StreamEnd)); - let is_stream_end = match ret { - Ok(Status::StreamEnd) => true, - _ => false, - }; - - if buf.len() > 0 && written == 0 && ret.is_ok() && !is_stream_end { + if !buf.is_empty() && written == 0 && ret.is_ok() && !is_stream_end { continue; } return match ret { @@ -240,7 +238,7 @@ fn dump(&mut self) -> io::Result<()> { // TODO: should manage this buffer not with `drain` but probably more of // a deque-like strategy. - while self.buf.len() > 0 { + while !self.buf.is_empty() { let n = self.obj.as_mut().unwrap().write(&self.buf)?; if n == 0 { return Err(io::ErrorKind::WriteZero.into()); diff -Nru cargo-0.58.0/vendor/flate2/src/zlib/bufread.rs cargo-0.60.0ubuntu1/vendor/flate2/src/zlib/bufread.rs --- cargo-0.58.0/vendor/flate2/src/zlib/bufread.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/zlib/bufread.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,11 +2,6 @@ use std::io::prelude::*; use std::mem; -#[cfg(feature = "tokio")] -use futures::Poll; -#[cfg(feature = "tokio")] -use tokio_io::{AsyncRead, AsyncWrite}; - use crate::zio; use crate::{Compress, Decompress}; @@ -112,9 +107,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for ZlibEncoder {} - impl Write for ZlibEncoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -125,13 +117,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for ZlibEncoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} - /// A ZLIB decoder, or decompressor. /// /// This structure consumes a [`BufRead`] interface, reading compressed data @@ -237,9 +222,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for ZlibDecoder {} - impl Write for ZlibDecoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -249,10 +231,3 @@ self.get_mut().flush() } } - -#[cfg(feature = "tokio")] -impl AsyncWrite for ZlibDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} diff -Nru cargo-0.58.0/vendor/flate2/src/zlib/mod.rs cargo-0.60.0ubuntu1/vendor/flate2/src/zlib/mod.rs --- cargo-0.58.0/vendor/flate2/src/zlib/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/zlib/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -18,7 +18,7 @@ let mut w = write::ZlibEncoder::new(Vec::new(), Compression::default()); let v = crate::random_bytes().take(1024).collect::>(); for _ in 0..200 { - let to_write = &v[..thread_rng().gen_range(0, v.len())]; + let to_write = &v[..thread_rng().gen_range(0..v.len())]; real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } @@ -47,7 +47,7 @@ let mut w = write::ZlibEncoder::new(Vec::new(), Compression::default()); let v = crate::random_bytes().take(1024).collect::>(); for _ in 0..200 { - let to_write = &v[..thread_rng().gen_range(0, v.len())]; + let to_write = &v[..thread_rng().gen_range(0..v.len())]; real.extend(to_write.iter().map(|x| *x)); w.write_all(to_write).unwrap(); } diff -Nru cargo-0.58.0/vendor/flate2/src/zlib/read.rs cargo-0.60.0ubuntu1/vendor/flate2/src/zlib/read.rs --- cargo-0.58.0/vendor/flate2/src/zlib/read.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/zlib/read.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,11 +1,6 @@ use std::io; use std::io::prelude::*; -#[cfg(feature = "tokio")] -use futures::Poll; -#[cfg(feature = "tokio")] -use tokio_io::{AsyncRead, AsyncWrite}; - use super::bufread; use crate::bufreader::BufReader; @@ -110,9 +105,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for ZlibEncoder {} - impl Write for ZlibEncoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -123,13 +115,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for ZlibEncoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} - /// A ZLIB decoder, or decompressor. /// /// This structure implements a [`Read`] interface and takes a stream of @@ -244,9 +229,6 @@ } } -#[cfg(feature = "tokio")] -impl AsyncRead for ZlibDecoder {} - impl Write for ZlibDecoder { fn write(&mut self, buf: &[u8]) -> io::Result { self.get_mut().write(buf) @@ -256,10 +238,3 @@ self.get_mut().flush() } } - -#[cfg(feature = "tokio")] -impl AsyncWrite for ZlibDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.get_mut().shutdown() - } -} diff -Nru cargo-0.58.0/vendor/flate2/src/zlib/write.rs cargo-0.60.0ubuntu1/vendor/flate2/src/zlib/write.rs --- cargo-0.58.0/vendor/flate2/src/zlib/write.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/src/zlib/write.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,11 +1,6 @@ use std::io; use std::io::prelude::*; -#[cfg(feature = "tokio")] -use futures::Poll; -#[cfg(feature = "tokio")] -use tokio_io::{AsyncRead, AsyncWrite}; - use crate::zio; use crate::{Compress, Decompress}; @@ -139,7 +134,7 @@ Ok(self.inner.take_inner()) } - /// Returns the number of bytes that have been written to this compresor. + /// Returns the number of bytes that have been written to this compressor. /// /// Note that not all bytes written to this object may be accounted for, /// there may still be some active buffering. @@ -166,23 +161,12 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for ZlibEncoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.try_finish()?; - self.get_mut().shutdown() - } -} - impl Read for ZlibEncoder { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.get_mut().read(buf) } } -#[cfg(feature = "tokio")] -impl AsyncRead for ZlibEncoder {} - /// A ZLIB decoder, or decompressor. /// /// This structure implements a [`Write`] and will emit a stream of decompressed @@ -330,19 +314,8 @@ } } -#[cfg(feature = "tokio")] -impl AsyncWrite for ZlibDecoder { - fn shutdown(&mut self) -> Poll<(), io::Error> { - self.inner.finish()?; - self.inner.get_mut().shutdown() - } -} - impl Read for ZlibDecoder { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.get_mut().read(buf) } } - -#[cfg(feature = "tokio")] -impl AsyncRead for ZlibDecoder {} diff -Nru cargo-0.58.0/vendor/flate2/tests/async-reader.rs cargo-0.60.0ubuntu1/vendor/flate2/tests/async-reader.rs --- cargo-0.58.0/vendor/flate2/tests/async-reader.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/tests/async-reader.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -#![cfg(all(feature = "future", feature = "tokio",feature = "tokio-io"))] - -extern crate flate2; -extern crate futures; -extern crate tokio_io; - -use flate2::read::{GzDecoder, MultiGzDecoder}; -use futures::prelude::*; -use futures::task; -use std::cmp; -use std::fs::File; -use std::io::{self, Read}; -use tokio_io::io::read_to_end; -use tokio_io::AsyncRead; - -struct BadReader { - reader: T, - x: bool, -} - -impl BadReader { - fn new(reader: T) -> BadReader { - BadReader { reader, x: true } - } -} - -impl Read for BadReader { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - if self.x { - self.x = false; - let len = cmp::min(buf.len(), 1); - self.reader.read(&mut buf[..len]) - } else { - self.x = true; - Err(io::ErrorKind::WouldBlock.into()) - } - } -} - -struct AssertAsync(T); - -impl Read for AssertAsync { - fn read(&mut self, buf: &mut [u8]) -> io::Result { - self.0.read(buf) - } -} - -impl AsyncRead for AssertAsync {} - -struct AlwaysNotify(T); - -impl Future for AlwaysNotify { - type Item = T::Item; - type Error = T::Error; - - fn poll(&mut self) -> Poll { - let ret = self.0.poll(); - if let Ok(Async::NotReady) = &ret { - task::current().notify(); - } - ret - } -} - -#[test] -fn test_gz_asyncread() { - let f = File::open("tests/good-file.gz").unwrap(); - - let fut = read_to_end(AssertAsync(GzDecoder::new(BadReader::new(f))), Vec::new()); - let (_, content) = AlwaysNotify(fut).wait().unwrap(); - - let mut expected = Vec::new(); - File::open("tests/good-file.txt") - .unwrap() - .read_to_end(&mut expected) - .unwrap(); - - assert_eq!(content, expected); -} - -#[test] -fn test_multi_gz_asyncread() { - let f = File::open("tests/multi.gz").unwrap(); - - let fut = read_to_end( - AssertAsync(MultiGzDecoder::new(BadReader::new(f))), - Vec::new(), - ); - let (_, content) = AlwaysNotify(fut).wait().unwrap(); - - let mut expected = Vec::new(); - File::open("tests/multi.txt") - .unwrap() - .read_to_end(&mut expected) - .unwrap(); - - assert_eq!(content, expected); -} diff -Nru cargo-0.58.0/vendor/flate2/tests/tokio.rs cargo-0.60.0ubuntu1/vendor/flate2/tests/tokio.rs --- cargo-0.58.0/vendor/flate2/tests/tokio.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/flate2/tests/tokio.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ -#![cfg(feature = "tokio")] - -extern crate flate2; -extern crate futures; -extern crate rand; -extern crate tokio_io; -extern crate tokio_tcp; -extern crate tokio_threadpool; - -use std::io::{Read, Write}; -use std::iter; -use std::net::{Shutdown, TcpListener}; -use std::thread; - -use flate2::read; -use flate2::write; -use flate2::Compression; -use futures::Future; -use rand::{thread_rng, Rng}; -use tokio_io::io::{copy, shutdown}; -use tokio_io::AsyncRead; -use tokio_tcp::TcpStream; - -#[test] -fn tcp_stream_echo_pattern() { - const N: u8 = 16; - const M: usize = 16 * 1024; - - let listener = TcpListener::bind("127.0.0.1:0").unwrap(); - let addr = listener.local_addr().unwrap(); - let t = thread::spawn(move || { - let a = listener.accept().unwrap().0; - let b = a.try_clone().unwrap(); - - let t = thread::spawn(move || { - let mut b = read::DeflateDecoder::new(b); - let mut buf = [0; M]; - for i in 0..N { - b.read_exact(&mut buf).unwrap(); - for byte in buf.iter() { - assert_eq!(*byte, i); - } - } - - assert_eq!(b.read(&mut buf).unwrap(), 0); - }); - - let mut a = write::ZlibEncoder::new(a, Compression::default()); - for i in 0..N { - let buf = [i; M]; - a.write_all(&buf).unwrap(); - } - a.finish().unwrap().shutdown(Shutdown::Write).unwrap(); - - t.join().unwrap(); - }); - - let stream = TcpStream::connect(&addr); - let copy = stream - .and_then(|s| { - let (a, b) = s.split(); - let a = read::ZlibDecoder::new(a); - let b = write::DeflateEncoder::new(b, Compression::default()); - copy(a, b) - }) - .then(|result| { - let (amt, _a, b) = result.unwrap(); - assert_eq!(amt, (N as u64) * (M as u64)); - shutdown(b).map(|_| ()) - }) - .map_err(|err| panic!("{}", err)); - - let threadpool = tokio_threadpool::Builder::new().build(); - threadpool.spawn(copy); - threadpool.shutdown().wait().unwrap(); - t.join().unwrap(); -} - -#[test] -fn echo_random() { - let v = iter::repeat(()) - .take(1024 * 1024) - .map(|()| thread_rng().gen::()) - .collect::>(); - let listener = TcpListener::bind("127.0.0.1:0").unwrap(); - let addr = listener.local_addr().unwrap(); - let v2 = v.clone(); - let t = thread::spawn(move || { - let a = listener.accept().unwrap().0; - let b = a.try_clone().unwrap(); - - let mut v3 = v2.clone(); - let t = thread::spawn(move || { - let mut b = read::DeflateDecoder::new(b); - let mut buf = [0; 1024]; - while v3.len() > 0 { - let n = b.read(&mut buf).unwrap(); - for (actual, expected) in buf[..n].iter().zip(&v3) { - assert_eq!(*actual, *expected); - } - v3.drain(..n); - } - - assert_eq!(b.read(&mut buf).unwrap(), 0); - }); - - let mut a = write::ZlibEncoder::new(a, Compression::default()); - a.write_all(&v2).unwrap(); - a.finish().unwrap().shutdown(Shutdown::Write).unwrap(); - - t.join().unwrap(); - }); - - let stream = TcpStream::connect(&addr); - let copy = stream - .and_then(|s| { - let (a, b) = s.split(); - let a = read::ZlibDecoder::new(a); - let b = write::DeflateEncoder::new(b, Compression::default()); - copy(a, b) - }) - .then(move |result| { - let (amt, _a, b) = result.unwrap(); - assert_eq!(amt, v.len() as u64); - shutdown(b).map(|_| ()) - }) - .map_err(|err| panic!("{}", err)); - - let threadpool = tokio_threadpool::Builder::new().build(); - threadpool.spawn(copy); - threadpool.shutdown().wait().unwrap(); - t.join().unwrap(); -} diff -Nru cargo-0.58.0/vendor/getrandom/benches/mod.rs cargo-0.60.0ubuntu1/vendor/getrandom/benches/mod.rs --- cargo-0.58.0/vendor/getrandom/benches/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/benches/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -#![feature(test)] -extern crate test; - -#[bench] -fn bench_64(b: &mut test::Bencher) { - let mut buf = [0u8; 64]; - b.iter(|| { - getrandom::getrandom(&mut buf[..]).unwrap(); - test::black_box(&buf); - }); - b.bytes = buf.len() as u64; -} - -#[bench] -fn bench_65536(b: &mut test::Bencher) { - let mut buf = [0u8; 65536]; - b.iter(|| { - getrandom::getrandom(&mut buf[..]).unwrap(); - test::black_box(&buf); - }); - b.bytes = buf.len() as u64; -} diff -Nru cargo-0.58.0/vendor/getrandom/build.rs cargo-0.60.0ubuntu1/vendor/getrandom/build.rs --- cargo-0.58.0/vendor/getrandom/build.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/build.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -#![deny(warnings)] - -use std::env; - -fn main() { - let target = env::var("TARGET").expect("TARGET was not set"); - if target.contains("-uwp-windows-") { - // for BCryptGenRandom - println!("cargo:rustc-link-lib=bcrypt"); - } else if target.contains("windows") { - // for RtlGenRandom (aka SystemFunction036) - println!("cargo:rustc-link-lib=advapi32"); - } else if target.contains("apple-ios") { - // for SecRandomCopyBytes and kSecRandomDefault - println!("cargo:rustc-link-lib=framework=Security"); - } -} diff -Nru cargo-0.58.0/vendor/getrandom/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/getrandom/.cargo-checksum.json --- cargo-0.58.0/vendor/getrandom/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -{"files":{},"package":"ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/getrandom/Cargo.toml cargo-0.60.0ubuntu1/vendor/getrandom/Cargo.toml --- cargo-0.58.0/vendor/getrandom/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - -[package] -edition = "2018" -name = "getrandom" -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" -documentation = "https://docs.rs/getrandom" -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 = "0.1.2" - -[dependencies.compiler_builtins] -version = "0.1" -optional = true - -[dependencies.core] -version = "1.0" -optional = true -package = "rustc-std-workspace-core" - -[features] -custom = [] -js = ["stdweb", "wasm-bindgen"] -rdrand = [] -rustc-dep-of-std = ["compiler_builtins", "core"] -std = [] -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 -[badges.appveyor] -repository = "rust-random/getrandom" - -[badges.travis-ci] -repository = "rust-random/getrandom" diff -Nru cargo-0.58.0/vendor/getrandom/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/getrandom/CHANGELOG.md --- cargo-0.58.0/vendor/getrandom/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,204 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [0.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] - -### 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] - -[#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 -- Added support for Internet Explorer 11 [#139] -- Fix Webpack require warning with `wasm-bindgen` [#137] - -[#137]: https://github.com/rust-random/getrandom/pull/137 -[#139]: https://github.com/rust-random/getrandom/pull/139 - -## [0.1.14] - 2020-01-07 -### Changed -- Remove use of spin-locks in the `use_file` module. [#125] -- Update `wasi` to v0.9. [#126] -- Do not read errno value on DragonFlyBSD to fix compilation failure. [#129] - -[#125]: https://github.com/rust-random/getrandom/pull/125 -[#126]: https://github.com/rust-random/getrandom/pull/126 -[#129]: https://github.com/rust-random/getrandom/pull/129 - -## [0.1.13] - 2019-08-25 -### Added -- VxWorks targets support. [#86] - -### Changed -- If zero-length slice is passed to the `getrandom` function, always return -`Ok(())` immediately without doing any calls to the underlying operating -system. [#104] -- Use the `kern.arandom` sysctl on NetBSD. [#115] - -### Fixed -- Bump `cfg-if` minimum version from 0.1.0 to 0.1.2. [#112] -- Typos and bad doc links. [#117] - -[#86]: https://github.com/rust-random/getrandom/pull/86 -[#104]: https://github.com/rust-random/getrandom/pull/104 -[#112]: https://github.com/rust-random/getrandom/pull/112 -[#115]: https://github.com/rust-random/getrandom/pull/115 -[#117]: https://github.com/rust-random/getrandom/pull/117 - -## [0.1.12] - 2019-08-18 -### Changed -- Update wasi dependency from v0.5 to v0.7. [#100] - -[#100]: https://github.com/rust-random/getrandom/pull/100 - -## [0.1.11] - 2019-08-25 -### Fixed -- Implement `std`-dependent traits for selected targets even if `std` -feature is disabled. (backward compatibility with v0.1.8) [#96] - -[#96]: https://github.com/rust-random/getrandom/pull/96 - -## [0.1.10] - 2019-08-18 [YANKED] -### Changed -- Use the dummy implementation on `wasm32-unknown-unknown` even with the -disabled `dummy` feature. [#90] - -### Fixed -- Fix CSP error for `wasm-bindgen`. [#92] - -[#90]: https://github.com/rust-random/getrandom/pull/90 -[#92]: https://github.com/rust-random/getrandom/pull/92 - -## [0.1.9] - 2019-08-14 [YANKED] -### Changed -- Remove `std` dependency for opening and reading files. [#58] -- Use `wasi` isntead of `libc` on WASI target. [#64] -- By default emit a compile-time error when built for an unsupported target. -This behaviour can be disabled by using the `dummy` feature. [#71] - -### Added -- Add support for UWP targets. [#69] -- Add unstable `rustc-dep-of-std` feature. [#78] - -[#58]: https://github.com/rust-random/getrandom/pull/58 -[#64]: https://github.com/rust-random/getrandom/pull/64 -[#69]: https://github.com/rust-random/getrandom/pull/69 -[#71]: https://github.com/rust-random/getrandom/pull/71 -[#78]: https://github.com/rust-random/getrandom/pull/78 - -## [0.1.8] - 2019-07-29 -### Changed -- Explicitly specify types to arguments of 'libc::syscall'. [#74] - -[#74]: https://github.com/rust-random/getrandom/pull/74 - -## [0.1.7] - 2019-07-29 -### Added -- Support for hermit and l4re. [#61] -- `Error::raw_os_error` method, `Error::INTERNAL_START` and -`Error::CUSTOM_START` constants. Use `libc` for retrieving OS error descriptions. [#54] - -### Changed -- Remove `lazy_static` dependency and use custom structures for lock-free -initialization. [#51] [#52] -- Try `getrandom()` first on FreeBSD. [#57] - -### Removed -- Bitrig support. [#56] - -### Deprecated -- `Error::UNKNOWN`, `Error::UNAVAILABLE`. [#54] - -[#51]: https://github.com/rust-random/getrandom/pull/51 -[#52]: https://github.com/rust-random/getrandom/pull/52 -[#54]: https://github.com/rust-random/getrandom/pull/54 -[#56]: https://github.com/rust-random/getrandom/pull/56 -[#57]: https://github.com/rust-random/getrandom/pull/57 -[#61]: https://github.com/rust-random/getrandom/pull/61 - -## [0.1.6] - 2019-06-30 -### Changed -- Minor change of RDRAND AMD bug handling. [#48] - -[#48]: https://github.com/rust-random/getrandom/pull/48 - -## [0.1.5] - 2019-06-29 -### Fixed -- Use shared `File` instead of shared file descriptor. [#44] -- Workaround for RDRAND hardware bug present on some AMD CPUs. [#43] - -### Changed -- Try `getentropy` and then fallback to `/dev/random` on macOS. [#38] - -[#38]: https://github.com/rust-random/getrandom/issues/38 -[#43]: https://github.com/rust-random/getrandom/pull/43 -[#44]: https://github.com/rust-random/getrandom/issues/44 - -## [0.1.4] - 2019-06-28 -### Added -- Add support for `x86_64-unknown-uefi` target by using RDRAND with CPUID -feature detection. [#30] - -### Fixed -- Fix long buffer issues on Windows and Linux. [#31] [#32] -- Check `EPERM` in addition to `ENOSYS` on Linux. [#37] - -### Changed -- Improve efficiency by sharing file descriptor across threads. [#13] -- Remove `cloudabi`, `winapi`, and `fuchsia-cprng` dependencies. [#40] -- Improve RDRAND implementation. [#24] -- Don't block during syscall detection on Linux. [#26] -- Increase consistency with libc implementation on FreeBSD. [#36] -- Apply `rustfmt`. [#39] - -[#30]: https://github.com/rust-random/getrandom/pull/30 -[#13]: https://github.com/rust-random/getrandom/issues/13 -[#40]: https://github.com/rust-random/getrandom/pull/40 -[#26]: https://github.com/rust-random/getrandom/pull/26 -[#24]: https://github.com/rust-random/getrandom/pull/24 -[#39]: https://github.com/rust-random/getrandom/pull/39 -[#36]: https://github.com/rust-random/getrandom/pull/36 -[#31]: https://github.com/rust-random/getrandom/issues/31 -[#32]: https://github.com/rust-random/getrandom/issues/32 -[#37]: https://github.com/rust-random/getrandom/issues/37 - -## [0.1.3] - 2019-05-15 -- Update for `wasm32-unknown-wasi` being renamed to `wasm32-wasi`, and for - WASI being categorized as an OS. - -## [0.1.2] - 2019-04-06 -- Add support for `wasm32-unknown-wasi` target. - -## [0.1.1] - 2019-04-05 -- Enable std functionality for CloudABI by default. - -## [0.1.0] - 2019-03-23 -Publish initial implementation. - -## [0.0.0] - 2019-01-19 -Publish an empty template library. diff -Nru cargo-0.58.0/vendor/getrandom/debian/patches/drop-wasi.patch cargo-0.60.0ubuntu1/vendor/getrandom/debian/patches/drop-wasi.patch --- cargo-0.58.0/vendor/getrandom/debian/patches/drop-wasi.patch 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/debian/patches/drop-wasi.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -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] - version = "0.2.64" - default-features = false diff -Nru cargo-0.58.0/vendor/getrandom/debian/patches/series cargo-0.60.0ubuntu1/vendor/getrandom/debian/patches/series --- cargo-0.58.0/vendor/getrandom/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -drop-wasi.patch diff -Nru cargo-0.58.0/vendor/getrandom/LICENSE-APACHE cargo-0.60.0ubuntu1/vendor/getrandom/LICENSE-APACHE --- cargo-0.58.0/vendor/getrandom/LICENSE-APACHE 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff -Nru cargo-0.58.0/vendor/getrandom/LICENSE-MIT cargo-0.60.0ubuntu1/vendor/getrandom/LICENSE-MIT --- cargo-0.58.0/vendor/getrandom/LICENSE-MIT 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -Copyright 2018 Developers of the Rand project -Copyright (c) 2014 The Rust Project Developers - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff -Nru cargo-0.58.0/vendor/getrandom/README.md cargo-0.60.0ubuntu1/vendor/getrandom/README.md --- cargo-0.58.0/vendor/getrandom/README.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -# getrandom - -[![Build Status](https://travis-ci.org/rust-random/getrandom.svg?branch=master)](https://travis-ci.org/rust-random/getrandom) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/getrandom?svg=true)](https://ci.appveyor.com/project/rust-random/getrandom) -[![Crate](https://img.shields.io/crates/v/getrandom.svg)](https://crates.io/crates/getrandom) -[![Documentation](https://docs.rs/getrandom/badge.svg)](https://docs.rs/getrandom) -[![Dependency status](https://deps.rs/repo/github/rust-random/getrandom/status.svg)](https://deps.rs/repo/github/rust-random/getrandom) - - -A Rust library for retrieving random data from (operating) system source. It is -assumed that system always provides high-quality cryptographically secure random -data, ideally backed by hardware entropy sources. This crate derives its name -from Linux's `getrandom` function, but is cross platform, roughly supporting -the same set of platforms as Rust's `std` lib. - -This is a low-level API. Most users should prefer using high-level random-number -library like [`rand`]. - -[`rand`]: https://crates.io/crates/rand - -## Usage - -Add this to your `Cargo.toml`: - -```toml -[dependencies] -getrandom = "0.2" -``` - -Then invoke the `getrandom` function: - -```rust -fn get_random_buf() -> Result<[u8; 32], getrandom::Error> { - let mut buf = [0u8; 32]; - getrandom::getrandom(&mut buf)?; - Ok(buf) -} -``` - -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.34.0 or later. - -# License - -The `getrandom` library is distributed under either of - - * [Apache License, Version 2.0](LICENSE-APACHE) - * [MIT license](LICENSE-MIT) - -at your option. diff -Nru cargo-0.58.0/vendor/getrandom/src/bsd_arandom.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/bsd_arandom.rs --- cargo-0.58.0/vendor/getrandom/src/bsd_arandom.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/bsd_arandom.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +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 FreeBSD and NetBSD -use crate::{util_libc::sys_fill_exact, Error}; -use core::ptr; - -fn kern_arnd(buf: &mut [u8]) -> libc::ssize_t { - static MIB: [libc::c_int; 2] = [libc::CTL_KERN, libc::KERN_ARND]; - let mut len = buf.len(); - let ret = unsafe { - libc::sysctl( - MIB.as_ptr(), - MIB.len() as libc::c_uint, - buf.as_mut_ptr() as *mut _, - &mut len, - ptr::null(), - 0, - ) - }; - if ret == -1 { - -1 - } else { - len as libc::ssize_t - } -} - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - #[cfg(target_os = "freebsd")] - { - use crate::util_libc::Weak; - static GETRANDOM: Weak = unsafe { Weak::new("getrandom\0") }; - type GetRandomFn = - unsafe extern "C" fn(*mut u8, libc::size_t, libc::c_uint) -> libc::ssize_t; - - if let Some(fptr) = GETRANDOM.ptr() { - let func: GetRandomFn = unsafe { core::mem::transmute(fptr) }; - return sys_fill_exact(dest, |buf| unsafe { func(buf.as_mut_ptr(), buf.len(), 0) }); - } - } - // 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.58.0/vendor/getrandom/src/cloudabi.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/cloudabi.rs --- cargo-0.58.0/vendor/getrandom/src/cloudabi.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/cloudabi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +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 CloudABI -use crate::Error; -use core::num::NonZeroU32; - -extern "C" { - fn cloudabi_sys_random_get(buf: *mut u8, buf_len: usize) -> u16; -} - -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) { - Err(Error::from(code)) - } else { - Ok(()) // Zero means success for CloudABI - } -} diff -Nru cargo-0.58.0/vendor/getrandom/src/custom.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/custom.rs --- cargo-0.58.0/vendor/getrandom/src/custom.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/custom.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +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. - -//! 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.58.0/vendor/getrandom/src/error_impls.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/error_impls.rs --- cargo-0.58.0/vendor/getrandom/src/error_impls.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/error_impls.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +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. -extern crate std; - -use crate::Error; -use core::convert::From; -use std::io; - -impl From for io::Error { - fn from(err: Error) -> Self { - match err.raw_os_error() { - Some(errno) => io::Error::from_raw_os_error(errno), - None => io::Error::new(io::ErrorKind::Other, err), - } - } -} - -impl std::error::Error for Error {} diff -Nru cargo-0.58.0/vendor/getrandom/src/error.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/error.rs --- cargo-0.58.0/vendor/getrandom/src/error.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/error.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +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. -use core::{fmt, num::NonZeroU32}; - -/// 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 -/// encountered, please consult with your system documentation. -/// -/// 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 { - /// 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 - /// reserved for use by the `rand` and `getrandom` crates. - pub const INTERNAL_START: u32 = 1 << 31; - - /// Codes at or above this point can be used by users to define their own - /// custom errors. - pub const CUSTOM_START: u32 = (1 << 31) + (1 << 30); - - /// Extract the raw OS error code (if this error came from the OS) - /// - /// This method is identical to [`std::io::Error::raw_os_error()`][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 { - Some(self.0.get() as i32) - } else { - None - } - } - - /// Extract the bare error code. - /// - /// This code can either come from the underlying OS, or be a custom error. - /// Use [`Error::raw_os_error()`] to disambiguate. - #[inline] - pub const fn code(self) -> NonZeroU32 { - self.0 - } -} - -cfg_if! { - if #[cfg(unix)] { - fn os_err(errno: i32, buf: &mut [u8]) -> Option<&str> { - let buf_ptr = buf.as_mut_ptr() as *mut libc::c_char; - if unsafe { libc::strerror_r(errno, buf_ptr, buf.len()) } != 0 { - return None; - } - - // Take up to trailing null byte - let n = buf.len(); - let idx = buf.iter().position(|&b| b == 0).unwrap_or(n); - core::str::from_utf8(&buf[..idx]).ok() - } - } else if #[cfg(target_os = "wasi")] { - fn os_err(errno: i32, _buf: &mut [u8]) -> Option { - wasi::Error::from_raw_error(errno as _) - } - } else { - fn os_err(_errno: i32, _buf: &mut [u8]) -> Option<&str> { - None - } - } -} - -impl fmt::Debug for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut dbg = f.debug_struct("Error"); - if let Some(errno) = self.raw_os_error() { - dbg.field("os_error", &errno); - let mut buf = [0u8; 128]; - if let Some(err) = os_err(errno, &mut buf) { - dbg.field("description", &err); - } - } else if let Some(desc) = internal_desc(*self) { - dbg.field("internal_code", &self.0.get()); - dbg.field("description", &desc); - } else { - dbg.field("unknown_code", &self.0.get()); - } - dbg.finish() - } -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if let Some(errno) = self.raw_os_error() { - let mut buf = [0u8; 128]; - match os_err(errno, &mut buf) { - Some(err) => err.fmt(f), - None => write!(f, "OS Error: {}", errno), - } - } else if let Some(desc) = internal_desc(*self) { - f.write_str(desc) - } else { - write!(f, "Unknown Error: {}", self.0.get()) - } - } -} - -impl From for Error { - fn from(code: NonZeroU32) -> Self { - Self(code) - } -} - -fn internal_desc(error: Error) -> Option<&'static str> { - match error { - 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, - } -} - -#[cfg(test)] -mod tests { - use super::Error; - use core::mem::size_of; - - #[test] - fn test_size() { - assert_eq!(size_of::(), 4); - assert_eq!(size_of::>(), 4); - } -} diff -Nru cargo-0.58.0/vendor/getrandom/src/fuchsia.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/fuchsia.rs --- cargo-0.58.0/vendor/getrandom/src/fuchsia.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/fuchsia.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +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 Fuchsia Zircon -use crate::Error; - -#[link(name = "zircon")] -extern "C" { - fn zx_cprng_draw(buffer: *mut u8, length: usize); -} - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - unsafe { zx_cprng_draw(dest.as_mut_ptr(), dest.len()) } - Ok(()) -} diff -Nru cargo-0.58.0/vendor/getrandom/src/ios.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/ios.rs --- cargo-0.58.0/vendor/getrandom/src/ios.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/ios.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +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 iOS -use crate::Error; -use core::{ffi::c_void, ptr::null}; - -#[link(name = "Security", kind = "framework")] -extern "C" { - fn SecRandomCopyBytes(rnd: *const c_void, count: usize, bytes: *mut u8) -> i32; -} - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - // 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(Error::IOS_SEC_RANDOM) - } else { - Ok(()) - } -} diff -Nru cargo-0.58.0/vendor/getrandom/src/lib.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/lib.rs --- cargo-0.58.0/vendor/getrandom/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,252 +0,0 @@ -// Copyright 2019 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Interface to the operating system's random number generator. -//! -//! # Supported targets -//! -//! | 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. -//! -//! Pull Requests that add support for new targets to `getrandom` are always welcome. -//! -//! ## Unsupported targets -//! -//! 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 -//! -//! 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 system interfaces always block until the RNG is securely -//! seeded. This can take anywhere from a few seconds to more than a minute. -//! 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), 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 -//! -//! We always choose failure over returning insecure "random" bytes. In general, -//! on supported platforms, failure is highly unlikely, though not impossible. -//! If an error does occur, then it is likely that it will occur on every call to -//! `getrandom`, hence after the first successful call one can be reasonably -//! confident that no errors will occur. -//! -//! [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 -//! [4]: https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc -//! [5]: https://www.freebsd.org/cgi/man.cgi?query=random&sektion=4 -//! [6]: https://man.openbsd.org/getentropy.2 -//! [7]: https://netbsd.gw.com/cgi-bin/man-cgi?sysctl+7+NetBSD-8.0 -//! [8]: https://leaf.dragonflybsd.org/cgi/web-man?command=random§ion=4 -//! [9]: https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html -//! [10]: https://docs.oracle.com/cd/E86824_01/html/E54777/random-7d.html -//! [11]: https://fuchsia.dev/fuchsia-src/zircon/syscalls/cprng_draw -//! [12]: https://github.com/redox-os/randd/blob/master/src/main.rs -//! [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]: #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://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", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://rust-random.github.io/rand/" -)] -#![no_std] -#![warn(rust_2018_idioms, unused_lifetimes, missing_docs)] - -#[macro_use] -extern crate cfg_if; - -mod error; -mod util; -// 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(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(any(target_os = "illumos", target_os = "solaris"))] { - mod util_libc; - 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 = "ios")] { - #[path = "ios.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 = "openbsd")] { - mod util_libc; - #[path = "openbsd.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, 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", target_env = "sgx"))] { - #[path = "rdrand.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"); - } -} - -/// Fill `dest` with random bytes from the system's preferred random number -/// source. -/// -/// This function returns an error on any failure, including partial reads. We -/// make no guarantees regarding the contents of `dest` on error. If `dest` is -/// empty, `getrandom` immediately returns success, making no calls to the -/// underlying operating system. -/// -/// Blocking is possible, at least during early boot; see module documentation. -/// -/// 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> { - if dest.is_empty() { - return Ok(()); - } - imp::getrandom_inner(dest) -} - -#[cfg(test)] -mod test_common; -#[cfg(test)] -mod test_rdrand; diff -Nru cargo-0.58.0/vendor/getrandom/src/linux_android.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/linux_android.rs --- cargo-0.58.0/vendor/getrandom/src/linux_android.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/linux_android.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +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 Linux / Android -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(); - if HAS_GETRANDOM.unsync_init(is_getrandom_available) { - sys_fill_exact(dest, |buf| unsafe { - getrandom(buf.as_mut_ptr() as *mut libc::c_void, buf.len(), 0) - }) - } else { - use_file::getrandom_inner(dest) - } -} - -fn is_getrandom_available() -> bool { - let res = unsafe { getrandom(core::ptr::null_mut(), 0, libc::GRND_NONBLOCK) }; - if res < 0 { - match last_os_error().raw_os_error() { - Some(libc::ENOSYS) => false, // No kernel support - Some(libc::EPERM) => false, // Blocked by seccomp - _ => true, - } - } else { - true - } -} - -unsafe fn getrandom( - buf: *mut libc::c_void, - buflen: libc::size_t, - flags: libc::c_uint, -) -> libc::ssize_t { - libc::syscall(libc::SYS_getrandom, buf, buflen, flags) as libc::ssize_t -} diff -Nru cargo-0.58.0/vendor/getrandom/src/macos.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/macos.rs --- cargo-0.58.0/vendor/getrandom/src/macos.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/macos.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2019 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Implementation for macOS -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; - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - static GETENTROPY: Weak = unsafe { Weak::new("getentropy\0") }; - if let Some(fptr) = GETENTROPY.ptr() { - let func: GetEntropyFn = unsafe { mem::transmute(fptr) }; - for chunk in dest.chunks_mut(256) { - let ret = unsafe { func(chunk.as_mut_ptr(), chunk.len()) }; - if ret != 0 { - return Err(last_os_error()); - } - } - Ok(()) - } else { - // We fallback to reading from /dev/random instead of SecRandomCopyBytes - // to avoid high startup costs and linking the Security framework. - use_file::getrandom_inner(dest) - } -} diff -Nru cargo-0.58.0/vendor/getrandom/src/openbsd.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/openbsd.rs --- cargo-0.58.0/vendor/getrandom/src/openbsd.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/openbsd.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +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 OpenBSD -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 { - return Err(last_os_error()); - } - } - Ok(()) -} diff -Nru cargo-0.58.0/vendor/getrandom/src/rdrand.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/rdrand.rs --- cargo-0.58.0/vendor/getrandom/src/rdrand.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/rdrand.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Implementation for SGX using RDRAND instruction -use crate::Error; -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::(); - -#[target_feature(enable = "rdrand")] -unsafe fn rdrand() -> Result<[u8; WORD_SIZE], Error> { - for _ in 0..RETRY_LIMIT { - let mut el = mem::zeroed(); - 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 - // We perform this check regardless of target to guard against - // any implementation that incorrectly fails to set CF. - if el != 0 && el != !0 { - return Ok(el.to_ne_bytes()); - } - // Keep looping in case this was a false positive. - } - } - Err(Error::FAILED_RDRAND) -} - -// "rdrand" target feature requires "+rdrnd" flag, see https://github.com/rust-lang/rust/issues/49653. -#[cfg(all(target_env = "sgx", not(target_feature = "rdrand")))] -compile_error!( - "SGX targets require 'rdrand' target feature. Enable by using -C target-feature=+rdrnd." -); - -#[cfg(target_feature = "rdrand")] -fn is_rdrand_supported() -> bool { - true -} - -// TODO use is_x86_feature_detected!("rdrand") when that works in core. See: -// https://github.com/rust-lang-nursery/stdsimd/issues/464 -#[cfg(not(target_feature = "rdrand"))] -fn is_rdrand_supported() -> bool { - 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 { (arch::__cpuid(1).ecx & FLAG) != 0 }) -} - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - if !is_rdrand_supported() { - return Err(Error::NO_RDRAND); - } - - // SAFETY: After this point, rdrand is supported, so calling the rdrand - // functions is not undefined behavior. - unsafe { rdrand_exact(dest) } -} - -#[target_feature(enable = "rdrand")] -unsafe fn rdrand_exact(dest: &mut [u8]) -> Result<(), Error> { - // We use chunks_exact_mut instead of chunks_mut as it allows almost all - // calls to memcpy to be elided by the compiler. - let mut chunks = dest.chunks_exact_mut(WORD_SIZE); - for chunk in chunks.by_ref() { - chunk.copy_from_slice(&rdrand()?); - } - - let tail = chunks.into_remainder(); - let n = tail.len(); - if n > 0 { - tail.copy_from_slice(&rdrand()?[..n]); - } - Ok(()) -} diff -Nru cargo-0.58.0/vendor/getrandom/src/solaris_illumos.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/solaris_illumos.rs --- cargo-0.58.0/vendor/getrandom/src/solaris_illumos.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/solaris_illumos.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +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 the Solaris family -//! -//! Read from `/dev/random`, with chunks of limited size (256 bytes). -//! `/dev/random` uses the Hash_DRBG with SHA512 algorithm from NIST SP 800-90A. -//! `/dev/urandom` uses the FIPS 186-2 algorithm, which is considered less -//! secure. We choose to read from `/dev/random`. -//! -//! Since Solaris 11.3 and mid-2015 illumos, the `getrandom` syscall is available. -//! 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::{ - use_file, - util_libc::{sys_fill_exact, Weak}, - Error, -}; -use core::mem; - -#[cfg(target_os = "illumos")] -type GetRandomFn = unsafe extern "C" fn(*mut u8, libc::size_t, libc::c_uint) -> libc::ssize_t; -#[cfg(target_os = "solaris")] -type GetRandomFn = unsafe extern "C" fn(*mut u8, libc::size_t, libc::c_uint) -> libc::c_int; - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - static GETRANDOM: Weak = unsafe { Weak::new("getrandom\0") }; - if let Some(fptr) = GETRANDOM.ptr() { - let func: GetRandomFn = unsafe { mem::transmute(fptr) }; - // 256 bytes is the lowest common denominator across all the Solaris - // derived platforms for atomically obtaining random data. - for chunk in dest.chunks_mut(256) { - sys_fill_exact(chunk, |buf| unsafe { - func(buf.as_mut_ptr(), buf.len(), 0) as libc::ssize_t - })? - } - Ok(()) - } else { - use_file::getrandom_inner(dest) - } -} diff -Nru cargo-0.58.0/vendor/getrandom/src/stdweb.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/stdweb.rs --- cargo-0.58.0/vendor/getrandom/src/stdweb.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/stdweb.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +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. -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.58.0/vendor/getrandom/src/test_common.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/test_common.rs --- cargo-0.58.0/vendor/getrandom/src/test_common.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/test_common.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -// 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.58.0/vendor/getrandom/src/test_rdrand.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/test_rdrand.rs --- cargo-0.58.0/vendor/getrandom/src/test_rdrand.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/test_rdrand.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -// 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.58.0/vendor/getrandom/src/use_file.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/use_file.rs --- cargo-0.58.0/vendor/getrandom/src/use_file.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/use_file.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +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. - -//! Implementations that just need to read from a file -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"; -#[cfg(any( - target_os = "dragonfly", - target_os = "emscripten", - target_os = "haiku", - target_os = "macos", - target_os = "solaris", - target_os = "illumos" -))] -const FILE_PATH: &str = "/dev/random\0"; -#[cfg(any(target_os = "android", target_os = "linux"))] -const FILE_PATH: &str = "/dev/urandom\0"; - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - let fd = get_rng_fd()?; - let read = |buf: &mut [u8]| unsafe { libc::read(fd, buf.as_mut_ptr() as *mut _, buf.len()) }; - - if cfg!(target_os = "emscripten") { - // `Crypto.getRandomValues` documents `dest` should be at most 65536 bytes. - for chunk in dest.chunks_mut(65536) { - sys_fill_exact(chunk, read)?; - } - } else { - sys_fill_exact(dest, read)?; - } - Ok(()) -} - -// Returns the file descriptor for the device file used to retrieve random -// bytes. The file will be opened exactly once. All successful calls will -// return the same file descriptor. This file descriptor is never closed. -fn get_rng_fd() -> Result { - static FD: AtomicUsize = AtomicUsize::new(LazyUsize::UNINIT); - fn get_fd() -> Option { - match FD.load(Relaxed) { - LazyUsize::UNINIT => None, - val => Some(val as libc::c_int), - } - } - - // Use double-checked locking to avoid acquiring the lock if possible. - if let Some(fd) = get_fd() { - return Ok(fd); - } - - // SAFETY: We use the mutex only in this method, and we always unlock it - // before returning, making sure we don't violate the pthread_mutex_t API. - static MUTEX: Mutex = Mutex::new(); - unsafe { MUTEX.lock() }; - let _guard = DropGuard(|| unsafe { MUTEX.unlock() }); - - if let Some(fd) = get_fd() { - return Ok(fd); - } - - // On Linux, /dev/urandom might return insecure values. - #[cfg(any(target_os = "android", target_os = "linux"))] - wait_until_rng_ready()?; - - let fd = unsafe { open_readonly(FILE_PATH)? }; - // The fd always fits in a usize without conflicting with UNINIT. - debug_assert!(fd >= 0 && (fd as usize) < LazyUsize::UNINIT); - FD.store(fd as usize, Relaxed); - - Ok(fd) -} - -// Succeeds once /dev/urandom is safe to read from -#[cfg(any(target_os = "android", target_os = "linux"))] -fn wait_until_rng_ready() -> Result<(), Error> { - // Poll /dev/random to make sure it is ok to read from /dev/urandom. - let fd = unsafe { open_readonly("/dev/random\0")? }; - let mut pfd = libc::pollfd { - fd, - events: libc::POLLIN, - revents: 0, - }; - let _guard = DropGuard(|| unsafe { - libc::close(fd); - }); - - loop { - // A negative timeout means an infinite timeout. - let res = unsafe { libc::poll(&mut pfd, 1, -1) }; - if res >= 0 { - debug_assert_eq!(res, 1); // We only used one fd, and cannot timeout. - return Ok(()); - } - let err = crate::util_libc::last_os_error(); - match err.raw_os_error() { - Some(libc::EINTR) | Some(libc::EAGAIN) => continue, - _ => return Err(err), - } - } -} - -struct Mutex(UnsafeCell); - -impl Mutex { - const fn new() -> Self { - Self(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER)) - } - unsafe fn lock(&self) { - let r = libc::pthread_mutex_lock(self.0.get()); - debug_assert_eq!(r, 0); - } - unsafe fn unlock(&self) { - let r = libc::pthread_mutex_unlock(self.0.get()); - debug_assert_eq!(r, 0); - } -} - -unsafe impl Sync for Mutex {} - -struct DropGuard(F); - -impl Drop for DropGuard { - fn drop(&mut self) { - self.0() - } -} diff -Nru cargo-0.58.0/vendor/getrandom/src/util_libc.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/util_libc.rs --- cargo-0.58.0/vendor/getrandom/src/util_libc.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/util_libc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -// Copyright 2019 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![allow(dead_code)] -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"))] { - use libc::__errno as errno_location; - } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "redox"))] { - use libc::__errno_location as errno_location; - } else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] { - use libc::___errno as errno_location; - } else if #[cfg(any(target_os = "macos", target_os = "freebsd"))] { - use libc::__error as errno_location; - } else if #[cfg(target_os = "haiku")] { - use libc::_errnop as errno_location; - } -} - -cfg_if! { - if #[cfg(target_os = "vxworks")] { - use libc::errnoGet as get_errno; - } else if #[cfg(target_os = "dragonfly")] { - // Until rust-lang/rust#29594 is stable, we cannot get the errno value - // on DragonFlyBSD. So we just return an out-of-range errno. - unsafe fn get_errno() -> libc::c_int { -1 } - } else { - unsafe fn get_errno() -> libc::c_int { *errno_location() } - } -} - -pub fn last_os_error() -> Error { - let errno = unsafe { get_errno() }; - if errno > 0 { - Error::from(NonZeroU32::new(errno as u32).unwrap()) - } else { - Error::ERRNO_NOT_POSITIVE - } -} - -// Fill a buffer by repeatedly invoking a system call. The `sys_fill` function: -// - should return -1 and set errno on failure -// - should return the number of bytes written on success -pub fn sys_fill_exact( - mut buf: &mut [u8], - sys_fill: impl Fn(&mut [u8]) -> libc::ssize_t, -) -> Result<(), Error> { - while !buf.is_empty() { - let res = sys_fill(buf); - if res < 0 { - let err = last_os_error(); - // We should try again if the call was interrupted. - if err.raw_os_error() != Some(libc::EINTR) { - return Err(err); - } - } else { - // We don't check for EOF (ret = 0) as the data we are reading - // should be an infinite stream of random bytes. - buf = &mut buf[(res as usize)..]; - } - } - Ok(()) -} - -// A "weak" binding to a C function that may or may not be present at runtime. -// Used for supporting newer OS features while still building on older systems. -// F must be a function pointer of type `unsafe extern "C" fn`. Based off of the -// weak! macro in libstd. -pub struct Weak { - name: &'static str, - addr: LazyUsize, -} - -impl Weak { - // Construct a binding to a C function with a given name. This function is - // unsafe because `name` _must_ be null terminated. - pub const unsafe fn new(name: &'static str) -> Self { - Self { - name, - addr: LazyUsize::new(), - } - } - - // Return a function pointer if present at runtime. Otherwise, return null. - pub fn ptr(&self) -> Option> { - let addr = self.addr.unsync_init(|| unsafe { - libc::dlsym(libc::RTLD_DEFAULT, self.name.as_ptr() as *const _) as usize - }); - NonNull::new(addr as *mut _) - } -} - -cfg_if! { - if #[cfg(any(target_os = "linux", target_os = "emscripten"))] { - use libc::open64 as open; - } else { - use libc::open; - } -} - -// SAFETY: path must be null terminated, FD must be manually closed. -pub unsafe fn open_readonly(path: &str) -> Result { - 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()); - } - Ok(fd) -} diff -Nru cargo-0.58.0/vendor/getrandom/src/util.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/util.rs --- cargo-0.58.0/vendor/getrandom/src/util.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/util.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -// Copyright 2019 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![allow(dead_code)] -use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; - -// This structure represents a lazily initialized static usize value. Useful -// when it is preferable to just rerun initialization instead of locking. -// Both unsync_init and sync_init will invoke an init() function until it -// succeeds, then return the cached value for future calls. -// -// Both methods support init() "failing". If the init() method returns UNINIT, -// that value will be returned as normal, but will not be cached. -// -// Users should only depend on the _value_ returned by init() functions. -// Specifically, for the following init() function: -// fn init() -> usize { -// a(); -// let v = b(); -// c(); -// v -// } -// the effects of c() or writes to shared memory will not necessarily be -// observed and additional synchronization methods with be needed. -pub struct LazyUsize(AtomicUsize); - -impl LazyUsize { - pub const fn new() -> Self { - Self(AtomicUsize::new(Self::UNINIT)) - } - - // The initialization is not completed. - pub const UNINIT: usize = usize::max_value(); - - // Runs the init() function at least once, returning the value of some run - // of init(). Multiple callers can run their init() functions in parallel. - // init() should always return the same value, if it succeeds. - pub fn unsync_init(&self, init: impl FnOnce() -> usize) -> usize { - // Relaxed ordering is fine, as we only have a single atomic variable. - let mut val = self.0.load(Relaxed); - if val == Self::UNINIT { - val = init(); - self.0.store(val, Relaxed); - } - val - } -} - -// Identical to LazyUsize except with bool instead of usize. -pub struct LazyBool(LazyUsize); - -impl LazyBool { - pub const fn new() -> Self { - Self(LazyUsize::new()) - } - - pub fn unsync_init(&self, init: impl FnOnce() -> bool) -> bool { - self.0.unsync_init(|| init() as usize) != 0 - } -} diff -Nru cargo-0.58.0/vendor/getrandom/src/vxworks.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/vxworks.rs --- cargo-0.58.0/vendor/getrandom/src/vxworks.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/vxworks.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +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 VxWorks -use crate::{util_libc::last_os_error, Error}; -use core::sync::atomic::{AtomicBool, Ordering::Relaxed}; - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - static RNG_INIT: AtomicBool = AtomicBool::new(false); - while !RNG_INIT.load(Relaxed) { - let ret = unsafe { libc::randSecure() }; - if ret < 0 { - return Err(Error::VXWORKS_RAND_SECURE); - } else if ret > 0 { - RNG_INIT.store(true, Relaxed); - break; - } - unsafe { libc::usleep(10) }; - } - - // Prevent overflow of i32 - for chunk in dest.chunks_mut(i32::max_value() as usize) { - let ret = unsafe { libc::randABytes(chunk.as_mut_ptr(), chunk.len() as i32) }; - if ret != 0 { - return Err(last_os_error()); - } - } - Ok(()) -} diff -Nru cargo-0.58.0/vendor/getrandom/src/wasi.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/wasi.rs --- cargo-0.58.0/vendor/getrandom/src/wasi.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/wasi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +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 WASI -use crate::Error; -use core::num::NonZeroU32; -use wasi::random_get; - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - unsafe { random_get(dest.as_mut_ptr(), dest.len()) }.map_err(|e: wasi::Error| { - // convert wasi's Error into getrandom's NonZeroU32 error - NonZeroU32::new(e.raw_error() as u32).unwrap().into() - }) -} diff -Nru cargo-0.58.0/vendor/getrandom/src/wasm-bindgen.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/wasm-bindgen.rs --- cargo-0.58.0/vendor/getrandom/src/wasm-bindgen.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/wasm-bindgen.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +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. -use crate::Error; - -extern crate std; -use std::thread_local; - -use wasm_bindgen::prelude::*; - -enum RngSource { - Node(NodeCrypto), - Browser(BrowserCrypto), -} - -// JsValues are always per-thread, so we initialize RngSource for each thread. -// See: https://github.com/rustwasm/wasm-bindgen/pull/955 -thread_local!( - static RNG_SOURCE: Result = getrandom_init(); -); - -pub(crate) fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - RNG_SOURCE.with(|result| { - let source = result.as_ref().map_err(|&e| e)?; - - match source { - RngSource::Node(n) => { - if n.random_fill_sync(dest).is_err() { - return Err(Error::NODE_RANDOM_FILL_SYNC); - } - } - RngSource::Browser(n) => { - // see https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues - // - // where it says: - // - // > A QuotaExceededError DOMException is thrown if the - // > requested length is greater than 65536 bytes. - for chunk in dest.chunks_mut(65536) { - if n.get_random_values(chunk).is_err() { - return Err(Error::WEB_GET_RANDOM_VALUES); - } - } - } - }; - Ok(()) - }) -} - -fn getrandom_init() -> Result { - if let Ok(self_) = Global::get_self() { - // If `self` is defined then we're in a browser somehow (main window - // or web worker). We get `self.crypto` (called `msCrypto` on IE), so we - // can call `crypto.getRandomValues`. If `crypto` isn't defined, we - // assume we're in an older web browser and the OS RNG isn't available. - - let crypto: BrowserCrypto = match (self_.crypto(), self_.ms_crypto()) { - (crypto, _) if !crypto.is_undefined() => crypto, - (_, crypto) if !crypto.is_undefined() => crypto, - _ => return Err(Error::WEB_CRYPTO), - }; - return Ok(RngSource::Browser(crypto)); - } - - let crypto = MODULE.require("crypto").map_err(|_| Error::NODE_CRYPTO)?; - Ok(RngSource::Node(crypto)) -} - -#[wasm_bindgen] -extern "C" { - type Global; - #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = self, js_name = self)] - fn get_self() -> Result; - - type Self_; - #[wasm_bindgen(method, getter, js_name = "msCrypto")] - fn ms_crypto(me: &Self_) -> BrowserCrypto; - #[wasm_bindgen(method, getter)] - fn crypto(me: &Self_) -> BrowserCrypto; - - type BrowserCrypto; - #[wasm_bindgen(method, js_name = getRandomValues, catch)] - fn get_random_values(me: &BrowserCrypto, buf: &mut [u8]) -> Result<(), JsValue>; - - #[wasm_bindgen(js_name = module)] - static MODULE: NodeModule; - - type NodeModule; - #[wasm_bindgen(method, catch)] - fn require(this: &NodeModule, s: &str) -> Result; - - type NodeCrypto; - #[wasm_bindgen(method, js_name = randomFillSync, catch)] - fn random_fill_sync(crypto: &NodeCrypto, buf: &mut [u8]) -> Result<(), JsValue>; -} diff -Nru cargo-0.58.0/vendor/getrandom/src/windows.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/windows.rs --- cargo-0.58.0/vendor/getrandom/src/windows.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/windows.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +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 Windows -use crate::Error; - -extern "system" { - #[link_name = "SystemFunction036"] - fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: u32) -> u8; -} - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - // Prevent overflow of u32 - for chunk in dest.chunks_mut(u32::max_value() as usize) { - let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr(), chunk.len() as u32) }; - if ret == 0 { - return Err(Error::WINDOWS_RTL_GEN_RANDOM); - } - } - Ok(()) -} diff -Nru cargo-0.58.0/vendor/getrandom/src/windows_uwp.rs cargo-0.60.0ubuntu1/vendor/getrandom/src/windows_uwp.rs --- cargo-0.58.0/vendor/getrandom/src/windows_uwp.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/getrandom/src/windows_uwp.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +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 Windows UWP targets. After deprecation of Windows XP -//! and Vista, this can supersede the `RtlGenRandom`-based implementation. -use crate::Error; -use core::{ffi::c_void, num::NonZeroU32, ptr}; - -const BCRYPT_USE_SYSTEM_PREFERRED_RNG: u32 = 0x00000002; - -extern "system" { - fn BCryptGenRandom( - hAlgorithm: *mut c_void, - pBuffer: *mut u8, - cbBuffer: u32, - dwFlags: u32, - ) -> u32; -} - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - // Prevent overflow of u32 - for chunk in dest.chunks_mut(u32::max_value() as usize) { - let ret = unsafe { - BCryptGenRandom( - ptr::null_mut(), - chunk.as_mut_ptr(), - chunk.len() as u32, - BCRYPT_USE_SYSTEM_PREFERRED_RNG, - ) - }; - // NTSTATUS codes use the two highest bits for severity status. - if ret >> 30 == 0b11 { - // We zeroize the highest bit, so the error code will reside - // inside the range designated for OS codes. - let code = ret ^ (1 << 31); - // SAFETY: the second highest bit is always equal to one, - // so it's impossible to get zero. Unfortunately the type - // system does not have a way to express this yet. - let code = unsafe { NonZeroU32::new_unchecked(code) }; - return Err(Error::from(code)); - } - } - Ok(()) -} diff -Nru cargo-0.58.0/vendor/git2/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/git2/.cargo-checksum.json --- cargo-0.58.0/vendor/git2/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"2a8057932925d3a9d9e4434ea016570d37420ddb1ceed45a174d577f24ed6700"} \ No newline at end of file +{"files":{},"package":"f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/git2/Cargo.lock cargo-0.60.0ubuntu1/vendor/git2/Cargo.lock --- cargo-0.58.0/vendor/git2/Cargo.lock 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -96,7 +96,7 @@ [[package]] name = "git2" -version = "0.13.23" +version = "0.13.25" dependencies = [ "bitflags", "libc", @@ -107,7 +107,6 @@ "paste", "structopt", "tempfile", - "thread-id", "time", "url", ] @@ -158,15 +157,15 @@ [[package]] name = "libc" -version = "0.2.103" +version = "0.2.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" +checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" [[package]] name = "libgit2-sys" -version = "0.12.24+1.3.0" +version = "0.12.26+1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c" +checksum = "19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494" dependencies = [ "cc", "libc", @@ -235,9 +234,9 @@ [[package]] name = "openssl-sys" -version = "0.9.67" +version = "0.9.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69df2d8dfc6ce3aaf44b40dec6f487d5a886516cf6879c49e98e0710f310a058" +checksum = "1996d2d305e561b70d1ee0c53f1542833f4e1ac6ce9a6708b6ff2738ca67dc82" dependencies = [ "autocfg", "cc", @@ -261,9 +260,9 @@ [[package]] name = "pkg-config" -version = "0.3.20" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c9b1041b4387893b91ee6746cddfc28516aff326a3519fb2adf820932c5e6cb" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "ppv-lite86" @@ -355,12 +354,6 @@ [[package]] name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "redox_syscall" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" @@ -409,9 +402,9 @@ [[package]] name = "syn" -version = "1.0.77" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5239bc68e0fef57495900cfea4e8dc75596d9a319d7e16b1e0a440d24e6fe0a0" +checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7" dependencies = [ "proc-macro2", "quote", @@ -427,7 +420,7 @@ "cfg-if", "libc", "rand", - "redox_syscall 0.2.10", + "redox_syscall", "remove_dir_all", "winapi", ] @@ -442,17 +435,6 @@ ] [[package]] -name = "thread-id" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1" -dependencies = [ - "libc", - "redox_syscall 0.1.57", - "winapi", -] - -[[package]] name = "time" version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -464,9 +446,9 @@ [[package]] name = "tinyvec" -version = "1.5.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7" +checksum = "848a1e1181b9f6753b5e96a092749e29b11d19ede67dfbbd6c7dc7e0f49b5338" dependencies = [ "tinyvec_macros", ] @@ -500,9 +482,9 @@ [[package]] name = "unicode-width" -version = "0.1.9" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" diff -Nru cargo-0.58.0/vendor/git2/Cargo.toml cargo-0.60.0ubuntu1/vendor/git2/Cargo.toml --- cargo-0.58.0/vendor/git2/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "git2" -version = "0.13.23" +version = "0.13.25" authors = ["Josh Triplett ", "Alex Crichton "] description = "Bindings to libgit2 for interoperating with git repositories. This library is\nboth threadsafe and memory safe and allows both reading and writing git\nrepositories.\n" documentation = "https://docs.rs/git2" @@ -28,7 +28,7 @@ version = "0.2" [dependencies.libgit2-sys] -version = "0.12.24" +version = "0.12.26" [dependencies.log] version = "0.4.8" @@ -44,9 +44,6 @@ [dev-dependencies.tempfile] version = "3.1.0" -[dev-dependencies.thread-id] -version = "3.3.0" - [dev-dependencies.time] version = "0.1.39" diff -Nru cargo-0.58.0/vendor/git2/debian/patches/0001-Revert-add-bindings-for-git_branch_name_is_valid-715.patch cargo-0.60.0ubuntu1/vendor/git2/debian/patches/0001-Revert-add-bindings-for-git_branch_name_is_valid-715.patch --- cargo-0.58.0/vendor/git2/debian/patches/0001-Revert-add-bindings-for-git_branch_name_is_valid-715.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/debian/patches/0001-Revert-add-bindings-for-git_branch_name_is_valid-715.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,59 @@ +From c02696949a4fd18810ea7072854818ee92049b9d Mon Sep 17 00:00:00 2001 +From: Ximin Luo +Date: Sat, 23 Oct 2021 23:51:12 +0100 +Subject: [PATCH 1/2] Revert "add bindings for `git_branch_name_is_valid` + (#715)" + +This reverts commit 0454efbaa0447a1d02eb11459a7db5e1c27d98e0. +--- + libgit2-sys/lib.rs | 1 - + src/branch.rs | 21 +-------------------- + 2 files changed, 1 insertion(+), 21 deletions(-) + +diff --git a/src/branch.rs b/src/branch.rs +index e1eba99..57b1591 100644 +--- a/src/branch.rs ++++ b/src/branch.rs +@@ -28,17 +28,6 @@ impl<'repo> Branch<'repo> { + Branch { inner: reference } + } + +- /// Ensure the branch name is well-formed. +- pub fn name_is_valid(name: &str) -> Result { +- crate::init(); +- let name = CString::new(name)?; +- let mut valid: libc::c_int = 0; +- unsafe { +- try_call!(raw::git_branch_name_is_valid(&mut valid, name.as_ptr())); +- } +- Ok(valid == 1) +- } +- + /// Gain access to the reference that is this branch + pub fn get(&self) -> &Reference<'repo> { + &self.inner +@@ -162,7 +151,7 @@ impl<'repo> Drop for Branches<'repo> { + + #[cfg(test)] + mod tests { +- use crate::{Branch, BranchType}; ++ use crate::BranchType; + + #[test] + fn smoke() { +@@ -186,12 +175,4 @@ mod tests { + + b1.delete().unwrap(); + } +- +- #[test] +- fn name_is_valid() { +- assert!(Branch::name_is_valid("foo").unwrap()); +- assert!(!Branch::name_is_valid("").unwrap()); +- assert!(!Branch::name_is_valid("with spaces").unwrap()); +- assert!(!Branch::name_is_valid("~tilde").unwrap()); +- } + } +-- +2.33.0 + diff -Nru cargo-0.58.0/vendor/git2/debian/patches/relax-dep.diff cargo-0.60.0ubuntu1/vendor/git2/debian/patches/relax-dep.diff --- cargo-0.58.0/vendor/git2/debian/patches/relax-dep.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/debian/patches/relax-dep.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,11 @@ +--- rust-git2-0.13.23.orig/Cargo.toml ++++ rust-git2-0.13.23/Cargo.toml +@@ -45,7 +45,7 @@ version = "0.3" + version = "3.1.0" + + [dev-dependencies.thread-id] +-version = "3.3.0" ++version = "4.0.0" + + [dev-dependencies.time] + version = "0.1.39" diff -Nru cargo-0.58.0/vendor/git2/debian/patches/series cargo-0.60.0ubuntu1/vendor/git2/debian/patches/series --- cargo-0.58.0/vendor/git2/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,7 @@ +# This patch is needed to make this crate work with libgit2 1.1.0 +# which is what is in Debian; by contrast the upstream crate at this version +# wants libgit2 1.3.0, and segfaults with libgit2 1.1.0 without this patch +0001-Revert-add-bindings-for-git_branch_name_is_valid-715.patch disable-vendor.patch remove-zlib-ng-compat.patch skip-credential_helper5-if-no-git.patch diff -Nru cargo-0.58.0/vendor/git2/src/branch.rs cargo-0.60.0ubuntu1/vendor/git2/src/branch.rs --- cargo-0.58.0/vendor/git2/src/branch.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/branch.rs 2022-04-20 13:48:09.000000000 +0000 @@ -28,17 +28,6 @@ Branch { inner: reference } } - /// Ensure the branch name is well-formed. - pub fn name_is_valid(name: &str) -> Result { - crate::init(); - let name = CString::new(name)?; - let mut valid: libc::c_int = 0; - unsafe { - try_call!(raw::git_branch_name_is_valid(&mut valid, name.as_ptr())); - } - Ok(valid == 1) - } - /// Gain access to the reference that is this branch pub fn get(&self) -> &Reference<'repo> { &self.inner @@ -162,7 +151,7 @@ #[cfg(test)] mod tests { - use crate::{Branch, BranchType}; + use crate::BranchType; #[test] fn smoke() { @@ -186,12 +175,4 @@ b1.delete().unwrap(); } - - #[test] - fn name_is_valid() { - assert!(Branch::name_is_valid("foo").unwrap()); - assert!(!Branch::name_is_valid("").unwrap()); - assert!(!Branch::name_is_valid("with spaces").unwrap()); - assert!(!Branch::name_is_valid("~tilde").unwrap()); - } } diff -Nru cargo-0.58.0/vendor/git2/src/build.rs cargo-0.60.0ubuntu1/vendor/git2/src/build.rs --- cargo-0.58.0/vendor/git2/src/build.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -680,6 +680,8 @@ .unwrap_or(2) } +unsafe impl Send for TreeUpdateBuilder {} + impl Default for TreeUpdateBuilder { fn default() -> Self { Self::new() diff -Nru cargo-0.58.0/vendor/git2/src/cred.rs cargo-0.60.0ubuntu1/vendor/git2/src/cred.rs --- cargo-0.58.0/vendor/git2/src/cred.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/cred.rs 2022-04-20 13:48:09.000000000 +0000 @@ -427,7 +427,7 @@ let output = my_try!(p.wait_with_output()); if !output.status.success() { debug!( - "credential helper failed: {}\nstdout ---\n{}\nstdout ---\n{}", + "credential helper failed: {}\nstdout ---\n{}\nstderr ---\n{}", output.status, String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr) diff -Nru cargo-0.58.0/vendor/git2/src/diff.rs cargo-0.60.0ubuntu1/vendor/git2/src/diff.rs --- cargo-0.58.0/vendor/git2/src/diff.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/diff.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1170,7 +1170,7 @@ } impl DiffStats { - /// Get the total number of files chaned in a diff. + /// Get the total number of files changed in a diff. pub fn files_changed(&self) -> usize { unsafe { raw::git_diff_stats_files_changed(&*self.raw) as usize } } diff -Nru cargo-0.58.0/vendor/git2/src/index.rs cargo-0.60.0ubuntu1/vendor/git2/src/index.rs --- cargo-0.58.0/vendor/git2/src/index.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/index.rs 2022-04-20 13:48:09.000000000 +0000 @@ -54,6 +54,7 @@ /// All fields of an entry are public for modification and inspection. This is /// also how a new index entry is created. #[allow(missing_docs)] +#[derive(Debug)] pub struct IndexEntry { pub ctime: IndexTime, pub mtime: IndexTime, diff -Nru cargo-0.58.0/vendor/git2/src/lib.rs cargo-0.60.0ubuntu1/vendor/git2/src/lib.rs --- cargo-0.58.0/vendor/git2/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -101,7 +101,11 @@ pub use crate::mailmap::Mailmap; pub use crate::mempack::Mempack; pub use crate::merge::{AnnotatedCommit, MergeOptions}; -pub use crate::message::{message_prettify, DEFAULT_COMMENT_CHAR}; +pub use crate::message::{ + message_prettify, message_trailers_bytes, message_trailers_strs, MessageTrailersBytes, + MessageTrailersBytesIterator, MessageTrailersStrs, MessageTrailersStrsIterator, + DEFAULT_COMMENT_CHAR, +}; pub use crate::note::{Note, Notes}; pub use crate::object::Object; pub use crate::odb::{Odb, OdbObject, OdbPackwriter, OdbReader, OdbWriter}; @@ -307,7 +311,7 @@ } /// An enumeration of the possible directions for a remote. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Direction { /// Data will be fetched (read) from this remote. Fetch, @@ -317,7 +321,7 @@ /// An enumeration of the operations that can be performed for the `reset` /// method on a `Repository`. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum ResetType { /// Move the head to the given commit. Soft, @@ -1209,7 +1213,7 @@ /// These values represent settings for the `submodule.$name.ignore` /// configuration value which says how deeply to look at the working /// directory when getting the submodule status. -#[derive(Debug)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum SubmoduleIgnore { /// Use the submodule's configuration Unspecified, @@ -1229,7 +1233,7 @@ /// configuration value which says how to handle `git submodule update` /// for this submodule. The value is usually set in the ".gitmodules" /// file and copied to ".git/config" when the submodule is initialized. -#[derive(Debug)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum SubmoduleUpdate { /// The default; when a submodule is updated, checkout the new detached /// HEAD to the submodule directory. @@ -1318,7 +1322,7 @@ } /// Possible output formats for diff data -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum DiffFormat { /// full git diff Patch, @@ -1382,7 +1386,7 @@ } #[allow(missing_docs)] -#[derive(Debug)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum StashApplyProgress { /// None None, diff -Nru cargo-0.58.0/vendor/git2/src/message.rs cargo-0.60.0ubuntu1/vendor/git2/src/message.rs --- cargo-0.58.0/vendor/git2/src/message.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/message.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,4 +1,7 @@ +use core::ops::Range; +use std::ffi::CStr; use std::ffi::CString; +use std::ptr; use libc::{c_char, c_int}; @@ -31,12 +34,216 @@ /// The default comment character for `message_prettify` ('#') pub const DEFAULT_COMMENT_CHAR: Option = Some(b'#'); +/// Get the trailers for the given message. +/// +/// Use this function when you are dealing with a UTF-8-encoded message. +pub fn message_trailers_strs(message: &str) -> Result { + _message_trailers(message.into_c_string()?).map(|res| MessageTrailersStrs(res)) +} + +/// Get the trailers for the given message. +/// +/// Use this function when the message might not be UTF-8-encoded, +/// or if you want to handle the returned trailer key–value pairs +/// as bytes. +pub fn message_trailers_bytes(message: S) -> Result { + _message_trailers(message.into_c_string()?).map(|res| MessageTrailersBytes(res)) +} + +fn _message_trailers(message: CString) -> Result { + let ret = MessageTrailers::new(); + unsafe { + try_call!(raw::git_message_trailers(ret.raw(), message)); + } + Ok(ret) +} + +/// Collection of UTF-8-encoded trailers. +/// +/// Use `iter()` to get access to the values. +pub struct MessageTrailersStrs(MessageTrailers); + +impl MessageTrailersStrs { + /// Create a borrowed iterator. + pub fn iter(&self) -> MessageTrailersStrsIterator<'_> { + MessageTrailersStrsIterator(self.0.iter()) + } + /// The number of trailer key–value pairs. + pub fn len(&self) -> usize { + self.0.len() + } + /// Convert to the “bytes” variant. + pub fn to_bytes(self) -> MessageTrailersBytes { + MessageTrailersBytes(self.0) + } +} + +/// Collection of unencoded (bytes) trailers. +/// +/// Use `iter()` to get access to the values. +pub struct MessageTrailersBytes(MessageTrailers); + +impl MessageTrailersBytes { + /// Create a borrowed iterator. + pub fn iter(&self) -> MessageTrailersBytesIterator<'_> { + MessageTrailersBytesIterator(self.0.iter()) + } + /// The number of trailer key–value pairs. + pub fn len(&self) -> usize { + self.0.len() + } +} + +struct MessageTrailers { + raw: raw::git_message_trailer_array, +} + +impl MessageTrailers { + fn new() -> MessageTrailers { + crate::init(); + unsafe { + Binding::from_raw(&mut raw::git_message_trailer_array { + trailers: ptr::null_mut(), + count: 0, + _trailer_block: ptr::null_mut(), + } as *mut _) + } + } + fn iter(&self) -> MessageTrailersIterator<'_> { + MessageTrailersIterator { + trailers: self, + range: Range { + start: 0, + end: self.raw.count, + }, + } + } + fn len(&self) -> usize { + self.raw.count + } +} + +impl Drop for MessageTrailers { + fn drop(&mut self) { + unsafe { + raw::git_message_trailer_array_free(&mut self.raw); + } + } +} + +impl Binding for MessageTrailers { + type Raw = *mut raw::git_message_trailer_array; + unsafe fn from_raw(raw: *mut raw::git_message_trailer_array) -> MessageTrailers { + MessageTrailers { raw: *raw } + } + fn raw(&self) -> *mut raw::git_message_trailer_array { + &self.raw as *const _ as *mut _ + } +} + +struct MessageTrailersIterator<'a> { + trailers: &'a MessageTrailers, + range: Range, +} + +fn to_raw_tuple(trailers: &MessageTrailers, index: usize) -> (*const c_char, *const c_char) { + unsafe { + let addr = trailers.raw.trailers.wrapping_add(index); + ((*addr).key, (*addr).value) + } +} + +/// Borrowed iterator over the UTF-8-encoded trailers. +pub struct MessageTrailersStrsIterator<'a>(MessageTrailersIterator<'a>); + +impl<'pair> Iterator for MessageTrailersStrsIterator<'pair> { + type Item = (&'pair str, &'pair str); + + fn next(&mut self) -> Option { + self.0 + .range + .next() + .map(|index| to_str_tuple(&self.0.trailers, index)) + } + + fn size_hint(&self) -> (usize, Option) { + self.0.range.size_hint() + } +} + +impl ExactSizeIterator for MessageTrailersStrsIterator<'_> { + fn len(&self) -> usize { + self.0.range.len() + } +} + +impl DoubleEndedIterator for MessageTrailersStrsIterator<'_> { + fn next_back(&mut self) -> Option { + self.0 + .range + .next_back() + .map(|index| to_str_tuple(&self.0.trailers, index)) + } +} + +fn to_str_tuple(trailers: &MessageTrailers, index: usize) -> (&str, &str) { + unsafe { + let (rkey, rvalue) = to_raw_tuple(&trailers, index); + let key = CStr::from_ptr(rkey).to_str().unwrap(); + let value = CStr::from_ptr(rvalue).to_str().unwrap(); + (key, value) + } +} + +/// Borrowed iterator over the raw (bytes) trailers. +pub struct MessageTrailersBytesIterator<'a>(MessageTrailersIterator<'a>); + +impl<'pair> Iterator for MessageTrailersBytesIterator<'pair> { + type Item = (&'pair [u8], &'pair [u8]); + + fn next(&mut self) -> Option { + self.0 + .range + .next() + .map(|index| to_bytes_tuple(&self.0.trailers, index)) + } + + fn size_hint(&self) -> (usize, Option) { + self.0.range.size_hint() + } +} + +impl ExactSizeIterator for MessageTrailersBytesIterator<'_> { + fn len(&self) -> usize { + self.0.range.len() + } +} + +impl DoubleEndedIterator for MessageTrailersBytesIterator<'_> { + fn next_back(&mut self) -> Option { + self.0 + .range + .next_back() + .map(|index| to_bytes_tuple(&self.0.trailers, index)) + } +} + +fn to_bytes_tuple(trailers: &MessageTrailers, index: usize) -> (&[u8], &[u8]) { + unsafe { + let (rkey, rvalue) = to_raw_tuple(&trailers, index); + let key = CStr::from_ptr(rkey).to_bytes(); + let value = CStr::from_ptr(rvalue).to_bytes(); + (key, value) + } +} + #[cfg(test)] mod tests { - use crate::{message_prettify, DEFAULT_COMMENT_CHAR}; #[test] fn prettify() { + use crate::{message_prettify, DEFAULT_COMMENT_CHAR}; + // This does not attempt to duplicate the extensive tests for // git_message_prettify in libgit2, just a few representative values to // make sure the interface works as expected. @@ -58,4 +265,80 @@ "1\n" ); } + + #[test] + fn trailers() { + use crate::{message_trailers_bytes, message_trailers_strs, MessageTrailersStrs}; + use std::collections::HashMap; + + // no trailers + let message1 = " +WHAT ARE WE HERE FOR + +What are we here for? + +Just to be eaten? +"; + let expected: HashMap<&str, &str> = HashMap::new(); + assert_eq!(expected, to_map(&message_trailers_strs(message1).unwrap())); + + // standard PSA + let message2 = " +Attention all + +We are out of tomatoes. + +Spoken-by: Major Turnips +Transcribed-by: Seargant Persimmons +Signed-off-by: Colonel Kale +"; + let expected: HashMap<&str, &str> = vec![ + ("Spoken-by", "Major Turnips"), + ("Transcribed-by", "Seargant Persimmons"), + ("Signed-off-by", "Colonel Kale"), + ] + .into_iter() + .collect(); + assert_eq!(expected, to_map(&message_trailers_strs(message2).unwrap())); + + // ignore everything after `---` + let message3 = " +The fate of Seargant Green-Peppers + +Seargant Green-Peppers was killed by Caterpillar Battalion 44. + +Signed-off-by: Colonel Kale +--- +I never liked that guy, anyway. + +Opined-by: Corporal Garlic +"; + let expected: HashMap<&str, &str> = vec![("Signed-off-by", "Colonel Kale")] + .into_iter() + .collect(); + assert_eq!(expected, to_map(&message_trailers_strs(message3).unwrap())); + + // Raw bytes message; not valid UTF-8 + // Source: https://stackoverflow.com/a/3886015/1725151 + let message4 = b" +Be honest guys + +Am I a malformed brussels sprout? + +Signed-off-by: Lieutenant \xe2\x28\xa1prout +"; + + let trailer = message_trailers_bytes(&message4[..]).unwrap(); + let expected = (&b"Signed-off-by"[..], &b"Lieutenant \xe2\x28\xa1prout"[..]); + let actual = trailer.iter().next().unwrap(); + assert_eq!(expected, actual); + + fn to_map(trailers: &MessageTrailersStrs) -> HashMap<&str, &str> { + let mut map = HashMap::with_capacity(trailers.len()); + for (key, value) in trailers.iter() { + map.insert(key, value); + } + map + } + } } diff -Nru cargo-0.58.0/vendor/git2/src/odb.rs cargo-0.60.0ubuntu1/vendor/git2/src/odb.rs --- cargo-0.58.0/vendor/git2/src/odb.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/odb.rs 2022-04-20 13:48:09.000000000 +0000 @@ -18,6 +18,10 @@ _marker: marker::PhantomData>, } +// `git_odb` uses locking and atomics internally. +unsafe impl<'repo> Send for Odb<'repo> {} +unsafe impl<'repo> Sync for Odb<'repo> {} + impl<'repo> Binding for Odb<'repo> { type Raw = *mut raw::git_odb; @@ -322,6 +326,10 @@ _marker: marker::PhantomData>, } +// `git_odb_stream` is not thread-safe internally, so it can't use `Sync`, but moving it to another +// thread and continuing to read will work. +unsafe impl<'repo> Send for OdbReader<'repo> {} + impl<'repo> Binding for OdbReader<'repo> { type Raw = *mut raw::git_odb_stream; @@ -363,6 +371,10 @@ _marker: marker::PhantomData>, } +// `git_odb_stream` is not thread-safe internally, so it can't use `Sync`, but moving it to another +// thread and continuing to write will work. +unsafe impl<'repo> Send for OdbWriter<'repo> {} + impl<'repo> OdbWriter<'repo> { /// Finish writing to an ODB stream /// diff -Nru cargo-0.58.0/vendor/git2/src/opts.rs cargo-0.60.0ubuntu1/vendor/git2/src/opts.rs --- cargo-0.58.0/vendor/git2/src/opts.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/opts.rs 2022-04-20 13:48:09.000000000 +0000 @@ -69,6 +69,23 @@ buf.into_c_string() } +/// Controls whether or not libgit2 will cache loaded objects. Enabled by +/// default, but disabling this can improve performance and memory usage if +/// loading a large number of objects that will not be referenced again. +/// Disabling this will cause repository objects to clear their caches when next +/// accessed. +pub fn enable_caching(enabled: bool) { + let error = unsafe { + raw::git_libgit2_opts( + raw::GIT_OPT_ENABLE_CACHING as libc::c_int, + enabled as libc::c_int, + ) + }; + // This function cannot actually fail, but the function has an error return + // for other options that can. + debug_assert!(error >= 0); +} + /// Controls whether or not libgit2 will verify when writing an object that all /// objects it references are valid. Enabled by default, but disabling this can /// significantly improve performance, at the cost of potentially allowing the diff -Nru cargo-0.58.0/vendor/git2/src/time.rs cargo-0.60.0ubuntu1/vendor/git2/src/time.rs --- cargo-0.58.0/vendor/git2/src/time.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/time.rs 2022-04-20 13:48:09.000000000 +0000 @@ -6,13 +6,13 @@ use crate::util::Binding; /// Time in a signature -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Time { raw: raw::git_time, } /// Time structure used in a git index entry. -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct IndexTime { raw: raw::git_index_time, } diff -Nru cargo-0.58.0/vendor/git2/src/tracing.rs cargo-0.60.0ubuntu1/vendor/git2/src/tracing.rs --- cargo-0.58.0/vendor/git2/src/tracing.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/git2/src/tracing.rs 2022-04-20 13:48:09.000000000 +0000 @@ -57,6 +57,9 @@ } } +//TODO: pass raw &[u8] and leave conversion to consumer (breaking API) +/// Callback type used to pass tracing events to the subscriber. +/// see `trace_set` to register a scubscriber. pub type TracingCb = fn(TraceLevel, &str); static CALLBACK: AtomicUsize = AtomicUsize::new(0); @@ -76,7 +79,7 @@ let cb = CALLBACK.load(Ordering::SeqCst); panic::wrap(|| unsafe { let cb: TracingCb = std::mem::transmute(cb); - let msg = std::ffi::CStr::from_ptr(msg).to_str().unwrap(); - cb(Binding::from_raw(level), msg); + let msg = std::ffi::CStr::from_ptr(msg).to_string_lossy(); + cb(Binding::from_raw(level), msg.as_ref()); }); } diff -Nru cargo-0.58.0/vendor/hermit-abi/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/hermit-abi/.cargo-checksum.json --- cargo-0.58.0/vendor/hermit-abi/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/hermit-abi/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1 @@ +{"files":{},"package":"62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/hermit-abi/Cargo.toml cargo-0.60.0ubuntu1/vendor/hermit-abi/Cargo.toml --- cargo-0.58.0/vendor/hermit-abi/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/hermit-abi/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,44 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "hermit-abi" +version = "0.1.19" +authors = ["Stefan Lankes"] +description = "hermit-abi is small interface to call functions from the unikernel RustyHermit.\nIt is used to build the target `x86_64-unknown-hermit`.\n" +documentation = "https://hermitcore.github.io/rusty-hermit/hermit_abi" +readme = "README.md" +keywords = ["unikernel", "libos"] +categories = ["os"] +license = "MIT/Apache-2.0" +repository = "https://github.com/hermitcore/libhermit-rs" +[package.metadata.docs.rs] +default-target = "x86_64-unknown-hermit" +features = ["docs"] +[dependencies.compiler_builtins] +version = "0.1" +optional = true + +[dependencies.core] +version = "1.0.0" +optional = true +package = "rustc-std-workspace-core" + +[dependencies.libc] +version = "0.2.51" +default-features = false + +[features] +default = [] +docs = [] +rustc-dep-of-std = ["core", "compiler_builtins/rustc-dep-of-std", "libc/rustc-dep-of-std"] diff -Nru cargo-0.58.0/vendor/hermit-abi/LICENSE-APACHE cargo-0.60.0ubuntu1/vendor/hermit-abi/LICENSE-APACHE --- cargo-0.58.0/vendor/hermit-abi/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/hermit-abi/LICENSE-APACHE 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff -Nru cargo-0.58.0/vendor/hermit-abi/LICENSE-MIT cargo-0.60.0ubuntu1/vendor/hermit-abi/LICENSE-MIT --- cargo-0.58.0/vendor/hermit-abi/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/hermit-abi/LICENSE-MIT 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,23 @@ +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.58.0/vendor/hermit-abi/README.md cargo-0.60.0ubuntu1/vendor/hermit-abi/README.md --- cargo-0.58.0/vendor/hermit-abi/README.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/hermit-abi/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,22 @@ +# hermit-abi + +[![Crates.io](https://img.shields.io/crates/v/hermit-abi.svg)](https://crates.io/crates/hermit-abi) +[![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://hermitcore.github.io/rusty-hermit/hermit_abi/) +[![License](https://img.shields.io/crates/l/hermit-abi.svg)](https://img.shields.io/crates/l/hermit-abi.svg) + +This is small interface to call functions from the unikernel [RustyHermit](https://github.com/hermitcore/libhermit-rs). + +Please read the README of [RustyHermit](https://github.com/hermitcore/libhermit-rs) for more information. + +## License + +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) + +at your option. + +## Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. diff -Nru cargo-0.58.0/vendor/hermit-abi/rust-toolchain cargo-0.60.0ubuntu1/vendor/hermit-abi/rust-toolchain --- cargo-0.58.0/vendor/hermit-abi/rust-toolchain 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/hermit-abi/rust-toolchain 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1 @@ +nightly diff -Nru cargo-0.58.0/vendor/hermit-abi/src/lib.rs cargo-0.60.0ubuntu1/vendor/hermit-abi/src/lib.rs --- cargo-0.58.0/vendor/hermit-abi/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/hermit-abi/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,490 @@ +//! `hermit-abi` is small interface to call functions from the unikernel +//! [RustyHermit](https://github.com/hermitcore/libhermit-rs). + +#![no_std] +#![allow(clippy::missing_safety_doc)] +#![allow(clippy::result_unit_err)] + +extern crate libc; + +pub mod tcplistener; +pub mod tcpstream; + +use libc::c_void; + +// sysmbols, which are part of the library operating system + +extern "Rust" { + fn sys_secure_rand64() -> Option; + fn sys_secure_rand32() -> Option; +} + +extern "C" { + fn sys_rand() -> u32; + fn sys_srand(seed: u32); + fn sys_get_processor_count() -> usize; + fn sys_malloc(size: usize, align: usize) -> *mut u8; + fn sys_realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8; + fn sys_free(ptr: *mut u8, size: usize, align: usize); + fn sys_init_queue(ptr: usize) -> i32; + fn sys_notify(id: usize, count: i32) -> i32; + fn sys_add_queue(id: usize, timeout_ns: i64) -> i32; + fn sys_wait(id: usize) -> i32; + fn sys_destroy_queue(id: usize) -> i32; + fn sys_read(fd: i32, buf: *mut u8, len: usize) -> isize; + fn sys_write(fd: i32, buf: *const u8, len: usize) -> isize; + fn sys_close(fd: i32) -> i32; + fn sys_sem_init(sem: *mut *const c_void, value: u32) -> i32; + fn sys_sem_destroy(sem: *const c_void) -> i32; + fn sys_sem_post(sem: *const c_void) -> i32; + fn sys_sem_trywait(sem: *const c_void) -> i32; + fn sys_sem_timedwait(sem: *const c_void, ms: u32) -> i32; + fn sys_recmutex_init(recmutex: *mut *const c_void) -> i32; + fn sys_recmutex_destroy(recmutex: *const c_void) -> i32; + fn sys_recmutex_lock(recmutex: *const c_void) -> i32; + fn sys_recmutex_unlock(recmutex: *const c_void) -> i32; + fn sys_getpid() -> u32; + fn sys_exit(arg: i32) -> !; + fn sys_abort() -> !; + fn sys_usleep(usecs: u64); + fn sys_spawn( + id: *mut Tid, + func: extern "C" fn(usize), + arg: usize, + prio: u8, + core_id: isize, + ) -> i32; + fn sys_spawn2( + func: extern "C" fn(usize), + arg: usize, + prio: u8, + stack_size: usize, + core_id: isize, + ) -> Tid; + fn sys_join(id: Tid) -> i32; + fn sys_yield(); + fn sys_clock_gettime(clock_id: u64, tp: *mut timespec) -> i32; + fn sys_open(name: *const i8, flags: i32, mode: i32) -> i32; + fn sys_unlink(name: *const i8) -> i32; + fn sys_network_init() -> i32; + fn sys_block_current_task(); + fn sys_wakeup_task(tid: Tid); + fn sys_get_priority() -> u8; +} + +/// A thread handle type +pub type Tid = u32; + +/// Maximum number of priorities +pub const NO_PRIORITIES: usize = 31; + +/// Priority of a thread +#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy)] +pub struct Priority(u8); + +impl Priority { + pub const fn into(self) -> u8 { + self.0 + } + + pub const fn from(x: u8) -> Self { + Priority(x) + } +} + +pub const HIGH_PRIO: Priority = Priority::from(3); +pub const NORMAL_PRIO: Priority = Priority::from(2); +pub const LOW_PRIO: Priority = Priority::from(1); + +/// A handle, identifying a socket +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, Hash)] +pub struct Handle(usize); + +pub const NSEC_PER_SEC: u64 = 1_000_000_000; +pub const CLOCK_REALTIME: u64 = 1; +pub const CLOCK_MONOTONIC: u64 = 4; +pub const STDIN_FILENO: libc::c_int = 0; +pub const STDOUT_FILENO: libc::c_int = 1; +pub const STDERR_FILENO: libc::c_int = 2; +pub const O_RDONLY: i32 = 0o0; +pub const O_WRONLY: i32 = 0o1; +pub const O_RDWR: i32 = 0o2; +pub const O_CREAT: i32 = 0o100; +pub const O_EXCL: i32 = 0o200; +pub const O_TRUNC: i32 = 0o1000; +pub const O_APPEND: i32 = 0o2000; + +/// returns true if file descriptor `fd` is a tty +pub fn isatty(_fd: libc::c_int) -> bool { + false +} + +/// intialize the network stack +pub fn network_init() -> i32 { + unsafe { sys_network_init() } +} + +/// `timespec` is used by `clock_gettime` to retrieve the +/// current time +#[derive(Copy, Clone, Debug)] +#[repr(C)] +pub struct timespec { + /// seconds + pub tv_sec: i64, + /// nanoseconds + pub tv_nsec: i64, +} + +/// Internet protocol version. +#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] +pub enum Version { + Unspecified, + Ipv4, + Ipv6, +} + +/// A four-octet IPv4 address. +#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default)] +pub struct Ipv4Address(pub [u8; 4]); + +/// A sixteen-octet IPv6 address. +#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default)] +pub struct Ipv6Address(pub [u8; 16]); + +/// An internetworking address. +#[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] +pub enum IpAddress { + /// An unspecified address. + /// May be used as a placeholder for storage where the address is not assigned yet. + Unspecified, + /// An IPv4 address. + Ipv4(Ipv4Address), + /// An IPv6 address. + Ipv6(Ipv6Address), +} + +/// determines the number of activated processors +#[inline(always)] +pub unsafe fn get_processor_count() -> usize { + sys_get_processor_count() +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn malloc(size: usize, align: usize) -> *mut u8 { + sys_malloc(size, align) +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8 { + sys_realloc(ptr, size, align, new_size) +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn free(ptr: *mut u8, size: usize, align: usize) { + sys_free(ptr, size, align) +} + +#[inline(always)] +pub unsafe fn notify(id: usize, count: i32) -> i32 { + sys_notify(id, count) +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn add_queue(id: usize, timeout_ns: i64) -> i32 { + sys_add_queue(id, timeout_ns) +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn wait(id: usize) -> i32 { + sys_wait(id) +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn init_queue(id: usize) -> i32 { + sys_init_queue(id) +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn destroy_queue(id: usize) -> i32 { + sys_destroy_queue(id) +} + +/// read from a file descriptor +/// +/// read() attempts to read `len` bytes of data from the object +/// referenced by the descriptor `fd` into the buffer pointed +/// to by `buf`. +#[inline(always)] +pub unsafe fn read(fd: i32, buf: *mut u8, len: usize) -> isize { + sys_read(fd, buf, len) +} + +/// write to a file descriptor +/// +/// write() attempts to write `len` of data to the object +/// referenced by the descriptor `fd` from the +/// buffer pointed to by `buf`. +#[inline(always)] +pub unsafe fn write(fd: i32, buf: *const u8, len: usize) -> isize { + sys_write(fd, buf, len) +} + +/// close a file descriptor +/// +/// The close() call deletes a file descriptor `fd` from the object +/// reference table. +#[inline(always)] +pub unsafe fn close(fd: i32) -> i32 { + sys_close(fd) +} + +/// sem_init() initializes the unnamed semaphore at the address +/// pointed to by `sem`. The `value` argument specifies the +/// initial value for the semaphore. +#[inline(always)] +pub unsafe fn sem_init(sem: *mut *const c_void, value: u32) -> i32 { + sys_sem_init(sem, value) +} + +/// sem_destroy() frees the unnamed semaphore at the address +/// pointed to by `sem`. +#[inline(always)] +pub unsafe fn sem_destroy(sem: *const c_void) -> i32 { + sys_sem_destroy(sem) +} + +/// sem_post() increments the semaphore pointed to by `sem`. +/// If the semaphore's value consequently becomes greater +/// than zero, then another thread blocked in a sem_wait call +/// will be woken up and proceed to lock the semaphore. +#[inline(always)] +pub unsafe fn sem_post(sem: *const c_void) -> i32 { + sys_sem_post(sem) +} + +/// try to decrement a semaphore +/// +/// sem_trywait() is the same as sem_timedwait(), except that +/// if the decrement cannot be immediately performed, then call +/// returns a negative value instead of blocking. +#[inline(always)] +pub unsafe fn sem_trywait(sem: *const c_void) -> i32 { + sys_sem_trywait(sem) +} + +/// decrement a semaphore +/// +/// sem_timedwait() decrements the semaphore pointed to by `sem`. +/// If the semaphore's value is greater than zero, then the +/// the function returns immediately. If the semaphore currently +/// has the value zero, then the call blocks until either +/// it becomes possible to perform the decrement of the time limit +/// to wait for the semaphore is expired. A time limit `ms` of +/// means infinity waiting time. +#[inline(always)] +pub unsafe fn sem_timedwait(sem: *const c_void, ms: u32) -> i32 { + sys_sem_timedwait(sem, ms) +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn recmutex_init(recmutex: *mut *const c_void) -> i32 { + sys_recmutex_init(recmutex) +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn recmutex_destroy(recmutex: *const c_void) -> i32 { + sys_recmutex_destroy(recmutex) +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn recmutex_lock(recmutex: *const c_void) -> i32 { + sys_recmutex_lock(recmutex) +} + +#[doc(hidden)] +#[inline(always)] +pub unsafe fn recmutex_unlock(recmutex: *const c_void) -> i32 { + sys_recmutex_unlock(recmutex) +} + +/// Determines the id of the current thread +#[inline(always)] +pub unsafe fn getpid() -> u32 { + sys_getpid() +} + +/// cause normal termination and return `arg` +/// to the host system +#[inline(always)] +pub unsafe fn exit(arg: i32) -> ! { + sys_exit(arg) +} + +/// cause abnormal termination +#[inline(always)] +pub unsafe fn abort() -> ! { + sys_abort() +} + +/// suspend execution for microsecond intervals +/// +/// The usleep() function suspends execution of the calling +/// thread for (at least) `usecs` microseconds. +#[inline(always)] +pub unsafe fn usleep(usecs: u64) { + sys_usleep(usecs) +} + +/// spawn a new thread +/// +/// spawn() starts a new thread. The new thread starts execution +/// by invoking `func(usize)`; `arg` is passed as the argument +/// to `func`. `prio` defines the priority of the new thread, +/// which can be between `LOW_PRIO` and `HIGH_PRIO`. +/// `core_id` defines the core, where the thread is located. +/// A negative value give the operating system the possibility +/// to select the core by its own. +#[inline(always)] +pub unsafe fn spawn( + id: *mut Tid, + func: extern "C" fn(usize), + arg: usize, + prio: u8, + core_id: isize, +) -> i32 { + sys_spawn(id, func, arg, prio, core_id) +} + +/// spawn a new thread with user-specified stack size +/// +/// spawn2() starts a new thread. The new thread starts execution +/// by invoking `func(usize)`; `arg` is passed as the argument +/// to `func`. `prio` defines the priority of the new thread, +/// which can be between `LOW_PRIO` and `HIGH_PRIO`. +/// `core_id` defines the core, where the thread is located. +/// A negative value give the operating system the possibility +/// to select the core by its own. +/// In contrast to spawn(), spawn2() is able to define the +/// stack size. +#[inline(always)] +pub unsafe fn spawn2( + func: extern "C" fn(usize), + arg: usize, + prio: u8, + stack_size: usize, + core_id: isize, +) -> Tid { + sys_spawn2(func, arg, prio, stack_size, core_id) +} + +/// join with a terminated thread +/// +/// The join() function waits for the thread specified by `id` +/// to terminate. +#[inline(always)] +pub unsafe fn join(id: Tid) -> i32 { + sys_join(id) +} + +/// yield the processor +/// +/// causes the calling thread to relinquish the CPU. The thread +/// is moved to the end of the queue for its static priority. +#[inline(always)] +pub unsafe fn yield_now() { + sys_yield() +} + +/// get current time +/// +/// The clock_gettime() functions allow the calling thread +/// to retrieve the value used by a clock which is specified +/// by `clock_id`. +/// +/// `CLOCK_REALTIME`: the system's real time clock, +/// expressed as the amount of time since the Epoch. +/// +/// `CLOCK_MONOTONIC`: clock that increments monotonically, +/// tracking the time since an arbitrary point +#[inline(always)] +pub unsafe fn clock_gettime(clock_id: u64, tp: *mut timespec) -> i32 { + sys_clock_gettime(clock_id, tp) +} + +/// open and possibly create a file +/// +/// The open() system call opens the file specified by `name`. +/// If the specified file does not exist, it may optionally +/// be created by open(). +#[inline(always)] +pub unsafe fn open(name: *const i8, flags: i32, mode: i32) -> i32 { + sys_open(name, flags, mode) +} + +/// delete the file it refers to `name` +#[inline(always)] +pub unsafe fn unlink(name: *const i8) -> i32 { + sys_unlink(name) +} + +/// The largest number `rand` will return +pub const RAND_MAX: u64 = 2_147_483_647; + +/// The function computes a sequence of pseudo-random integers +/// in the range of 0 to RAND_MAX +#[inline(always)] +pub unsafe fn rand() -> u32 { + sys_rand() +} + +/// The function sets its argument as the seed for a new sequence +/// of pseudo-random numbers to be returned by `rand` +#[inline(always)] +pub unsafe fn srand(seed: u32) { + sys_srand(seed); +} + +/// Create a cryptographicly secure 32bit random number with the support of +/// the underlying hardware. If the required hardware isn't available, +/// the function returns `None`. +#[inline(always)] +pub unsafe fn secure_rand32() -> Option { + sys_secure_rand32() +} + +/// Create a cryptographicly secure 64bit random number with the support of +/// the underlying hardware. If the required hardware isn't available, +/// the function returns `None`. +#[inline(always)] +pub unsafe fn secure_rand64() -> Option { + sys_secure_rand64() +} + +/// Add current task to the queue of blocked tasl. After calling `block_current_task`, +/// call `yield_now` to switch to another task. +#[inline(always)] +pub unsafe fn block_current_task() { + sys_block_current_task(); +} + +/// Wakeup task with the thread id `tid` +#[inline(always)] +pub unsafe fn wakeup_task(tid: Tid) { + sys_wakeup_task(tid); +} + +/// Determine the priority of the current thread +#[inline(always)] +pub unsafe fn get_priority() -> Priority { + Priority::from(sys_get_priority()) +} diff -Nru cargo-0.58.0/vendor/hermit-abi/src/tcplistener.rs cargo-0.60.0ubuntu1/vendor/hermit-abi/src/tcplistener.rs --- cargo-0.58.0/vendor/hermit-abi/src/tcplistener.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/hermit-abi/src/tcplistener.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,13 @@ +//! `tcplistener` provide an interface to establish tcp socket server. + +use crate::{Handle, IpAddress}; + +extern "Rust" { + fn sys_tcp_listener_accept(port: u16) -> Result<(Handle, IpAddress, u16), ()>; +} + +/// Wait for connection at specified address. +#[inline(always)] +pub fn accept(port: u16) -> Result<(Handle, IpAddress, u16), ()> { + unsafe { sys_tcp_listener_accept(port) } +} diff -Nru cargo-0.58.0/vendor/hermit-abi/src/tcpstream.rs cargo-0.60.0ubuntu1/vendor/hermit-abi/src/tcpstream.rs --- cargo-0.58.0/vendor/hermit-abi/src/tcpstream.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/hermit-abi/src/tcpstream.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,109 @@ +//! `tcpstream` provide an interface to establish tcp socket client. + +use crate::{Handle, IpAddress}; + +extern "Rust" { + fn sys_tcp_stream_connect(ip: &[u8], port: u16, timeout: Option) -> Result; + fn sys_tcp_stream_close(handle: Handle) -> Result<(), ()>; + fn sys_tcp_stream_read(handle: Handle, buffer: &mut [u8]) -> Result; + fn sys_tcp_stream_write(handle: Handle, buffer: &[u8]) -> Result; + fn sys_tcp_stream_set_read_timeout(handle: Handle, timeout: Option) -> Result<(), ()>; + fn sys_tcp_stream_get_read_timeout(handle: Handle) -> Result, ()>; + fn sys_tcp_stream_set_write_timeout(handle: Handle, timeout: Option) -> Result<(), ()>; + fn sys_tcp_stream_get_write_timeout(handle: Handle) -> Result, ()>; + fn sys_tcp_stream_peek(handle: Handle, buf: &mut [u8]) -> Result; + fn sys_tcp_stream_set_nonblocking(handle: Handle, mode: bool) -> Result<(), ()>; + fn sys_tcp_stream_set_tll(handle: Handle, ttl: u32) -> Result<(), ()>; + fn sys_tcp_stream_get_tll(handle: Handle) -> Result; + fn sys_tcp_stream_shutdown(handle: Handle, how: i32) -> Result<(), ()>; + fn sys_tcp_stream_peer_addr(handle: Handle) -> Result<(IpAddress, u16), ()>; +} + +/// Opens a TCP connection to a remote host. +#[inline(always)] +pub fn connect(ip: &[u8], port: u16, timeout: Option) -> Result { + unsafe { sys_tcp_stream_connect(ip, port, timeout) } +} + +/// Close a TCP connection +#[inline(always)] +pub fn close(handle: Handle) -> Result<(), ()> { + unsafe { sys_tcp_stream_close(handle) } +} + +#[inline(always)] +pub fn peek(handle: Handle, buf: &mut [u8]) -> Result { + unsafe { sys_tcp_stream_peek(handle, buf) } +} + +#[inline(always)] +pub fn peer_addr(handle: Handle) -> Result<(IpAddress, u16), ()> { + unsafe { sys_tcp_stream_peer_addr(handle) } +} +#[inline(always)] +pub fn read(handle: Handle, buffer: &mut [u8]) -> Result { + unsafe { sys_tcp_stream_read(handle, buffer) } +} + +#[inline(always)] +pub fn write(handle: Handle, buffer: &[u8]) -> Result { + unsafe { sys_tcp_stream_write(handle, buffer) } +} + +#[inline(always)] +pub fn set_read_timeout(handle: Handle, timeout: Option) -> Result<(), ()> { + unsafe { sys_tcp_stream_set_read_timeout(handle, timeout) } +} + +#[inline(always)] +pub fn set_write_timeout(handle: Handle, timeout: Option) -> Result<(), ()> { + unsafe { sys_tcp_stream_set_write_timeout(handle, timeout) } +} + +#[inline(always)] +pub fn get_read_timeout(handle: Handle) -> Result, ()> { + unsafe { sys_tcp_stream_get_read_timeout(handle) } +} + +#[inline(always)] +pub fn get_write_timeout(handle: Handle) -> Result, ()> { + unsafe { sys_tcp_stream_get_write_timeout(handle) } +} + +#[inline(always)] +pub fn set_nodelay(_: Handle, mode: bool) -> Result<(), ()> { + // smoltcp does not support Nagle's algorithm + // => to enable Nagle's algorithm isn't possible + if mode { + Ok(()) + } else { + Err(()) + } +} + +#[inline(always)] +pub fn nodelay(_: Handle) -> Result { + // smoltcp does not support Nagle's algorithm + // => return always true + Ok(true) +} + +#[inline(always)] +pub fn set_nonblocking(handle: Handle, mode: bool) -> Result<(), ()> { + unsafe { sys_tcp_stream_set_nonblocking(handle, mode) } +} + +#[inline(always)] +pub fn set_tll(handle: Handle, ttl: u32) -> Result<(), ()> { + unsafe { sys_tcp_stream_set_tll(handle, ttl) } +} + +#[inline(always)] +pub fn get_tll(handle: Handle) -> Result { + unsafe { sys_tcp_stream_get_tll(handle) } +} + +#[inline(always)] +pub fn shutdown(handle: Handle, how: i32) -> Result<(), ()> { + unsafe { sys_tcp_stream_shutdown(handle, how) } +} diff -Nru cargo-0.58.0/vendor/im-rc/Cargo.toml cargo-0.60.0ubuntu1/vendor/im-rc/Cargo.toml --- cargo-0.58.0/vendor/im-rc/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/im-rc/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -29,9 +29,9 @@ [lib] path = "./src/lib.rs" -[dependencies.arbitrary] -version = "0.4" -optional = true +#[dependencies.arbitrary] +#version = "0.4" +#optional = true [dependencies.bitmaps] version = "2" @@ -41,22 +41,22 @@ optional = true [dependencies.quickcheck] -version = "0.9" +version = ">= 0.9, < 2.0" optional = true [dependencies.rand_core] -version = "0.5.1" +version = ">= 0.5.1, < 0.7" [dependencies.rand_xoshiro] -version = "0.4" +version = ">= 0.4, < 0.7" [dependencies.rayon] version = "1" optional = true -[dependencies.refpool] -version = "0.4" -optional = true +#[dependencies.refpool] +#version = "0.4" +#optional = true [dependencies.serde] version = "1" @@ -67,8 +67,9 @@ [dependencies.typenum] version = "1.12" -[dev-dependencies.metrohash] -version = "1" +[dev-dependencies.tiny-keccak] +version = "2.0" +features = ["keccak"] [dev-dependencies.pretty_assertions] version = "0.6" @@ -76,11 +77,8 @@ [dev-dependencies.proptest] version = "0.9" -[dev-dependencies.proptest-derive] -version = "0.1" - [dev-dependencies.rand] -version = "0.7" +version = ">= 0.7, < 0.9" features = ["small_rng"] [dev-dependencies.rayon] @@ -96,6 +94,6 @@ [features] debug = [] -pool = ["refpool", "sized-chunks/refpool"] +#pool = ["refpool", "sized-chunks/refpool"] [badges.travis-ci] repository = "bodil/im-rs" diff -Nru cargo-0.58.0/vendor/im-rc/debian/patches/disable-features.patch cargo-0.60.0ubuntu1/vendor/im-rc/debian/patches/disable-features.patch --- cargo-0.58.0/vendor/im-rc/debian/patches/disable-features.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/im-rc/debian/patches/disable-features.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,38 @@ +Index: im-rc/Cargo.toml +=================================================================== +--- im-rc.orig/Cargo.toml ++++ im-rc/Cargo.toml +@@ -29,9 +29,9 @@ all-features = true + + [lib] + path = "./src/lib.rs" +-[dependencies.arbitrary] +-version = "0.4" +-optional = true ++#[dependencies.arbitrary] ++#version = "0.4" ++#optional = true + + [dependencies.bitmaps] + version = "2" +@@ -54,9 +54,9 @@ version = "0.4" + version = "1" + optional = true + +-[dependencies.refpool] +-version = "0.4" +-optional = true ++#[dependencies.refpool] ++#version = "0.4" ++#optional = true + + [dependencies.serde] + version = "1" +@@ -96,6 +96,6 @@ version = "0.9" + + [features] + debug = [] +-pool = ["refpool", "sized-chunks/refpool"] ++#pool = ["refpool", "sized-chunks/refpool"] + [badges.travis-ci] + repository = "bodil/im-rs" diff -Nru cargo-0.58.0/vendor/im-rc/debian/patches/disable-tests-proptest-derive.patch cargo-0.60.0ubuntu1/vendor/im-rc/debian/patches/disable-tests-proptest-derive.patch --- cargo-0.58.0/vendor/im-rc/debian/patches/disable-tests-proptest-derive.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/im-rc/debian/patches/disable-tests-proptest-derive.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,129 @@ +Index: im-rc/Cargo.toml +=================================================================== +--- im-rc.orig/Cargo.toml ++++ im-rc/Cargo.toml +@@ -77,9 +77,6 @@ version = "0.6" + [dev-dependencies.proptest] + version = "0.9" + +-[dev-dependencies.proptest-derive] +-version = "0.1" +- + [dev-dependencies.rand] + version = ">= 0.7, < 0.9" + features = ["small_rng"] +Index: im-rc/src/tests/hashset.rs +=================================================================== +--- im-rc.orig/src/tests/hashset.rs ++++ im-rc/src/tests/hashset.rs +@@ -7,15 +7,14 @@ use std::hash::Hash; + use crate::HashSet; + + use proptest::proptest; +-use proptest_derive::Arbitrary; ++//use proptest_derive::Arbitrary; + +-#[derive(Arbitrary, Debug)] ++#[derive(Debug)] + enum Action { + Insert(A), + Remove(A), + } + +-#[derive(Arbitrary)] + struct Actions(Vec>) + where + A: Hash + Eq + Clone; +@@ -50,7 +49,7 @@ where + } + } + +-proptest! { ++/*proptest! { + #[test] + fn comprehensive(actions: Actions) { + let mut set = HashSet::new(); +@@ -82,4 +81,4 @@ proptest! { + assert_eq!(HashSet::from(nat.clone()), set); + } + } +-} ++}*/ +Index: im-rc/src/tests/ordset.rs +=================================================================== +--- im-rc.orig/src/tests/ordset.rs ++++ im-rc/src/tests/ordset.rs +@@ -6,15 +6,13 @@ use std::fmt::{Debug, Error, Formatter, + use crate::OrdSet; + + use proptest::proptest; +-use proptest_derive::Arbitrary; + +-#[derive(Arbitrary, Debug)] ++#[derive(Debug)] + enum Action { + Insert(A), + Remove(A), + } + +-#[derive(Arbitrary)] + struct Actions(Vec>) + where + A: Ord + Clone; +@@ -49,7 +47,7 @@ where + } + } + +-proptest! { ++/*proptest! { + #[test] + fn comprehensive(actions: Actions) { + let mut set = OrdSet::new(); +@@ -82,4 +80,4 @@ proptest! { + assert!(nat.iter().eq(set.iter())); + } + } +-} ++}*/ +Index: im-rc/src/tests/vector.rs +=================================================================== +--- im-rc.orig/src/tests/vector.rs ++++ im-rc/src/tests/vector.rs +@@ -6,9 +6,9 @@ use std::iter::FromIterator; + use crate::Vector; + + use proptest::proptest; +-use proptest_derive::Arbitrary; ++//use proptest_derive::Arbitrary; + +-#[derive(Arbitrary, Debug)] ++#[derive(Debug)] + enum Action { + PushFront(A), + PushBack(A), +@@ -22,7 +22,6 @@ enum Action { + SplitRight(usize), + } + +-#[derive(Arbitrary)] + struct Actions(Vec>) + where + A: Clone; +@@ -118,7 +117,7 @@ fn cap_index(len: usize, index: usize) - + } + } + +-proptest! { ++/*proptest! { + #[test] + fn comprehensive(actions: Actions) { + let mut vec = Vector::new(); +@@ -216,7 +215,7 @@ proptest! { + assert_eq!(Vector::from_iter(nat.iter().cloned()), vec); + } + } +-} ++}*/ + + #[test] + fn test_inserts() { diff -Nru cargo-0.58.0/vendor/im-rc/debian/patches/relax-dep.patch cargo-0.60.0ubuntu1/vendor/im-rc/debian/patches/relax-dep.patch --- cargo-0.58.0/vendor/im-rc/debian/patches/relax-dep.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/im-rc/debian/patches/relax-dep.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,31 @@ +Index: im-rc/Cargo.toml +=================================================================== +--- im-rc.orig/Cargo.toml ++++ im-rc/Cargo.toml +@@ -41,14 +41,14 @@ version = "0.9" + optional = true + + [dependencies.quickcheck] +-version = "0.9" ++version = ">= 0.9, < 2.0" + optional = true + + [dependencies.rand_core] +-version = "0.5.1" ++version = ">= 0.5.1, < 0.7" + + [dependencies.rand_xoshiro] +-version = "0.4" ++version = ">= 0.4, < 0.7" + + [dependencies.rayon] + version = "1" +@@ -80,7 +80,7 @@ version = "0.9" + version = "0.1" + + [dev-dependencies.rand] +-version = "0.7" ++version = ">= 0.7, < 0.9" + features = ["small_rng"] + + [dev-dependencies.rayon] diff -Nru cargo-0.58.0/vendor/im-rc/debian/patches/replace-metrohash-with-keccak.patch cargo-0.60.0ubuntu1/vendor/im-rc/debian/patches/replace-metrohash-with-keccak.patch --- cargo-0.58.0/vendor/im-rc/debian/patches/replace-metrohash-with-keccak.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/im-rc/debian/patches/replace-metrohash-with-keccak.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,80 @@ +Replace metrohash with keccak, this is only used in one test +and one test doesn't justify adding a new crate to Debian. + +Index: im-rc/Cargo.toml +=================================================================== +--- im-rc.orig/Cargo.toml ++++ im-rc/Cargo.toml +@@ -67,8 +67,9 @@ version = "0.6" + + [dependencies.typenum] + version = "1.12" +-[dev-dependencies.metrohash] +-version = "1" ++[dev-dependencies.tiny-keccak] ++version = "2.0" ++features = ["keccak"] + + [dev-dependencies.pretty_assertions] + version = "0.6" +Index: im-rc/src/test.rs +=================================================================== +--- im-rc.orig/src/test.rs ++++ im-rc/src/test.rs +@@ -2,8 +2,9 @@ + // License, v. 2.0. If a copy of the MPL was not distributed with this + // file, You can obtain one at http://mozilla.org/MPL/2.0/. + +-use metrohash::MetroHash64; ++use tiny_keccak::Keccak; + use std::hash::{BuildHasher, Hasher}; ++use tiny_keccak::Hasher as tiny_keccak_Hasher; + use std::marker::PhantomData; + use typenum::{Unsigned, U64}; + +@@ -64,6 +65,34 @@ impl Default for LolHasher< + } + } + ++pub(crate) struct KeccakHasher { ++ k : Keccak, ++} ++ ++impl KeccakHasher { ++ fn with_seed(seed: u64) -> KeccakHasher { ++ let mut k = Keccak::v256(); ++ let sb = seed.to_le_bytes(); ++ k.update(&sb); ++ KeccakHasher { k } ++ ++ } ++} ++ ++impl Hasher for KeccakHasher { ++ fn write(&mut self, bytes: &[u8]) { ++ self.k.update(bytes); ++ } ++ ++ fn finish(&self) -> u64 { ++ let mut rb: [u8; 8] = [0;8]; ++ let k = self.k.clone(); ++ k.finalize(& mut rb); ++ return u64::from_le_bytes(rb); ++ } ++} ++ ++ + pub(crate) struct MetroHashBuilder { + seed: u64, + } +@@ -79,8 +108,8 @@ impl MetroHashBuilder { + } + + impl BuildHasher for MetroHashBuilder { +- type Hasher = MetroHash64; ++ type Hasher = KeccakHasher; + fn build_hasher(&self) -> Self::Hasher { +- MetroHash64::with_seed(self.seed) ++ KeccakHasher::with_seed(self.seed) + } + } diff -Nru cargo-0.58.0/vendor/im-rc/debian/patches/series cargo-0.60.0ubuntu1/vendor/im-rc/debian/patches/series --- cargo-0.58.0/vendor/im-rc/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/im-rc/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,4 @@ +disable-features.patch +relax-dep.patch +replace-metrohash-with-keccak.patch +disable-tests-proptest-derive.patch diff -Nru cargo-0.58.0/vendor/im-rc/src/test.rs cargo-0.60.0ubuntu1/vendor/im-rc/src/test.rs --- cargo-0.58.0/vendor/im-rc/src/test.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/im-rc/src/test.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,8 +2,9 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -use metrohash::MetroHash64; +use tiny_keccak::Keccak; use std::hash::{BuildHasher, Hasher}; +use tiny_keccak::Hasher as tiny_keccak_Hasher; use std::marker::PhantomData; use typenum::{Unsigned, U64}; @@ -64,6 +65,34 @@ } } +pub(crate) struct KeccakHasher { + k : Keccak, +} + +impl KeccakHasher { + fn with_seed(seed: u64) -> KeccakHasher { + let mut k = Keccak::v256(); + let sb = seed.to_le_bytes(); + k.update(&sb); + KeccakHasher { k } + + } +} + +impl Hasher for KeccakHasher { + fn write(&mut self, bytes: &[u8]) { + self.k.update(bytes); + } + + fn finish(&self) -> u64 { + let mut rb: [u8; 8] = [0;8]; + let k = self.k.clone(); + k.finalize(& mut rb); + return u64::from_le_bytes(rb); + } +} + + pub(crate) struct MetroHashBuilder { seed: u64, } @@ -79,8 +108,8 @@ } impl BuildHasher for MetroHashBuilder { - type Hasher = MetroHash64; + type Hasher = KeccakHasher; fn build_hasher(&self) -> Self::Hasher { - MetroHash64::with_seed(self.seed) + KeccakHasher::with_seed(self.seed) } } diff -Nru cargo-0.58.0/vendor/im-rc/src/tests/hashset.rs cargo-0.60.0ubuntu1/vendor/im-rc/src/tests/hashset.rs --- cargo-0.58.0/vendor/im-rc/src/tests/hashset.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/im-rc/src/tests/hashset.rs 2022-04-20 13:48:09.000000000 +0000 @@ -7,15 +7,14 @@ use crate::HashSet; use proptest::proptest; -use proptest_derive::Arbitrary; +//use proptest_derive::Arbitrary; -#[derive(Arbitrary, Debug)] +#[derive(Debug)] enum Action { Insert(A), Remove(A), } -#[derive(Arbitrary)] struct Actions(Vec>) where A: Hash + Eq + Clone; @@ -50,7 +49,7 @@ } } -proptest! { +/*proptest! { #[test] fn comprehensive(actions: Actions) { let mut set = HashSet::new(); @@ -82,4 +81,4 @@ assert_eq!(HashSet::from(nat.clone()), set); } } -} +}*/ diff -Nru cargo-0.58.0/vendor/im-rc/src/tests/ordset.rs cargo-0.60.0ubuntu1/vendor/im-rc/src/tests/ordset.rs --- cargo-0.58.0/vendor/im-rc/src/tests/ordset.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/im-rc/src/tests/ordset.rs 2022-04-20 13:48:09.000000000 +0000 @@ -6,15 +6,13 @@ use crate::OrdSet; use proptest::proptest; -use proptest_derive::Arbitrary; -#[derive(Arbitrary, Debug)] +#[derive(Debug)] enum Action { Insert(A), Remove(A), } -#[derive(Arbitrary)] struct Actions(Vec>) where A: Ord + Clone; @@ -49,7 +47,7 @@ } } -proptest! { +/*proptest! { #[test] fn comprehensive(actions: Actions) { let mut set = OrdSet::new(); @@ -82,4 +80,4 @@ assert!(nat.iter().eq(set.iter())); } } -} +}*/ diff -Nru cargo-0.58.0/vendor/im-rc/src/tests/vector.rs cargo-0.60.0ubuntu1/vendor/im-rc/src/tests/vector.rs --- cargo-0.58.0/vendor/im-rc/src/tests/vector.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/im-rc/src/tests/vector.rs 2022-04-20 13:48:09.000000000 +0000 @@ -6,9 +6,9 @@ use crate::Vector; use proptest::proptest; -use proptest_derive::Arbitrary; +//use proptest_derive::Arbitrary; -#[derive(Arbitrary, Debug)] +#[derive(Debug)] enum Action { PushFront(A), PushBack(A), @@ -22,7 +22,6 @@ SplitRight(usize), } -#[derive(Arbitrary)] struct Actions(Vec>) where A: Clone; @@ -118,7 +117,7 @@ } } -proptest! { +/*proptest! { #[test] fn comprehensive(actions: Actions) { let mut vec = Vector::new(); @@ -216,7 +215,7 @@ assert_eq!(Vector::from_iter(nat.iter().cloned()), vec); } } -} +}*/ #[test] fn test_inserts() { diff -Nru cargo-0.58.0/vendor/libc/build.rs cargo-0.60.0ubuntu1/vendor/libc/build.rs --- cargo-0.58.0/vendor/libc/build.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -60,6 +60,11 @@ println!("cargo:rustc-cfg=libc_align"); } + // Rust >= 1.26 supports i128 and u128: + if rustc_minor_ver >= 26 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_int128"); + } + // Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it. // Otherwise, it defines an incompatible type to retaining // backwards-compatibility. @@ -82,6 +87,11 @@ println!("cargo:rustc-cfg=libc_ptr_addr_of"); } + // Rust >= 1.37.0 allows underscores as anonymous constant names. + if rustc_minor_ver >= 37 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_underscore_const_names"); + } + // #[thread_local] is currently unstable if rustc_dep_of_std { println!("cargo:rustc-cfg=libc_thread_local"); diff -Nru cargo-0.58.0/vendor/libc/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/libc/.cargo-checksum.json --- cargo-0.58.0/vendor/libc/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9"} \ No newline at end of file +{"files":{},"package":"21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/libc/Cargo.toml cargo-0.60.0ubuntu1/vendor/libc/Cargo.toml --- cargo-0.58.0/vendor/libc/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -11,20 +11,42 @@ [package] name = "libc" -version = "0.2.113" +version = "0.2.124" authors = ["The Rust Project Developers"] build = "build.rs" -exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml"] -description = "Raw FFI bindings to platform libraries like libc.\n" +exclude = [ + "/ci/*", + "/.github/*", + "/.cirrus.yml", + "/triagebot.toml", +] +description = """ +Raw FFI bindings to platform libraries like libc. +""" homepage = "https://github.com/rust-lang/libc" documentation = "https://docs.rs/libc/" readme = "README.md" -keywords = ["libc", "ffi", "bindings", "operating", "system"] -categories = ["external-ffi-bindings", "no-std", "os"] +keywords = [ + "libc", + "ffi", + "bindings", + "operating", + "system", +] +categories = [ + "external-ffi-bindings", + "no-std", + "os", +] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/libc" + [package.metadata.docs.rs] -features = ["const-extern-fn", "extra_traits"] +features = [ + "const-extern-fn", + "extra_traits", +] + [dependencies.rustc-std-workspace-core] version = "1.0.0" optional = true @@ -34,6 +56,9 @@ const-extern-fn = [] default = ["std"] extra_traits = [] -rustc-dep-of-std = ["align", "rustc-std-workspace-core"] +rustc-dep-of-std = [ + "align", + "rustc-std-workspace-core", +] std = [] use_std = ["std"] diff -Nru cargo-0.58.0/vendor/libc/LICENSE-APACHE cargo-0.60.0ubuntu1/vendor/libc/LICENSE-APACHE --- cargo-0.58.0/vendor/libc/LICENSE-APACHE 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/LICENSE-APACHE 2022-04-20 13:48:09.000000000 +0000 @@ -174,28 +174,3 @@ of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff -Nru cargo-0.58.0/vendor/libc/src/fixed_width_ints.rs cargo-0.60.0ubuntu1/vendor/libc/src/fixed_width_ints.rs --- cargo-0.58.0/vendor/libc/src/fixed_width_ints.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/fixed_width_ints.rs 2022-04-20 13:48:09.000000000 +0000 @@ -18,3 +18,82 @@ pub type uint32_t = u32; #[deprecated(since = "0.2.55", note = "Use u64 instead.")] pub type uint64_t = u64; + +cfg_if! { + if #[cfg(all(libc_int128, target_arch = "aarch64", not(target_os = "windows")))] { + // This introduces partial support for FFI with __int128 and + // equivalent types on platforms where Rust's definition is validated + // to match the standard C ABI of that platform. + // + // Rust does not guarantee u128/i128 are sound for FFI, and its + // definitions are in fact known to be incompatible. [0] + // + // However these problems aren't fundamental, and are just platform + // inconsistencies. Specifically at the time of this writing: + // + // * For x64 SysV ABIs (everything but Windows), the types are underaligned. + // * For all Windows ABIs, Microsoft doesn't actually officially define __int128, + // and as a result different implementations don't actually agree on its ABI. + // + // But on the other major aarch64 platforms (android, linux, ios, macos) we have + // validated that rustc has the right ABI for these types. This is important because + // aarch64 uses these types in some fundamental OS types like user_fpsimd_struct, + // which represents saved simd registers. + // + // Any API which uses these types will need to `#[ignore(improper_ctypes)]` + // until the upstream rust issue is resolved, but this at least lets us make + // progress on platforms where this type is important. + // + // The list of supported architectures and OSes is intentionally very restricted, + // as careful work needs to be done to verify that a particular platform + // has a conformant ABI. + // + // [0]: https://github.com/rust-lang/rust/issues/54341 + + /// C `__int128` (a GCC extension that's part of many ABIs) + pub type __int128 = i128; + /// C `unsigned __int128` (a GCC extension that's part of many ABIs) + pub type __uint128 = u128; + /// C __int128_t (alternate name for [__int128][]) + pub type __int128_t = i128; + /// C __uint128_t (alternate name for [__uint128][]) + pub type __uint128_t = u128; + + cfg_if! { + if #[cfg(libc_underscore_const_names)] { + macro_rules! static_assert_eq { + ($a:expr, $b:expr) => { + const _: [(); $a] = [(); $b]; + }; + } + + // NOTE: if you add more platforms to here, you may need to cfg + // these consts. They should always match the platform's values + // for `sizeof(__int128)` and `_Alignof(__int128)`. + const _SIZE_128: usize = 16; + const _ALIGN_128: usize = 16; + + // Since Rust doesn't officially guarantee that these types + // have compatible ABIs, we const assert that these values have the + // known size/align of the target platform's libc. If rustc ever + // tries to regress things, it will cause a compilation error. + // + // This isn't a bullet-proof solution because e.g. it doesn't + // catch the fact that llvm and gcc disagree on how x64 __int128 + // is actually *passed* on the stack (clang underaligns it for + // the same reason that rustc *never* properly aligns it). + static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128); + static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128); + + static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128); + static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128); + + static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128); + static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128); + + static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128); + static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128); + } + } + } +} diff -Nru cargo-0.58.0/vendor/libc/src/fuchsia/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/fuchsia/mod.rs --- cargo-0.58.0/vendor/libc/src/fuchsia/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/fuchsia/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1313,6 +1313,7 @@ pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; +pub const DT_UNKNOWN: u8 = 0; pub const DT_FIFO: u8 = 1; pub const DT_CHR: u8 = 2; pub const DT_DIR: u8 = 4; diff -Nru cargo-0.58.0/vendor/libc/src/lib.rs cargo-0.60.0ubuntu1/vendor/libc/src/lib.rs --- cargo-0.58.0/vendor/libc/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -25,8 +25,8 @@ #![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)] #![cfg_attr(feature = "rustc-dep-of-std", no_core)] #![cfg_attr( - any(feature = "rustc-dep-of-std", target_os = "redox"), - feature(static_nobundle, native_link_modifiers, native_link_modifiers_bundle) + feature = "rustc-dep-of-std", + feature(native_link_modifiers, native_link_modifiers_bundle) )] #![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))] diff -Nru cargo-0.58.0/vendor/libc/src/solid/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/solid/mod.rs --- cargo-0.58.0/vendor/libc/src/solid/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/solid/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -535,8 +535,8 @@ pub fn strtod_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f64; pub fn strtof_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f32; pub fn strtold_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f64; - pub fn _Exit(arg1: c_int); - pub fn abort(); + pub fn _Exit(arg1: c_int) -> !; + pub fn abort() -> !; pub fn abs(arg1: c_int) -> c_int; pub fn atexit(arg1: ::Option) -> c_int; pub fn atoi(arg1: *const c_char) -> c_int; @@ -553,7 +553,7 @@ ) -> *mut c_void; pub fn calloc(arg1: size_t, arg2: size_t) -> *mut c_void; pub fn div(arg1: c_int, arg2: c_int) -> div_t; - pub fn exit(arg1: c_int); + pub fn exit(arg1: c_int) -> !; pub fn free(arg1: *mut c_void); pub fn getenv(arg1: *const c_char) -> *mut c_char; pub fn labs(arg1: c_long) -> c_long; diff -Nru cargo-0.58.0/vendor/libc/src/unix/bsd/apple/b64/aarch64/align.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/apple/b64/aarch64/align.rs --- cargo-0.58.0/vendor/libc/src/unix/bsd/apple/b64/aarch64/align.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/apple/b64/aarch64/align.rs 2022-04-20 13:48:09.000000000 +0000 @@ -39,8 +39,15 @@ pub __pad: u32, } - #[repr(align(16))] + // This type natively uses a uint128, but for a while we hacked + // it in with repr(align) and `[u64; 2]`. uint128 isn't available + // all the way back to our earliest supported versions so we + // preserver the old shim. + #[cfg_attr(not(libc_int128), repr(align(16)))] pub struct __darwin_arm_neon_state64 { + #[cfg(libc_int128)] + pub __v: [::__uint128_t; 32], + #[cfg(not(libc_int128))] pub __v: [[u64; 2]; 32], pub __fpsr: u32, pub __fpcr: u32, diff -Nru cargo-0.58.0/vendor/libc/src/unix/bsd/apple/b64/aarch64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/apple/b64/aarch64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/bsd/apple/b64/aarch64/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/apple/b64/aarch64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -6,6 +6,8 @@ } } +pub const CLOCK_UPTIME_RAW: ::clockid_t = 8; + cfg_if! { if #[cfg(libc_align)] { mod align; diff -Nru cargo-0.58.0/vendor/libc/src/unix/bsd/apple/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/apple/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/bsd/apple/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/apple/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -128,6 +128,9 @@ pub type CCCryptorStatus = i32; pub type CCRNGStatus = ::CCCryptorStatus; +pub type copyfile_state_t = *mut ::c_void; +pub type copyfile_flags_t = u32; + deprecated_mach! { pub type mach_timebase_info_data_t = mach_timebase_info; } @@ -221,6 +224,12 @@ pub imr_ifindex: ::c_int, } + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_sourceaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct aiocb { pub aio_fildes: ::c_int, pub aio_offset: ::off_t, @@ -1169,9 +1178,9 @@ pub ifi_noproto: u64, pub ifi_recvtiming: u32, pub ifi_xmittiming: u32, - #[cfg(any(target_arch = "arm", target_arch = "x86"))] + #[cfg(target_pointer_width = "32")] pub ifi_lastchange: ::timeval, - #[cfg(not(any(target_arch = "arm", target_arch = "x86")))] + #[cfg(not(target_pointer_width = "32"))] pub ifi_lastchange: timeval32, } @@ -3539,6 +3548,10 @@ pub const IPV6_HOPLIMIT: ::c_int = 47; pub const IPV6_RECVPKTINFO: ::c_int = 61; pub const IPV6_DONTFRAG: ::c_int = 62; +pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 70; +pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 71; +pub const IP_BLOCK_SOURCE: ::c_int = 72; +pub const IP_UNBLOCK_SOURCE: ::c_int = 73; pub const TCP_NOPUSH: ::c_int = 4; pub const TCP_NOOPT: ::c_int = 8; @@ -4611,6 +4624,43 @@ pub const RUSAGE_INFO_V3: ::c_int = 3; pub const RUSAGE_INFO_V4: ::c_int = 4; +// copyfile.h +pub const COPYFILE_ACL: ::copyfile_flags_t = 1 << 0; +pub const COPYFILE_STAT: ::copyfile_flags_t = 1 << 1; +pub const COPYFILE_XATTR: ::copyfile_flags_t = 1 << 2; +pub const COPYFILE_DATA: ::copyfile_flags_t = 1 << 3; +pub const COPYFILE_SECURITY: ::copyfile_flags_t = COPYFILE_STAT | COPYFILE_ACL; +pub const COPYFILE_METADATA: ::copyfile_flags_t = COPYFILE_SECURITY | COPYFILE_XATTR; +pub const COPYFILE_RECURSIVE: ::copyfile_flags_t = 1 << 15; +pub const COPYFILE_CHECK: ::copyfile_flags_t = 1 << 16; +pub const COPYFILE_EXCL: ::copyfile_flags_t = 1 << 17; +pub const COPYFILE_NOFOLLOW_SRC: ::copyfile_flags_t = 1 << 18; +pub const COPYFILE_NOFOLLOW_DST: ::copyfile_flags_t = 1 << 19; +pub const COPYFILE_MOVE: ::copyfile_flags_t = 1 << 20; +pub const COPYFILE_UNLINK: ::copyfile_flags_t = 1 << 21; +pub const COPYFILE_NOFOLLOW: ::copyfile_flags_t = COPYFILE_NOFOLLOW_SRC | COPYFILE_NOFOLLOW_DST; +pub const COPYFILE_PACK: ::copyfile_flags_t = 1 << 22; +pub const COPYFILE_UNPACK: ::copyfile_flags_t = 1 << 23; +pub const COPYFILE_CLONE: ::copyfile_flags_t = 1 << 24; +pub const COPYFILE_CLONE_FORCE: ::copyfile_flags_t = 1 << 25; +pub const COPYFILE_RUN_IN_PLACE: ::copyfile_flags_t = 1 << 26; +pub const COPYFILE_DATA_SPARSE: ::copyfile_flags_t = 1 << 27; +pub const COPYFILE_PRESERVE_DST_TRACKED: ::copyfile_flags_t = 1 << 28; +pub const COPYFILE_VERBOSE: ::copyfile_flags_t = 1 << 30; +pub const COPYFILE_RECURSE_ERROR: ::c_int = 0; +pub const COPYFILE_RECURSE_FILE: ::c_int = 1; +pub const COPYFILE_RECURSE_DIR: ::c_int = 2; +pub const COPYFILE_RECURSE_DIR_CLEANUP: ::c_int = 3; +pub const COPYFILE_COPY_DATA: ::c_int = 4; +pub const COPYFILE_COPY_XATTR: ::c_int = 5; +pub const COPYFILE_START: ::c_int = 1; +pub const COPYFILE_FINISH: ::c_int = 2; +pub const COPYFILE_ERR: ::c_int = 3; +pub const COPYFILE_PROGRESS: ::c_int = 4; +pub const COPYFILE_CONTINUE: ::c_int = 0; +pub const COPYFILE_SKIP: ::c_int = 1; +pub const COPYFILE_QUIT: ::c_int = 2; + cfg_if! { if #[cfg(libc_const_extern_fn)] { const fn __DARWIN_ALIGN32(p: usize) -> usize { @@ -5267,6 +5317,19 @@ flags: u32, ) -> ::c_int; + pub fn copyfile( + from: *const ::c_char, + to: *const ::c_char, + state: copyfile_state_t, + flags: copyfile_flags_t, + ) -> ::c_int; + pub fn fcopyfile( + from: ::c_int, + to: ::c_int, + state: copyfile_state_t, + flags: copyfile_flags_t, + ) -> ::c_int; + // Added in macOS 10.13 // ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1 pub fn memset_s(s: *mut ::c_void, smax: ::size_t, c: ::c_int, n: ::size_t) -> ::c_int; @@ -5469,10 +5532,10 @@ } cfg_if! { - if #[cfg(any(target_arch = "arm", target_arch = "x86"))] { + if #[cfg(target_pointer_width = "32")] { mod b32; pub use self::b32::*; - } else if #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] { + } else if #[cfg(target_pointer_width = "64")] { mod b64; pub use self::b64::*; } else { diff -Nru cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -762,6 +762,8 @@ pub const F_SETLKW: ::c_int = 9; pub const F_GETPATH: ::c_int = 19; pub const ENOMEDIUM: ::c_int = 93; +pub const ENOTRECOVERABLE: ::c_int = 94; +pub const EOWNERDEAD: ::c_int = 95; pub const EASYNC: ::c_int = 99; pub const ELAST: ::c_int = 99; pub const RLIMIT_POSIXLOCKS: ::c_int = 11; @@ -1348,7 +1350,7 @@ const_fn! { {const} fn _CMSG_ALIGN(n: usize) -> usize { - (n + ::mem::size_of::<::c_long>()) & !::mem::size_of::<::c_long>() + (n + (::mem::size_of::<::c_long>() - 1)) & !(::mem::size_of::<::c_long>() - 1) } } diff -Nru cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -41,12 +41,14 @@ pub type fhandle_t = fhandle; +pub type au_id_t = ::uid_t; +pub type au_asid_t = ::pid_t; + // It's an alias over "struct __kvm_t". However, its fields aren't supposed to be used directly, // making the type definition system dependent. Better not bind it exactly. pub type kvm_t = ::c_void; -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] -#[derive(PartialEq, Eq)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_support_flags { DEVSTAT_ALL_SUPPORTED = 0x00, @@ -61,8 +63,7 @@ } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] -#[derive(PartialEq, Eq)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_trans_flags { DEVSTAT_NO_DATA = 0x00, @@ -78,8 +79,7 @@ } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] -#[derive(PartialEq, Eq)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_tag_type { DEVSTAT_TAG_SIMPLE = 0x00, @@ -94,8 +94,7 @@ } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] -#[derive(PartialEq, Eq)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_match_flags { DEVSTAT_MATCH_NONE = 0x00, @@ -110,8 +109,7 @@ } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] -#[derive(PartialEq, Eq)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_priority { DEVSTAT_PRIORITY_MIN = 0x000, @@ -132,8 +130,7 @@ } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] -#[derive(PartialEq, Eq)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_type_flags { DEVSTAT_TYPE_DIRECT = 0x000, @@ -165,8 +162,7 @@ } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] -#[derive(PartialEq, Eq)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_metric { DSM_NONE, @@ -223,8 +219,7 @@ } } -#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] -#[derive(PartialEq, Eq)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] #[repr(u32)] pub enum devstat_select_mode { DS_SELECT_ADD, @@ -600,6 +595,11 @@ pub mode: u16, } + pub struct spacectl_range { + pub r_offset: ::off_t, + pub r_len: ::off_t + } + pub struct rusage_ext { pub rux_runtime: u64, pub rux_uticks: u64, @@ -955,6 +955,39 @@ pub sc_ngroups: ::c_int, pub sc_groups: [::gid_t; 1], } + + pub struct ifconf { + pub ifc_len: ::c_int, + #[cfg(libc_union)] + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + pub struct au_mask_t { + pub am_success: ::c_uint, + pub am_failure: ::c_uint, + } + + pub struct au_tid_t { + pub port: u32, + pub machine: u32, + } + + pub struct auditinfo_t { + pub ai_auid: ::au_id_t, + pub ai_mask: ::au_mask_t, + pub ai_termid: au_tid_t, + pub ai_asid: ::au_asid_t, + } + + pub struct tcp_fastopen { + pub enable: ::c_int, + pub psk: [u8; ::TCP_FASTOPEN_PSK_LEN as usize], + } + + pub struct tcp_function_set { + pub function_set_name: [::c_char; ::TCP_FUNCTION_NAME_LEN_MAX as usize], + pub pcbcnt: u32, + } } s_no_extra_traits! { @@ -1137,6 +1170,12 @@ pub ifr_ifru: ::sockaddr, } + #[cfg(libc_union)] + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: ::caddr_t, + pub ifcu_req: *mut ifreq, + } + pub struct ifstat { /// if name, e.g. "en0" pub ifs_name: [::c_char; ::IFNAMSIZ as usize], @@ -1544,6 +1583,37 @@ } } + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifc_ifcu {} + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifc_ifcu { + fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { + unsafe { + self.ifcu_buf == other.ifcu_buf && + self.ifcu_req == other.ifcu_req + } + } + } + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifc_ifcu { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifc_ifcu") + .field("ifcu_buf", unsafe { &self.ifcu_buf }) + .field("ifcu_req", unsafe { &self.ifcu_req }) + .finish() + } + } + + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifc_ifcu { + fn hash(&self, state: &mut H) { + unsafe { self.ifcu_buf.hash(state) }; + unsafe { self.ifcu_req.hash(state) }; + } + } + impl PartialEq for ifstat { fn eq(&self, other: &ifstat) -> bool { let self_ascii: &[::c_char] = &self.ascii; @@ -2056,7 +2126,6 @@ pub const KERN_HOSTUUID: ::c_int = 36; pub const KERN_ARND: ::c_int = 37; pub const KERN_MAXPHYS: ::c_int = 38; -pub const KERN_STACKTOP: ::c_int = 39; pub const KERN_PROC_ALL: ::c_int = 0; pub const KERN_PROC_PID: ::c_int = 1; @@ -2258,6 +2327,8 @@ pub const PT_SETDBREGS: ::c_int = 38; pub const PT_VM_TIMESTAMP: ::c_int = 40; pub const PT_VM_ENTRY: ::c_int = 41; +pub const PT_GETREGSET: ::c_int = 42; +pub const PT_SETREGSET: ::c_int = 43; pub const PT_FIRSTMACH: ::c_int = 64; pub const PTRACE_EXEC: ::c_int = 0x0001; @@ -2790,10 +2861,24 @@ pub const TCP_INFO: ::c_int = 32; pub const TCP_CONGESTION: ::c_int = 64; pub const TCP_CCALGOOPT: ::c_int = 65; +pub const TCP_MAXUNACKTIME: ::c_int = 68; +pub const TCP_MAXPEAKRATE: ::c_int = 69; +pub const TCP_IDLE_REDUCE: ::c_int = 70; +pub const TCP_REMOTE_UDP_ENCAPS_PORT: ::c_int = 71; +pub const TCP_DELACK: ::c_int = 72; +pub const TCP_FIN_IS_RST: ::c_int = 73; +pub const TCP_LOG_LIMIT: ::c_int = 74; +pub const TCP_SHARED_CWND_ALLOWED: ::c_int = 75; +pub const TCP_PROC_ACCOUNTING: ::c_int = 76; +pub const TCP_USE_CMP_ACKS: ::c_int = 77; +pub const TCP_PERF_INFO: ::c_int = 78; +pub const TCP_LRD: ::c_int = 79; pub const TCP_KEEPINIT: ::c_int = 128; pub const TCP_FASTOPEN: ::c_int = 1025; pub const TCP_PCAP_OUT: ::c_int = 2048; pub const TCP_PCAP_IN: ::c_int = 4096; +pub const TCP_FASTOPEN_PSK_LEN: ::c_int = 16; +pub const TCP_FUNCTION_NAME_LEN_MAX: ::c_int = 32; pub const IP_BINDANY: ::c_int = 24; pub const IP_BINDMULTI: ::c_int = 25; @@ -2801,6 +2886,7 @@ pub const IP_ORIGDSTADDR: ::c_int = 27; pub const IP_RECVORIGDSTADDR: ::c_int = IP_ORIGDSTADDR; +pub const IP_DONTFRAG: ::c_int = 67; pub const IP_RECVTOS: ::c_int = 68; pub const IPV6_BINDANY: ::c_int = 64; @@ -2979,6 +3065,9 @@ pub const F_SEAL_SHRINK: ::c_int = 2; pub const F_SEAL_WRITE: ::c_int = 8; +// for use with fspacectl +pub const SPACECTL_DEALLOC: ::c_int = 1; + // For getrandom() pub const GRND_NONBLOCK: ::c_uint = 0x1; pub const GRND_RANDOM: ::c_uint = 0x2; @@ -3498,63 +3587,6 @@ /// Unmount in async context. pub const MNT_DEFERRED: u64 = 0x200000000000; -/// Forced unmount in progress. -pub const MNTK_UNMOUNTF: u32 = 0x00000001; -/// Filtered async flag. -pub const MNTK_ASYNC: u32 = 0x00000002; -/// Async disabled by softdep. -pub const MNTK_SOFTDEP: u32 = 0x00000004; -/// Don't do msync. -pub const MNTK_NOMSYNC: u32 = 0x00000008; -/// Lock draining is happening. -pub const MNTK_DRAINING: u32 = 0x00000010; -/// Refcount expiring is happening. -pub const MNTK_REFEXPIRE: u32 = 0x00000020; -/// Allow shared locking for more ops. -pub const MNTK_EXTENDED_SHARED: u32 = 0x00000040; -/// Allow shared locking for writes. -pub const MNTK_SHARED_WRITES: u32 = 0x00000080; -/// Disallow page faults during reads and writes. Filesystem shall properly handle i/o -/// state on EFAULT. -pub const MNTK_NO_IOPF: u32 = 0x00000100; -/// Pending recursive unmount. -pub const MNTK_RECURSE: u32 = 0x00000200; -/// Waiting to drain MNTK_UPPER_PENDING. -pub const MNTK_UPPER_WAITER: u32 = 0x00000400; -pub const MNTK_LOOKUP_EXCL_DOTDOT: u32 = 0x00000800; -pub const MNTK_UNMAPPED_BUFS: u32 = 0x00002000; -/// FS uses the buffer cache. -pub const MNTK_USES_BCACHE: u32 = 0x00004000; -/// Keep use ref for text. -pub const MNTK_TEXT_REFS: u32 = 0x00008000; -pub const MNTK_VMSETSIZE_BUG: u32 = 0x00010000; -/// A hack for F_ISUNIONSTACK. -pub const MNTK_UNIONFS: u32 = 0x00020000; -/// fast path lookup is supported. -pub const MNTK_FPLOOKUP: u32 = 0x00040000; -/// Suspended by all-fs suspension. -pub const MNTK_SUSPEND_ALL: u32 = 0x00080000; -/// Waiting on unmount taskqueue. -pub const MNTK_TASKQUEUE_WAITER: u32 = 0x00100000; -/// Disable async. -pub const MNTK_NOASYNC: u32 = 0x00800000; -/// Unmount in progress. -pub const MNTK_UNMOUNT: u32 = 0x01000000; -/// Waiting for unmount to finish. -pub const MNTK_MWAIT: u32 = 0x02000000; -/// Request write suspension. -pub const MNTK_SUSPEND: u32 = 0x08000000; -/// Block secondary writes. -pub const MNTK_SUSPEND2: u32 = 0x04000000; -/// Write operations are suspended. -pub const MNTK_SUSPENDED: u32 = 0x10000000; -/// auto disable cache for nullfs mounts over this fs. -pub const MNTK_NULL_NOCACHE: u32 = 0x20000000; -/// FS supports shared lock lookups. -pub const MNTK_LOOKUP_SHARED: u32 = 0x40000000; -/// Don't send KNOTEs from VOP hooks. -pub const MNTK_NOKNOTE: u32 = 0x80000000; - /// Get configured filesystems. pub const VFS_VFSCONF: ::c_int = 0; /// Generic filesystem information. @@ -3619,6 +3651,9 @@ pub const MFD_ALLOW_SEALING: ::c_uint = 0x00000002; pub const MFD_HUGETLB: ::c_uint = 0x00000004; +pub const SHM_LARGEPAGE_ALLOC_DEFAULT: ::c_int = 0; +pub const SHM_LARGEPAGE_ALLOC_NOWAIT: ::c_int = 1; +pub const SHM_LARGEPAGE_ALLOC_HARD: ::c_int = 2; pub const SHM_RENAME_NOREPLACE: ::c_int = 1 << 0; pub const SHM_RENAME_EXCHANGE: ::c_int = 1 << 1; @@ -3863,6 +3898,14 @@ nbytes: ::size_t, ) -> ::ssize_t; + pub fn fspacectl( + fd: ::c_int, + cmd: ::c_int, + rqsr: *const spacectl_range, + flags: ::c_int, + rmsr: *mut spacectl_range, + ) -> ::c_int; + pub fn jail(jail: *mut ::jail) -> ::c_int; pub fn jail_attach(jid: ::c_int) -> ::c_int; pub fn jail_remove(jid: ::c_int) -> ::c_int; @@ -4159,16 +4202,25 @@ pub fn procctl(idtype: ::idtype_t, id: ::id_t, cmd: ::c_int, data: *mut ::c_void) -> ::c_int; pub fn getpagesize() -> ::c_int; + pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int; pub fn adjtime(arg1: *const ::timeval, arg2: *mut ::timeval) -> ::c_int; pub fn clock_getcpuclockid2(arg1: ::id_t, arg2: ::c_int, arg3: *mut clockid_t) -> ::c_int; + pub fn shm_create_largepage( + path: *const ::c_char, + flags: ::c_int, + psind: ::c_int, + alloc_policy: ::c_int, + mode: ::mode_t, + ) -> ::c_int; pub fn shm_rename( path_from: *const ::c_char, path_to: *const ::c_char, flags: ::c_int, ) -> ::c_int; pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn setaudit(auditinfo: *const auditinfo_t) -> ::c_int; } #[link(name = "kvm")] @@ -4272,6 +4324,11 @@ scale: ::c_int, flags: ::c_int, ) -> ::c_int; + + pub fn flopen(path: *const ::c_char, flags: ::c_int, ...) -> ::c_int; + pub fn flopenat(fd: ::c_int, path: *const ::c_char, flags: ::c_int, ...) -> ::c_int; + + pub fn getlocalbase() -> *const ::c_char; } #[link(name = "procstat")] diff -Nru cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/freebsdlike/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/freebsdlike/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -96,6 +96,12 @@ pub imr_ifindex: ::c_int, } + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_sourceaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct glob_t { pub gl_pathc: ::size_t, pub gl_matchc: ::size_t, @@ -963,6 +969,11 @@ pub const IPV6_HOPLIMIT: ::c_int = 47; pub const IPV6_RECVTCLASS: ::c_int = 57; pub const IPV6_TCLASS: ::c_int = 61; +pub const IPV6_DONTFRAG: ::c_int = 62; +pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 70; +pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 71; +pub const IP_BLOCK_SOURCE: ::c_int = 72; +pub const IP_UNBLOCK_SOURCE: ::c_int = 73; pub const TCP_NOPUSH: ::c_int = 4; pub const TCP_NOOPT: ::c_int = 8; @@ -1594,6 +1605,16 @@ pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> ::c_int; pub fn pthread_get_name_np(tid: ::pthread_t, name: *mut ::c_char, len: ::size_t); pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); + pub fn pthread_setschedparam( + native: ::pthread_t, + policy: ::c_int, + param: *const sched_param, + ) -> ::c_int; + pub fn pthread_getschedparam( + native: ::pthread_t, + policy: *mut ::c_int, + param: *mut sched_param, + ) -> ::c_int; pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_char, data: ::c_int) -> ::c_int; pub fn utrace(addr: *const ::c_void, len: ::size_t) -> ::c_int; pub fn pututxline(ut: *const utmpx) -> *mut utmpx; @@ -1601,6 +1622,7 @@ -> ::ssize_t; pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; pub fn rtprio(function: ::c_int, pid: ::pid_t, rtp: *mut rtprio) -> ::c_int; + pub fn sched_rr_get_interval(pid: ::pid_t, t: *mut ::timespec) -> ::c_int; pub fn sched_getparam(pid: ::pid_t, param: *mut sched_param) -> ::c_int; pub fn sched_setparam(pid: ::pid_t, param: *const sched_param) -> ::c_int; pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; diff -Nru cargo-0.58.0/vendor/libc/src/unix/bsd/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/bsd/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -37,6 +37,7 @@ #[cfg(not(any(target_os = "macos", target_os = "ios", + target_os = "watchos", target_os = "netbsd", target_os = "openbsd")))] pub pw_fields: ::c_int, @@ -867,10 +868,20 @@ pub fn arc4random() -> u32; pub fn arc4random_buf(buf: *mut ::c_void, size: ::size_t); pub fn arc4random_uniform(l: u32) -> u32; + + pub fn drand48() -> ::c_double; + pub fn erand48(xseed: *mut ::c_ushort) -> ::c_double; + pub fn lrand48() -> ::c_long; + pub fn nrand48(xseed: *mut ::c_ushort) -> ::c_long; + pub fn mrand48() -> ::c_long; + pub fn jrand48(xseed: *mut ::c_ushort) -> ::c_long; + pub fn srand48(seed: ::c_long); + pub fn seed48(xseed: *mut ::c_ushort) -> *mut ::c_ushort; + pub fn lcong48(p: *mut ::c_ushort); } cfg_if! { - if #[cfg(any(target_os = "macos", target_os = "ios"))] { + if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))] { mod apple; pub use self::apple::*; } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] { diff -Nru cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/netbsdlike/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/netbsdlike/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -31,6 +31,10 @@ } s! { + pub struct sched_param { + pub sched_priority: ::c_int, + } + pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, @@ -724,6 +728,16 @@ pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> ::c_int; pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> ::c_int; pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> ::c_int; + pub fn pthread_setschedparam( + native: ::pthread_t, + policy: ::c_int, + param: *const sched_param, + ) -> ::c_int; + pub fn pthread_getschedparam( + native: ::pthread_t, + policy: *mut ::c_int, + param: *mut sched_param, + ) -> ::c_int; pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; pub fn getgrouplist( diff -Nru cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -487,10 +487,6 @@ af_arg: [[::c_char; 10]; 24], } - pub struct sched_param { - pub sched_priority: ::c_int, - } - pub struct kinfo_vmentry { pub kve_start: u64, pub kve_end: u64, @@ -527,7 +523,7 @@ pub struct posix_spawnattr_t { pub sa_flags: ::c_short, pub sa_pgroup: ::pid_t, - pub sa_schedparam: sched_param, + pub sa_schedparam: ::sched_param, pub sa_schedpolicy: ::c_int, pub sa_sigdefault: sigset_t, pub sa_sigmask: sigset_t, @@ -575,6 +571,16 @@ pub descr_len: u32, pub descr_str: [::c_char; 1], } + + pub struct ifreq { + pub _priv: [[::c_char; 6]; 24], + } + + pub struct ifconf { + pub ifc_len: ::c_int, + #[cfg(libc_union)] + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } } s_no_extra_traits! { @@ -693,6 +699,12 @@ pub open: __c_anonymous_posix_spawn_fae_open, pub dup2: __c_anonymous_posix_spawn_fae_dup2, } + + #[cfg(libc_union)] + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut ::c_void, + pub ifcu_req: *mut ifreq, + } } cfg_if! { @@ -1155,6 +1167,41 @@ } } } + + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifc_ifcu {} + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifc_ifcu { + fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { + unsafe { + self.ifcu_buf == other.ifcu_buf + || self.ifcu_req == other.ifcu_req + } + } + } + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifc_ifcu { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + unsafe { + f.debug_struct("__c_anonymous_ifc_ifcu") + .field("ifcu_buf", &self.ifcu_buf) + .field("ifcu_req", &self.ifcu_req) + .finish() + } + } + } + + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifc_ifcu { + fn hash(&self, state: &mut H) { + unsafe { + self.ifcu_buf.hash(state); + self.ifcu_req.hash(state); + } + } + } } } @@ -2464,8 +2511,9 @@ flags: ::c_int, ) -> *mut ::c_void; - pub fn sched_setparam(pid: ::pid_t, param: *const sched_param) -> ::c_int; - pub fn sched_getparam(pid: ::pid_t, param: *mut sched_param) -> ::c_int; + pub fn sched_rr_get_interval(pid: ::pid_t, t: *mut ::timespec) -> ::c_int; + pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int; + pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int; pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; pub fn sched_setscheduler( pid: ::pid_t, diff -Nru cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -35,6 +35,11 @@ pub type Elf64_Word = u32; pub type Elf64_Xword = u64; +// search.h + +pub type ENTRY = entry; +pub type ACTION = ::c_uint; + cfg_if! { if #[cfg(target_pointer_width = "64")] { type Elf_Addr = Elf64_Addr; @@ -48,6 +53,12 @@ } s! { + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: ::c_int, + } + pub struct glob_t { pub gl_pathc: ::size_t, pub gl_matchc: ::size_t, @@ -417,6 +428,12 @@ pub struct ptrace_thread_state { pub pts_tid: ::pid_t, } + + // search.h + pub struct entry { + pub key: *mut ::c_char, + pub data: *mut ::c_void, + } } impl siginfo_t { @@ -1148,6 +1165,10 @@ pub const FD_SETSIZE: usize = 1024; +pub const SCHED_FIFO: ::c_int = 1; +pub const SCHED_OTHER: ::c_int = 2; +pub const SCHED_RR: ::c_int = 3; + pub const ST_NOSUID: ::c_ulong = 2; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; @@ -1355,6 +1376,35 @@ pub const KI_MAXLOGNAME: ::c_int = 32; pub const KI_EMULNAMELEN: ::c_int = 8; +pub const KVE_ET_OBJ: ::c_int = 0x00000001; +pub const KVE_ET_SUBMAP: ::c_int = 0x00000002; +pub const KVE_ET_COPYONWRITE: ::c_int = 0x00000004; +pub const KVE_ET_NEEDSCOPY: ::c_int = 0x00000008; +pub const KVE_ET_HOLE: ::c_int = 0x00000010; +pub const KVE_ET_NOFAULT: ::c_int = 0x00000020; +pub const KVE_ET_STACK: ::c_int = 0x00000040; +pub const KVE_ET_WC: ::c_int = 0x000000080; +pub const KVE_ET_CONCEAL: ::c_int = 0x000000100; +pub const KVE_ET_SYSCALL: ::c_int = 0x000000200; +pub const KVE_ET_FREEMAPPED: ::c_int = 0x000000800; + +pub const KVE_PROT_NONE: ::c_int = 0x00000000; +pub const KVE_PROT_READ: ::c_int = 0x00000001; +pub const KVE_PROT_WRITE: ::c_int = 0x00000002; +pub const KVE_PROT_EXEC: ::c_int = 0x00000004; + +pub const KVE_ADV_NORMAL: ::c_int = 0x00000000; +pub const KVE_ADV_RANDOM: ::c_int = 0x00000001; +pub const KVE_ADV_SEQUENTIAL: ::c_int = 0x00000002; + +pub const KVE_INH_SHARE: ::c_int = 0x00000000; +pub const KVE_INH_COPY: ::c_int = 0x00000010; +pub const KVE_INH_NONE: ::c_int = 0x00000020; +pub const KVE_INH_ZERO: ::c_int = 0x00000030; + +pub const KVE_F_STATIC: ::c_int = 0x1; +pub const KVE_F_KMEM: ::c_int = 0x2; + pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS; pub const OLCUC: ::tcflag_t = 0x20; pub const ONOCR: ::tcflag_t = 0x40; @@ -1465,6 +1515,10 @@ pub const WCONTINUED: ::c_int = 8; +// search.h +pub const FIND: ::ACTION = 0; +pub const ENTER: ::ACTION = 1; + const_fn! { {const} fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES @@ -1627,6 +1681,28 @@ pub fn freezero(ptr: *mut ::c_void, size: ::size_t); pub fn malloc_conceal(size: ::size_t) -> *mut ::c_void; pub fn calloc_conceal(nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; + + pub fn srand48_deterministic(seed: ::c_long); + pub fn seed48_deterministic(xseed: *mut ::c_ushort) -> *mut ::c_ushort; + pub fn lcong48_deterministic(p: *mut ::c_ushort); + + pub fn lsearch( + key: *const ::c_void, + base: *mut ::c_void, + nelp: *mut ::size_t, + width: ::size_t, + compar: ::Option ::c_int>, + ) -> *mut ::c_void; + pub fn lfind( + key: *const ::c_void, + base: *const ::c_void, + nelp: *mut ::size_t, + width: ::size_t, + compar: ::Option ::c_int>, + ) -> *mut ::c_void; + pub fn hcreate(nelt: ::size_t) -> ::c_int; + pub fn hdestroy(); + pub fn hsearch(entry: ::ENTRY, action: ::ACTION) -> *mut ::ENTRY; } #[link(name = "execinfo")] diff -Nru cargo-0.58.0/vendor/libc/src/unix/haiku/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/haiku/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/haiku/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/haiku/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -33,14 +33,12 @@ pub type Elf32_Addr = u32; pub type Elf32_Half = u16; -pub type Elf32_Lword = u64; pub type Elf32_Off = u32; pub type Elf32_Sword = i32; pub type Elf32_Word = u32; pub type Elf64_Addr = u64; pub type Elf64_Half = u16; -pub type Elf64_Lword = u64; pub type Elf64_Off = u64; pub type Elf64_Sword = i32; pub type Elf64_Sxword = i64; @@ -120,12 +118,12 @@ pub struct ifaddrs { pub ifa_next: *mut ifaddrs, - pub ifa_name: *mut ::c_char, + pub ifa_name: *const ::c_char, pub ifa_flags: ::c_uint, pub ifa_addr: *mut ::sockaddr, pub ifa_netmask: *mut ::sockaddr, pub ifa_dstaddr: *mut ::sockaddr, - pub ida_data: *mut ::c_void, + pub ifa_data: *mut ::c_void, } pub struct fd_set { @@ -287,6 +285,10 @@ waiters: [*mut ::c_void; 2], } + pub struct pthread_spinlock_t { + lock: u32, + } + pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, @@ -370,6 +372,18 @@ pub dlpi_tls_modid: usize, pub dlpi_tls_data: *mut ::c_void, } + + pub struct spwd { + pub sp_namp: *mut ::c_char, + pub sp_pwdp: *mut ::c_char, + pub sp_lstchg: ::c_int, + pub sp_min: ::c_int, + pub sp_max: ::c_int, + pub sp_warn: ::c_int, + pub sp_inact: ::c_int, + pub sp_expire: ::c_int, + pub sp_flag: ::c_int, + } } s_no_extra_traits! { @@ -1510,6 +1524,46 @@ pub fn srand(seed: ::c_uint); pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; pub fn freeifaddrs(ifa: *mut ::ifaddrs); + pub fn ppoll( + fds: *mut ::pollfd, + numfds: ::nfds_t, + timeout: *const ::timespec, + sigMask: *const sigset_t, + ) -> ::c_int; + + pub fn getspent() -> *mut spwd; + pub fn getspent_r( + pwd: *mut spwd, + buf: *mut ::c_char, + bufferSize: ::size_t, + res: *mut *mut spwd, + ) -> ::c_int; + pub fn setspent(); + pub fn endspent(); + pub fn getspnam(name: *const ::c_char) -> *mut spwd; + pub fn getspnam_r( + name: *const ::c_char, + spwd: *mut spwd, + buffer: *mut ::c_char, + bufferSize: ::size_t, + res: *mut *mut spwd, + ) -> ::c_int; + pub fn sgetspent(line: *const ::c_char) -> *mut spwd; + pub fn sgetspent_r( + line: *const ::c_char, + spwd: *mut spwd, + buffer: *mut ::c_char, + bufferSize: ::size_t, + res: *mut *mut spwd, + ) -> ::c_int; + pub fn fgetspent(file: *mut ::FILE) -> *mut spwd; + pub fn fgetspent_r( + file: *mut ::FILE, + spwd: *mut spwd, + buffer: *mut ::c_char, + bufferSize: ::size_t, + res: *mut *mut spwd, + ) -> ::c_int; } #[link(name = "bsd")] @@ -1562,6 +1616,11 @@ lock: *mut pthread_mutex_t, abstime: *const ::timespec, ) -> ::c_int; + pub fn pthread_spin_init(lock: *mut ::pthread_spinlock_t, pshared: ::c_int) -> ::c_int; + pub fn pthread_spin_destroy(lock: *mut ::pthread_spinlock_t) -> ::c_int; + pub fn pthread_spin_lock(lock: *mut ::pthread_spinlock_t) -> ::c_int; + pub fn pthread_spin_trylock(lock: *mut ::pthread_spinlock_t) -> ::c_int; + pub fn pthread_spin_unlock(lock: *mut ::pthread_spinlock_t) -> ::c_int; pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; @@ -1700,6 +1759,14 @@ pub fn login_tty(_fd: ::c_int) -> ::c_int; pub fn fgetln(stream: *mut ::FILE, _length: *mut ::size_t) -> *mut ::c_char; + + pub fn realhostname(host: *mut ::c_char, hsize: ::size_t, ip: *const in_addr) -> ::c_int; + pub fn realhostname_sa( + host: *mut ::c_char, + hsize: ::size_t, + addr: *mut sockaddr, + addrlen: ::c_int, + ) -> ::c_int; } cfg_if! { diff -Nru cargo-0.58.0/vendor/libc/src/unix/haiku/native.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/haiku/native.rs --- cargo-0.58.0/vendor/libc/src/unix/haiku/native.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/haiku/native.rs 2022-04-20 13:48:09.000000000 +0000 @@ -114,6 +114,89 @@ B_FIND_PATH_IMAGE_PATH = 1000, B_FIND_PATH_PACKAGE_PATH, } + + pub enum directory_which { + B_DESKTOP_DIRECTORY = 0, + B_TRASH_DIRECTORY, + B_SYSTEM_DIRECTORY = 1000, + B_SYSTEM_ADDONS_DIRECTORY = 1002, + B_SYSTEM_BOOT_DIRECTORY, + B_SYSTEM_FONTS_DIRECTORY, + B_SYSTEM_LIB_DIRECTORY, + B_SYSTEM_SERVERS_DIRECTORY, + B_SYSTEM_APPS_DIRECTORY, + B_SYSTEM_BIN_DIRECTORY, + B_SYSTEM_DOCUMENTATION_DIRECTORY = 1010, + B_SYSTEM_PREFERENCES_DIRECTORY, + B_SYSTEM_TRANSLATORS_DIRECTORY, + B_SYSTEM_MEDIA_NODES_DIRECTORY, + B_SYSTEM_SOUNDS_DIRECTORY, + B_SYSTEM_DATA_DIRECTORY, + B_SYSTEM_DEVELOP_DIRECTORY, + B_SYSTEM_PACKAGES_DIRECTORY, + B_SYSTEM_HEADERS_DIRECTORY, + B_SYSTEM_ETC_DIRECTORY = 2008, + B_SYSTEM_SETTINGS_DIRECTORY = 2010, + B_SYSTEM_LOG_DIRECTORY = 2012, + B_SYSTEM_SPOOL_DIRECTORY, + B_SYSTEM_TEMP_DIRECTORY, + B_SYSTEM_VAR_DIRECTORY, + B_SYSTEM_CACHE_DIRECTORY = 2020, + B_SYSTEM_NONPACKAGED_DIRECTORY = 2023, + B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY, + B_SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY, + B_SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY, + B_SYSTEM_NONPACKAGED_BIN_DIRECTORY, + B_SYSTEM_NONPACKAGED_DATA_DIRECTORY, + B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY, + B_SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY, + B_SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY, + B_SYSTEM_NONPACKAGED_LIB_DIRECTORY, + B_SYSTEM_NONPACKAGED_HEADERS_DIRECTORY, + B_SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY, + B_USER_DIRECTORY = 3000, + B_USER_CONFIG_DIRECTORY, + B_USER_ADDONS_DIRECTORY, + B_USER_BOOT_DIRECTORY, + B_USER_FONTS_DIRECTORY, + B_USER_LIB_DIRECTORY, + B_USER_SETTINGS_DIRECTORY, + B_USER_DESKBAR_DIRECTORY, + B_USER_PRINTERS_DIRECTORY, + B_USER_TRANSLATORS_DIRECTORY, + B_USER_MEDIA_NODES_DIRECTORY, + B_USER_SOUNDS_DIRECTORY, + B_USER_DATA_DIRECTORY, + B_USER_CACHE_DIRECTORY, + B_USER_PACKAGES_DIRECTORY, + B_USER_HEADERS_DIRECTORY, + B_USER_NONPACKAGED_DIRECTORY, + B_USER_NONPACKAGED_ADDONS_DIRECTORY, + B_USER_NONPACKAGED_TRANSLATORS_DIRECTORY, + B_USER_NONPACKAGED_MEDIA_NODES_DIRECTORY, + B_USER_NONPACKAGED_BIN_DIRECTORY, + B_USER_NONPACKAGED_DATA_DIRECTORY, + B_USER_NONPACKAGED_FONTS_DIRECTORY, + B_USER_NONPACKAGED_SOUNDS_DIRECTORY, + B_USER_NONPACKAGED_DOCUMENTATION_DIRECTORY, + B_USER_NONPACKAGED_LIB_DIRECTORY, + B_USER_NONPACKAGED_HEADERS_DIRECTORY, + B_USER_NONPACKAGED_DEVELOP_DIRECTORY, + B_USER_DEVELOP_DIRECTORY, + B_USER_DOCUMENTATION_DIRECTORY, + B_USER_SERVERS_DIRECTORY, + B_USER_APPS_DIRECTORY, + B_USER_BIN_DIRECTORY, + B_USER_PREFERENCES_DIRECTORY, + B_USER_ETC_DIRECTORY, + B_USER_LOG_DIRECTORY, + B_USER_SPOOL_DIRECTORY, + B_USER_VAR_DIRECTORY, + B_APPS_DIRECTORY = 4000, + B_PREFERENCES_DIRECTORY, + B_UTILITIES_DIRECTORY, + B_PACKAGE_LINKS_DIRECTORY, + } } s! { @@ -879,7 +962,7 @@ pub fn rename_thread(thread: thread_id, newName: *const ::c_char) -> status_t; pub fn set_thread_priority(thread: thread_id, newPriority: i32) -> status_t; pub fn suggest_thread_priority( - task_flags: be_task_flags, + what: u32, period: i32, jitter: ::bigtime_t, length: ::bigtime_t, @@ -936,8 +1019,6 @@ pub fn debugger(message: *const ::c_char); pub fn disable_debugger(state: ::c_int) -> ::c_int; - pub fn get_cpuid(info: *mut cpuid_info, eaxRegister: u32, cpuNum: u32) -> status_t; - pub fn get_system_info(info: *mut system_info) -> status_t; pub fn get_cpu_info(firstCPU: u32, cpuCount: u32, info: *mut cpu_info) -> status_t; pub fn is_computer_on() -> i32; @@ -1082,6 +1163,61 @@ pathBuffer: *mut ::c_char, bufferSize: usize, ) -> status_t; + pub fn find_path_etc( + codePointer: *const ::c_void, + dependency: *const ::c_char, + architecture: *const ::c_char, + baseDirectory: path_base_directory, + subPath: *const ::c_char, + flags: u32, + pathBuffer: *mut ::c_char, + bufferSize: ::size_t, + ) -> status_t; + pub fn find_path_for_path( + path: *const ::c_char, + baseDirectory: path_base_directory, + subPath: *const ::c_char, + pathBuffer: *mut ::c_char, + bufferSize: ::size_t, + ) -> status_t; + pub fn find_path_for_path_etc( + path: *const ::c_char, + dependency: *const ::c_char, + architectur: *const ::c_char, + baseDirectory: path_base_directory, + subPath: *const ::c_char, + flags: u32, + pathBuffer: *mut ::c_char, + bufferSize: ::size_t, + ) -> status_t; + pub fn find_paths( + baseDirectory: path_base_directory, + subPath: *const ::c_char, + _paths: *mut *mut *mut ::c_char, + pathCount: *mut ::size_t, + ) -> status_t; + pub fn find_paths_etc( + architecture: *const ::c_char, + baseDirectory: path_base_directory, + subPath: *const ::c_char, + _paths: *mut *mut *mut ::c_char, + pathCount: *mut ::size_t, + ) -> status_t; + pub fn find_directory( + which: directory_which, + volume: ::dev_t, + createIt: bool, + pathString: *mut ::c_char, + length: i32, + ) -> status_t; +} + +cfg_if! { + if #[cfg(libc_union)] { + extern "C" { + pub fn get_cpuid(info: *mut cpuid_info, eaxRegister: u32, cpuNum: u32) -> status_t; + } + } } // The following functions are defined as macros in C/C++ diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/android/b64/aarch64/int128.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/android/b64/aarch64/int128.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/android/b64/aarch64/int128.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/android/b64/aarch64/int128.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,7 @@ +s! { + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: u32, + pub fpcr: u32, + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -382,3 +382,10 @@ pub use self::align::*; } } + +cfg_if! { + if #[cfg(libc_int128)] { + mod int128; + pub use self::int128::*; + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/android/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/android/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/android/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/android/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -73,12 +73,6 @@ pub cmsg_type: ::c_int, } - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } - pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, @@ -998,6 +992,12 @@ pub const F_TLOCK: ::c_int = 2; pub const F_ULOCK: ::c_int = 0; +pub const F_SEAL_FUTURE_WRITE: ::c_int = 0x0010; + +pub const IFF_LOWER_UP: ::c_int = 0x10000; +pub const IFF_DORMANT: ::c_int = 0x20000; +pub const IFF_ECHO: ::c_int = 0x40000; + pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; @@ -1269,33 +1269,6 @@ pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0o200000; -pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; -pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; -pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; -pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; -pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; -pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; -pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; -pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; -pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; -pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; -pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; -pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; -pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; -pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; -pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; -pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; -pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; -pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; -pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; -pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; -pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; -pub const TMPFS_MAGIC: ::c_long = 0x01021994; -pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; - pub const MAP_HUGETLB: ::c_int = 0x040000; pub const PTRACE_TRACEME: ::c_int = 0; @@ -1554,6 +1527,8 @@ pub const B4000000: ::speed_t = 0o010017; pub const IBSHIFT: ::tcflag_t = 16; +pub const BLKIOMIN: ::c_int = 0x1278; +pub const BLKIOOPT: ::c_int = 0x1279; pub const BLKSSZGET: ::c_int = 0x1268; pub const BLKPBSZGET: ::c_int = 0x127B; @@ -1893,6 +1868,20 @@ pub const MFD_CLOEXEC: ::c_uint = 0x0001; pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002; pub const MFD_HUGETLB: ::c_uint = 0x0004; +pub const MFD_HUGE_64KB: ::c_uint = 0x40000000; +pub const MFD_HUGE_512KB: ::c_uint = 0x4c000000; +pub const MFD_HUGE_1MB: ::c_uint = 0x50000000; +pub const MFD_HUGE_2MB: ::c_uint = 0x54000000; +pub const MFD_HUGE_8MB: ::c_uint = 0x5c000000; +pub const MFD_HUGE_16MB: ::c_uint = 0x60000000; +pub const MFD_HUGE_32MB: ::c_uint = 0x64000000; +pub const MFD_HUGE_256MB: ::c_uint = 0x70000000; +pub const MFD_HUGE_512MB: ::c_uint = 0x74000000; +pub const MFD_HUGE_1GB: ::c_uint = 0x78000000; +pub const MFD_HUGE_2GB: ::c_uint = 0x7c000000; +pub const MFD_HUGE_16GB: ::c_uint = 0x88000000; +pub const MFD_HUGE_MASK: ::c_uint = 63; +pub const MFD_HUGE_SHIFT: ::c_uint = 26; // these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has // the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32 @@ -2477,6 +2466,16 @@ pub const CLONE_PIDFD: ::c_int = 0x1000; +// linux/mempolicy.h +pub const MPOL_DEFAULT: ::c_int = 0; +pub const MPOL_PREFERRED: ::c_int = 1; +pub const MPOL_BIND: ::c_int = 2; +pub const MPOL_INTERLEAVE: ::c_int = 3; +pub const MPOL_LOCAL: ::c_int = 4; +pub const MPOL_F_NUMA_BALANCING: ::c_int = 1 << 13; +pub const MPOL_F_RELATIVE_NODES: ::c_int = 1 << 14; +pub const MPOL_F_STATIC_NODES: ::c_int = 1 << 15; + // bits/seek_constants.h pub const SEEK_DATA: ::c_int = 3; pub const SEEK_HOLE: ::c_int = 4; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/align.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/align.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/align.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/align.rs 2022-04-20 13:48:09.000000000 +0000 @@ -76,6 +76,7 @@ any(target_arch = "mips", target_arch = "arm", target_arch = "hexagon", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", target_arch = "x86_64", @@ -85,6 +86,7 @@ not(any(target_arch = "mips", target_arch = "arm", target_arch = "hexagon", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", target_arch = "x86_64", @@ -99,6 +101,7 @@ any(target_arch = "mips", target_arch = "arm", target_arch = "hexagon", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", target_arch = "x86_64", @@ -108,6 +111,7 @@ not(any(target_arch = "mips", target_arch = "arm", target_arch = "hexagon", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", target_arch = "x86_64", diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -114,103 +114,92 @@ // Ioctl Constants -cfg_if! { - if #[cfg(not(any(target_arch = "mips", - target_arch = "mips64", - target_arch = "powerpc", - target_arch = "powerpc64", - target_arch = "sparc", - target_arch = "sparc64")))] { - - pub const TCGETS: ::Ioctl = 0x5401; - pub const TCSETS: ::Ioctl = 0x5402; - pub const TCSETSW: ::Ioctl = 0x5403; - pub const TCSETSF: ::Ioctl = 0x5404; - pub const TCGETA: ::Ioctl = 0x5405; - pub const TCSETA: ::Ioctl = 0x5406; - pub const TCSETAW: ::Ioctl = 0x5407; - pub const TCSETAF: ::Ioctl = 0x5408; - pub const TCSBRK: ::Ioctl = 0x5409; - pub const TCXONC: ::Ioctl = 0x540A; - pub const TCFLSH: ::Ioctl = 0x540B; - pub const TIOCEXCL: ::Ioctl = 0x540C; - pub const TIOCNXCL: ::Ioctl = 0x540D; - pub const TIOCSCTTY: ::Ioctl = 0x540E; - pub const TIOCGPGRP: ::Ioctl = 0x540F; - pub const TIOCSPGRP: ::Ioctl = 0x5410; - pub const TIOCOUTQ: ::Ioctl = 0x5411; - pub const TIOCSTI: ::Ioctl = 0x5412; - pub const TIOCGWINSZ: ::Ioctl = 0x5413; - pub const TIOCSWINSZ: ::Ioctl = 0x5414; - pub const TIOCMGET: ::Ioctl = 0x5415; - pub const TIOCMBIS: ::Ioctl = 0x5416; - pub const TIOCMBIC: ::Ioctl = 0x5417; - pub const TIOCMSET: ::Ioctl = 0x5418; - pub const TIOCGSOFTCAR: ::Ioctl = 0x5419; - pub const TIOCSSOFTCAR: ::Ioctl = 0x541A; - pub const FIONREAD: ::Ioctl = 0x541B; - pub const TIOCINQ: ::Ioctl = FIONREAD; - pub const TIOCLINUX: ::Ioctl = 0x541C; - pub const TIOCCONS: ::Ioctl = 0x541D; - pub const TIOCGSERIAL: ::Ioctl = 0x541E; - pub const TIOCSSERIAL: ::Ioctl = 0x541F; - pub const TIOCPKT: ::Ioctl = 0x5420; - pub const FIONBIO: ::Ioctl = 0x5421; - pub const TIOCNOTTY: ::Ioctl = 0x5422; - pub const TIOCSETD: ::Ioctl = 0x5423; - pub const TIOCGETD: ::Ioctl = 0x5424; - pub const TCSBRKP: ::Ioctl = 0x5425; - pub const TIOCSBRK: ::Ioctl = 0x5427; - pub const TIOCCBRK: ::Ioctl = 0x5428; - pub const TIOCGSID: ::Ioctl = 0x5429; - pub const TCGETS2: ::Ioctl = 0x802c542a; - pub const TCSETS2: ::Ioctl = 0x402c542b; - pub const TCSETSW2: ::Ioctl = 0x402c542c; - pub const TCSETSF2: ::Ioctl = 0x402c542d; - pub const TIOCGRS485: ::Ioctl = 0x542E; - pub const TIOCSRS485: ::Ioctl = 0x542F; - pub const TIOCGPTN: ::Ioctl = 0x80045430; - pub const TIOCSPTLCK: ::Ioctl = 0x40045431; - pub const TIOCGDEV: ::Ioctl = 0x80045432; - pub const TCGETX: ::Ioctl = 0x5432; - pub const TCSETX: ::Ioctl = 0x5433; - pub const TCSETXF: ::Ioctl = 0x5434; - pub const TCSETXW: ::Ioctl = 0x5435; - pub const TIOCSIG: ::Ioctl = 0x40045436; - pub const TIOCVHANGUP: ::Ioctl = 0x5437; - pub const TIOCGPKT: ::Ioctl = 0x80045438; - pub const TIOCGPTLCK: ::Ioctl = 0x80045439; - pub const TIOCGEXCL: ::Ioctl = 0x80045440; - pub const TIOCGPTPEER: ::Ioctl = 0x5441; -// pub const TIOCGISO7816: ::Ioctl = 0x80285442; -// pub const TIOCSISO7816: ::Ioctl = 0xc0285443; - pub const FIONCLEX: ::Ioctl = 0x5450; - pub const FIOCLEX: ::Ioctl = 0x5451; - pub const FIOASYNC: ::Ioctl = 0x5452; - pub const TIOCSERCONFIG: ::Ioctl = 0x5453; - pub const TIOCSERGWILD: ::Ioctl = 0x5454; - pub const TIOCSERSWILD: ::Ioctl = 0x5455; - pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456; - pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457; - pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458; - pub const TIOCSERGETLSR: ::Ioctl = 0x5459; - pub const TIOCSERGETMULTI: ::Ioctl = 0x545A; - pub const TIOCSERSETMULTI: ::Ioctl = 0x545B; - pub const TIOCMIWAIT: ::Ioctl = 0x545C; - pub const TIOCGICOUNT: ::Ioctl = 0x545D; - } -} +pub const TCGETS: ::Ioctl = 0x5401; +pub const TCSETS: ::Ioctl = 0x5402; +pub const TCSETSW: ::Ioctl = 0x5403; +pub const TCSETSF: ::Ioctl = 0x5404; +pub const TCGETA: ::Ioctl = 0x5405; +pub const TCSETA: ::Ioctl = 0x5406; +pub const TCSETAW: ::Ioctl = 0x5407; +pub const TCSETAF: ::Ioctl = 0x5408; +pub const TCSBRK: ::Ioctl = 0x5409; +pub const TCXONC: ::Ioctl = 0x540A; +pub const TCFLSH: ::Ioctl = 0x540B; +pub const TIOCEXCL: ::Ioctl = 0x540C; +pub const TIOCNXCL: ::Ioctl = 0x540D; +pub const TIOCSCTTY: ::Ioctl = 0x540E; +pub const TIOCGPGRP: ::Ioctl = 0x540F; +pub const TIOCSPGRP: ::Ioctl = 0x5410; +pub const TIOCOUTQ: ::Ioctl = 0x5411; +pub const TIOCSTI: ::Ioctl = 0x5412; +pub const TIOCGWINSZ: ::Ioctl = 0x5413; +pub const TIOCSWINSZ: ::Ioctl = 0x5414; +pub const TIOCMGET: ::Ioctl = 0x5415; +pub const TIOCMBIS: ::Ioctl = 0x5416; +pub const TIOCMBIC: ::Ioctl = 0x5417; +pub const TIOCMSET: ::Ioctl = 0x5418; +pub const TIOCGSOFTCAR: ::Ioctl = 0x5419; +pub const TIOCSSOFTCAR: ::Ioctl = 0x541A; +pub const FIONREAD: ::Ioctl = 0x541B; +pub const TIOCINQ: ::Ioctl = FIONREAD; +pub const TIOCLINUX: ::Ioctl = 0x541C; +pub const TIOCCONS: ::Ioctl = 0x541D; +pub const TIOCGSERIAL: ::Ioctl = 0x541E; +pub const TIOCSSERIAL: ::Ioctl = 0x541F; +pub const TIOCPKT: ::Ioctl = 0x5420; +pub const FIONBIO: ::Ioctl = 0x5421; +pub const TIOCNOTTY: ::Ioctl = 0x5422; +pub const TIOCSETD: ::Ioctl = 0x5423; +pub const TIOCGETD: ::Ioctl = 0x5424; +pub const TCSBRKP: ::Ioctl = 0x5425; +pub const TIOCSBRK: ::Ioctl = 0x5427; +pub const TIOCCBRK: ::Ioctl = 0x5428; +pub const TIOCGSID: ::Ioctl = 0x5429; +pub const TCGETS2: ::Ioctl = 0x802c542a; +pub const TCSETS2: ::Ioctl = 0x402c542b; +pub const TCSETSW2: ::Ioctl = 0x402c542c; +pub const TCSETSF2: ::Ioctl = 0x402c542d; +pub const TIOCGRS485: ::Ioctl = 0x542E; +pub const TIOCSRS485: ::Ioctl = 0x542F; +pub const TIOCGPTN: ::Ioctl = 0x80045430; +pub const TIOCSPTLCK: ::Ioctl = 0x40045431; +pub const TIOCGDEV: ::Ioctl = 0x80045432; +pub const TCGETX: ::Ioctl = 0x5432; +pub const TCSETX: ::Ioctl = 0x5433; +pub const TCSETXF: ::Ioctl = 0x5434; +pub const TCSETXW: ::Ioctl = 0x5435; +pub const TIOCSIG: ::Ioctl = 0x40045436; +pub const TIOCVHANGUP: ::Ioctl = 0x5437; +pub const TIOCGPKT: ::Ioctl = 0x80045438; +pub const TIOCGPTLCK: ::Ioctl = 0x80045439; +pub const TIOCGEXCL: ::Ioctl = 0x80045440; +pub const TIOCGPTPEER: ::Ioctl = 0x5441; +// pub const TIOCGISO7816: ::Ioctl = 0x80285442; +// pub const TIOCSISO7816: ::Ioctl = 0xc0285443; +pub const FIONCLEX: ::Ioctl = 0x5450; +pub const FIOCLEX: ::Ioctl = 0x5451; +pub const FIOASYNC: ::Ioctl = 0x5452; +pub const TIOCSERCONFIG: ::Ioctl = 0x5453; +pub const TIOCSERGWILD: ::Ioctl = 0x5454; +pub const TIOCSERSWILD: ::Ioctl = 0x5455; +pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456; +pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457; +pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458; +pub const TIOCSERGETLSR: ::Ioctl = 0x5459; +pub const TIOCSERGETMULTI: ::Ioctl = 0x545A; +pub const TIOCSERSETMULTI: ::Ioctl = 0x545B; +pub const TIOCMIWAIT: ::Ioctl = 0x545C; +pub const TIOCGICOUNT: ::Ioctl = 0x545D; +pub const BLKIOMIN: ::Ioctl = 0x1278; +pub const BLKIOOPT: ::Ioctl = 0x1279; +pub const BLKSSZGET: ::Ioctl = 0x1268; +pub const BLKPBSZGET: ::Ioctl = 0x127B; cfg_if! { if #[cfg(any(target_arch = "arm", target_arch = "s390x"))] { pub const FIOQSIZE: ::Ioctl = 0x545E; - } else if #[cfg(not(any(target_arch = "mips", - target_arch = "mips64", - target_arch = "powerpc", - target_arch = "powerpc64", - target_arch = "sparc", - target_arch = "sparc64")))] { + } else { pub const FIOQSIZE: ::Ioctl = 0x5460; } } @@ -230,5 +219,60 @@ pub const BOTHER: ::speed_t = 0o010000; pub const IBSHIFT: ::tcflag_t = 16; -pub const BLKSSZGET: ::c_int = 0x1268; -pub const BLKPBSZGET: ::c_int = 0x127B; +// RLIMIT Constants + +cfg_if! { + if #[cfg(any(target_env = "gnu", + target_env = "uclibc"))] { + + pub const RLIMIT_CPU: ::__rlimit_resource_t = 0; + pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1; + pub const RLIMIT_DATA: ::__rlimit_resource_t = 2; + pub const RLIMIT_STACK: ::__rlimit_resource_t = 3; + pub const RLIMIT_CORE: ::__rlimit_resource_t = 4; + pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; + pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; + pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; + pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; + pub const RLIMIT_AS: ::__rlimit_resource_t = 9; + pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10; + pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11; + pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12; + pub const RLIMIT_NICE: ::__rlimit_resource_t = 13; + pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14; + pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15; + pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS; + + } else if #[cfg(target_env = "musl")] { + + pub const RLIMIT_CPU: ::c_int = 0; + pub const RLIMIT_FSIZE: ::c_int = 1; + pub const RLIMIT_DATA: ::c_int = 2; + pub const RLIMIT_STACK: ::c_int = 3; + pub const RLIMIT_CORE: ::c_int = 4; + pub const RLIMIT_RSS: ::c_int = 5; + pub const RLIMIT_NPROC: ::c_int = 6; + pub const RLIMIT_NOFILE: ::c_int = 7; + pub const RLIMIT_MEMLOCK: ::c_int = 8; + pub const RLIMIT_AS: ::c_int = 9; + pub const RLIMIT_LOCKS: ::c_int = 10; + pub const RLIMIT_SIGPENDING: ::c_int = 11; + pub const RLIMIT_MSGQUEUE: ::c_int = 12; + pub const RLIMIT_NICE: ::c_int = 13; + pub const RLIMIT_RTPRIO: ::c_int = 14; + pub const RLIMIT_RTTIME: ::c_int = 15; + pub const RLIM_NLIMITS: ::c_int = 15; + pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS; + } +} + +cfg_if! { + if #[cfg(target_env = "gnu")] { + pub const RLIM_NLIMITS: ::__rlimit_resource_t = 16; + } + else if #[cfg(target_env = "uclibc")] { + pub const RLIM_NLIMITS: ::__rlimit_resource_t = 15; + } +} + +pub const RLIM_INFINITY: ::rlim_t = !0; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -185,6 +185,10 @@ pub const TIOCGETP: ::Ioctl = 0x7408; pub const TIOCSETP: ::Ioctl = 0x7409; pub const TIOCSETN: ::Ioctl = 0x740a; +pub const BLKIOMIN: ::Ioctl = 0x20001278; +pub const BLKIOOPT: ::Ioctl = 0x20001279; +pub const BLKSSZGET: ::Ioctl = 0x20001268; +pub const BLKPBSZGET: ::Ioctl = 0x2000127B; cfg_if! { if #[cfg(target_env = "musl")] { @@ -208,5 +212,74 @@ pub const BOTHER: ::speed_t = 0o010000; pub const IBSHIFT: ::tcflag_t = 16; -pub const BLKSSZGET: ::c_int = 0x20001268; -pub const BLKPBSZGET: ::c_int = 0x2000127B; +// RLIMIT Constants + +cfg_if! { + if #[cfg(any(target_env = "gnu", + target_env = "uclibc"))] { + + pub const RLIMIT_CPU: ::__rlimit_resource_t = 0; + pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1; + pub const RLIMIT_DATA: ::__rlimit_resource_t = 2; + pub const RLIMIT_STACK: ::__rlimit_resource_t = 3; + pub const RLIMIT_CORE: ::__rlimit_resource_t = 4; + pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 5; + pub const RLIMIT_AS: ::__rlimit_resource_t = 6; + pub const RLIMIT_RSS: ::__rlimit_resource_t = 7; + pub const RLIMIT_NPROC: ::__rlimit_resource_t = 8; + pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 9; + pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10; + pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11; + pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12; + pub const RLIMIT_NICE: ::__rlimit_resource_t = 13; + pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14; + pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15; + pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS; + + } else if #[cfg(target_env = "musl")] { + + pub const RLIMIT_CPU: ::c_int = 0; + pub const RLIMIT_FSIZE: ::c_int = 1; + pub const RLIMIT_DATA: ::c_int = 2; + pub const RLIMIT_STACK: ::c_int = 3; + pub const RLIMIT_CORE: ::c_int = 4; + pub const RLIMIT_NOFILE: ::c_int = 5; + pub const RLIMIT_AS: ::c_int = 6; + pub const RLIMIT_RSS: ::c_int = 7; + pub const RLIMIT_NPROC: ::c_int = 8; + pub const RLIMIT_MEMLOCK: ::c_int = 9; + pub const RLIMIT_LOCKS: ::c_int = 10; + pub const RLIMIT_SIGPENDING: ::c_int = 11; + pub const RLIMIT_MSGQUEUE: ::c_int = 12; + pub const RLIMIT_NICE: ::c_int = 13; + pub const RLIMIT_RTPRIO: ::c_int = 14; + pub const RLIMIT_RTTIME: ::c_int = 15; + pub const RLIM_NLIMITS: ::c_int = 15; + pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS; + pub const RLIM_INFINITY: ::rlim_t = !0; + } +} + +cfg_if! { + if #[cfg(target_env = "gnu")] { + pub const RLIM_NLIMITS: ::__rlimit_resource_t = 16; + } else if #[cfg(target_env = "uclibc")] { + pub const RLIM_NLIMITS: ::__rlimit_resource_t = 15; + } +} + +cfg_if! { + if #[cfg(target_arch = "mips64", + any(target_env = "gnu", + target_env = "uclibc"))] { + pub const RLIM_INFINITY: ::rlim_t = !0; + } +} + +cfg_if! { + if #[cfg(target_arch = "mips", + any(target_env = "gnu", + target_env = "uclibc"))] { + pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -93,16 +93,16 @@ // Ioctl Constants cfg_if! { - if #[cfg(target_env = "musl")] { - pub const TCGETS: ::Ioctl = 0x402c7413; - pub const TCSETS: ::Ioctl = 0x802c7414; - pub const TCSETSW: ::Ioctl = 0x802c7415; - pub const TCSETSF: ::Ioctl = 0x802c7416; - } else { + if #[cfg(target_env = "gnu")] { pub const TCGETS: ::Ioctl = 0x403c7413; pub const TCSETS: ::Ioctl = 0x803c7414; pub const TCSETSW: ::Ioctl = 0x803c7415; pub const TCSETSF: ::Ioctl = 0x803c7416; + } else if #[cfg(target_env = "musl")] { + pub const TCGETS: ::Ioctl = 0x402c7413; + pub const TCSETS: ::Ioctl = 0x802c7414; + pub const TCSETSW: ::Ioctl = 0x802c7415; + pub const TCSETSF: ::Ioctl = 0x802c7416; } } @@ -170,6 +170,10 @@ pub const TIOCSERSETMULTI: ::Ioctl = 0x545B; pub const TIOCMIWAIT: ::Ioctl = 0x545C; pub const TIOCGICOUNT: ::Ioctl = 0x545D; +pub const BLKIOMIN: ::Ioctl = 0x20001278; +pub const BLKIOOPT: ::Ioctl = 0x20001279; +pub const BLKSSZGET: ::Ioctl = 0x20001268; +pub const BLKPBSZGET: ::Ioctl = 0x2000127B; //pub const FIOQSIZE: ::Ioctl = 0x40086680; pub const TIOCM_LE: ::c_int = 0x001; @@ -187,5 +191,50 @@ pub const BOTHER: ::speed_t = 0o0037; pub const IBSHIFT: ::tcflag_t = 16; -pub const BLKSSZGET: ::c_int = 0x20001268; -pub const BLKPBSZGET: ::c_int = 0x2000127B; +// RLIMIT Constants + +cfg_if! { + if #[cfg(target_env = "gnu")] { + + pub const RLIMIT_CPU: ::__rlimit_resource_t = 0; + pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1; + pub const RLIMIT_DATA: ::__rlimit_resource_t = 2; + pub const RLIMIT_STACK: ::__rlimit_resource_t = 3; + pub const RLIMIT_CORE: ::__rlimit_resource_t = 4; + pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; + pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; + pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; + pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; + pub const RLIMIT_AS: ::__rlimit_resource_t = 9; + pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10; + pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11; + pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12; + pub const RLIMIT_NICE: ::__rlimit_resource_t = 13; + pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14; + pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15; + pub const RLIM_NLIMITS: ::__rlimit_resource_t = 16; + pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS; + + } else if #[cfg(target_env = "musl")] { + + pub const RLIMIT_CPU: ::c_int = 0; + pub const RLIMIT_FSIZE: ::c_int = 1; + pub const RLIMIT_DATA: ::c_int = 2; + pub const RLIMIT_STACK: ::c_int = 3; + pub const RLIMIT_CORE: ::c_int = 4; + pub const RLIMIT_RSS: ::c_int = 5; + pub const RLIMIT_NPROC: ::c_int = 6; + pub const RLIMIT_NOFILE: ::c_int = 7; + pub const RLIMIT_MEMLOCK: ::c_int = 8; + pub const RLIMIT_AS: ::c_int = 9; + pub const RLIMIT_LOCKS: ::c_int = 10; + pub const RLIMIT_SIGPENDING: ::c_int = 11; + pub const RLIMIT_MSGQUEUE: ::c_int = 12; + pub const RLIMIT_NICE: ::c_int = 13; + pub const RLIMIT_RTPRIO: ::c_int = 14; + pub const RLIMIT_RTTIME: ::c_int = 15; + pub const RLIM_NLIMITS: ::c_int = 15; + pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS; + } +} +pub const RLIM_INFINITY: ::rlim_t = !0; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -171,6 +171,10 @@ pub const TIOCGICOUNT: ::Ioctl = 0x545D; pub const TIOCSTART: ::Ioctl = 0x2000746e; pub const TIOCSTOP: ::Ioctl = 0x2000746f; +pub const BLKIOMIN: ::Ioctl = 0x20001278; +pub const BLKIOOPT: ::Ioctl = 0x20001279; +pub const BLKSSZGET: ::Ioctl = 0x20001268; +pub const BLKPBSZGET: ::Ioctl = 0x2000127B; //pub const FIOASYNC: ::Ioctl = 0x4004667d; //pub const FIOQSIZE: ::Ioctl = ; @@ -194,5 +198,31 @@ pub const BOTHER: ::speed_t = 0x1000; pub const IBSHIFT: ::tcflag_t = 16; -pub const BLKSSZGET: ::c_int = 0x20001268; -pub const BLKPBSZGET: ::c_int = 0x2000127B; +// RLIMIT Constants + +pub const RLIMIT_CPU: ::__rlimit_resource_t = 0; +pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1; +pub const RLIMIT_DATA: ::__rlimit_resource_t = 2; +pub const RLIMIT_STACK: ::__rlimit_resource_t = 3; +pub const RLIMIT_CORE: ::__rlimit_resource_t = 4; +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 6; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 7; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10; +pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11; +pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12; +pub const RLIMIT_NICE: ::__rlimit_resource_t = 13; +pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14; +pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15; +pub const RLIM_NLIMITS: ::__rlimit_resource_t = 16; +pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS; + +cfg_if! { + if #[cfg(target_arch = "sparc64")] { + pub const RLIM_INFINITY: ::rlim_t = !0; + } else if #[cfg(target_arch = "sparc")] { + pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/align.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/align.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/align.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/align.rs 2022-04-20 13:48:09.000000000 +0000 @@ -4,4 +4,50 @@ pub struct max_align_t { priv_: [i64; 2] } + + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: ::mcontext_t, + pub uc_sigmask: ::sigset_t, + pub uc_regspace: [::c_ulong; 128], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + } + } + impl Eq for ucontext_t {} + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_link) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + .finish() + } + } + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + } + } + } } diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -167,9 +167,32 @@ pub seccomp_notif_resp: ::__u16, pub seccomp_data: ::__u16, } + + pub struct mcontext_t { + pub trap_no: ::c_ulong, + pub error_code: ::c_ulong, + pub oldmask: ::c_ulong, + pub arm_r0: ::c_ulong, + pub arm_r1: ::c_ulong, + pub arm_r2: ::c_ulong, + pub arm_r3: ::c_ulong, + pub arm_r4: ::c_ulong, + pub arm_r5: ::c_ulong, + pub arm_r6: ::c_ulong, + pub arm_r7: ::c_ulong, + pub arm_r8: ::c_ulong, + pub arm_r9: ::c_ulong, + pub arm_r10: ::c_ulong, + pub arm_fp: ::c_ulong, + pub arm_ip: ::c_ulong, + pub arm_sp: ::c_ulong, + pub arm_lr: ::c_ulong, + pub arm_pc: ::c_ulong, + pub arm_cpsr: ::c_ulong, + pub fault_address: ::c_ulong, + } } -pub const RLIM_INFINITY: ::rlim_t = !0; pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; @@ -189,11 +212,6 @@ pub const O_FSYNC: ::c_int = 0x101000; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MAP_LOCKED: ::c_int = 0x02000; @@ -797,6 +815,7 @@ pub const SYS_pkey_alloc: ::c_long = 395; pub const SYS_pkey_free: ::c_long = 396; pub const SYS_statx: ::c_long = 397; +pub const SYS_rseq: ::c_long = 398; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/align.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/align.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/align.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/align.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(2))] + pub struct max_align_t { + priv_: [i8; 20] + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,849 @@ +pub type c_char = i8; +pub type wchar_t = i32; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_ulong, + pub sa_restorer: ::Option, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + f_spare: [::__fsword_t; 4], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct ipc_perm { + __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + __seq: ::c_ushort, + __pad1: ::c_ushort, + __glibc_reserved1: ::c_ulong, + __glibc_reserved2: ::c_ulong, + } + + pub struct stat64 { + pub st_dev: ::dev_t, + __pad1: ::c_ushort, + pub __st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_ushort, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_ulong, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_ulong, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_ulong, + pub st_ino: ::ino64_t, + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsblkcnt64_t, + pub f_ffree: ::fsblkcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsblkcnt64_t, + pub f_ffree: ::fsblkcnt64_t, + pub f_favail: ::fsblkcnt64_t, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + __glibc_reserved1: ::c_long, + pub shm_dtime: ::time_t, + __glibc_reserved2: ::c_long, + pub shm_ctime: ::time_t, + __glibc_reserved3: ::c_long, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __glibc_reserved5: ::c_ulong, + __glibc_reserved6: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + __glibc_reserved1: ::c_uint, + pub msg_rtime: ::time_t, + __glibc_reserved2: ::c_uint, + pub msg_ctime: ::time_t, + __glibc_reserved3: ::c_uint, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved4: ::c_ulong, + __glibc_reserved5: ::c_ulong, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } +} + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_LARGEFILE: ::c_int = 0x20000; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 0x101000; +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_NDELAY: ::c_int = 0x800; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_32BIT: ::c_int = 0x0040; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_SYNC: ::c_int = 0x080000; + +pub const EDEADLOCK: ::c_int = 35; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +pub const PTRACE_GETFPXREGS: ::c_uint = 18; +pub const PTRACE_SETFPXREGS: ::c_uint = 19; +pub const PTRACE_SYSEMU: ::c_uint = 31; +pub const PTRACE_SYSEMU_SINGLESTEP: ::c_uint = 32; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const EFD_NONBLOCK: ::c_int = 0x800; +pub const SFD_NONBLOCK: ::c_int = 0x0800; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = 31; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; +pub const EXTPROC: ::tcflag_t = 0x00010000; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time32: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_chown16: ::c_long = 16; +pub const SYS_stat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_oldumount: ::c_long = 22; +pub const SYS_setuid16: ::c_long = 23; +pub const SYS_getuid16: ::c_long = 24; +pub const SYS_stime32: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_fstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime32: ::c_long = 30; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid16: ::c_long = 46; +pub const SYS_getgid16: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid16: ::c_long = 49; +pub const SYS_getegid16: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount: ::c_long = 52; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid16: ::c_long = 70; +pub const SYS_setregid16: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_old_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups16: ::c_long = 80; +pub const SYS_setgroups16: ::c_long = 81; +pub const SYS_old_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_lstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_old_readdir: ::c_long = 89; +pub const SYS_old_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown16: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_newstat: ::c_long = 106; +pub const SYS_newlstat: ::c_long = 107; +pub const SYS_newfstat: ::c_long = 108; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_newuname: ::c_long = 122; +pub const SYS_cacheflush: ::c_long = 123; +pub const SYS_adjtimex_time32: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_setfsuid16: ::c_long = 138; +pub const SYS_setfsgid16: ::c_long = 139; +pub const SYS_llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS_select: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval_time32: ::c_long = 161; +pub const SYS_nanosleep_time32: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid16: ::c_long = 164; +pub const SYS_getresuid16: ::c_long = 165; +pub const SYS_getpagesize: ::c_long = 166; +pub const SYS_query_module: ::c_long = 167; +pub const SYS_poll: ::c_long = 168; +pub const SYS_nfsservctl: ::c_long = 169; +pub const SYS_setresgid16: ::c_long = 170; +pub const SYS_getresgid16: ::c_long = 171; +pub const SYS_prctl: ::c_long = 172; +pub const SYS_rt_sigreturn: ::c_long = 173; +pub const SYS_rt_sigaction: ::c_long = 174; +pub const SYS_rt_sigprocmask: ::c_long = 175; +pub const SYS_rt_sigpending: ::c_long = 176; +pub const SYS_rt_sigtimedwait_time32: ::c_long = 177; +pub const SYS_rt_sigqueueinfo: ::c_long = 178; +pub const SYS_rt_sigsuspend: ::c_long = 179; +pub const SYS_pread64: ::c_long = 180; +pub const SYS_pwrite64: ::c_long = 181; +pub const SYS_lchown16: ::c_long = 182; +pub const SYS_getcwd: ::c_long = 183; +pub const SYS_capget: ::c_long = 184; +pub const SYS_capset: ::c_long = 185; +pub const SYS_sigaltstack: ::c_long = 186; +pub const SYS_sendfile: ::c_long = 187; +pub const SYS_getpmsg: ::c_long = 188; +pub const SYS_putpmsg: ::c_long = 189; +pub const SYS_vfork: ::c_long = 190; +pub const SYS_getrlimit: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_chown: ::c_long = 198; +pub const SYS_getuid: ::c_long = 199; +pub const SYS_getgid: ::c_long = 200; +pub const SYS_geteuid: ::c_long = 201; +pub const SYS_getegid: ::c_long = 202; +pub const SYS_setreuid: ::c_long = 203; +pub const SYS_setregid: ::c_long = 204; +pub const SYS_getgroups: ::c_long = 205; +pub const SYS_setgroups: ::c_long = 206; +pub const SYS_fchown: ::c_long = 207; +pub const SYS_setresuid: ::c_long = 208; +pub const SYS_getresuid: ::c_long = 209; +pub const SYS_setresgid: ::c_long = 210; +pub const SYS_getresgid: ::c_long = 211; +pub const SYS_lchown: ::c_long = 212; +pub const SYS_setuid: ::c_long = 213; +pub const SYS_setgid: ::c_long = 214; +pub const SYS_setfsuid: ::c_long = 215; +pub const SYS_setfsgid: ::c_long = 216; +pub const SYS_pivot_root: ::c_long = 217; +pub const SYS_getdents64: ::c_long = 220; +pub const SYS_gettid: ::c_long = 221; +pub const SYS_tkill: ::c_long = 222; +pub const SYS_setxattr: ::c_long = 223; +pub const SYS_lsetxattr: ::c_long = 224; +pub const SYS_fsetxattr: ::c_long = 225; +pub const SYS_getxattr: ::c_long = 226; +pub const SYS_lgetxattr: ::c_long = 227; +pub const SYS_fgetxattr: ::c_long = 228; +pub const SYS_listxattr: ::c_long = 229; +pub const SYS_llistxattr: ::c_long = 230; +pub const SYS_flistxattr: ::c_long = 231; +pub const SYS_removexattr: ::c_long = 232; +pub const SYS_lremovexattr: ::c_long = 233; +pub const SYS_fremovexattr: ::c_long = 234; +pub const SYS_futex_time32: ::c_long = 235; +pub const SYS_sendfile64: ::c_long = 236; +pub const SYS_mincore: ::c_long = 237; +pub const SYS_madvise: ::c_long = 238; +pub const SYS_fcntl64: ::c_long = 239; +pub const SYS_readahead: ::c_long = 240; +pub const SYS_io_setup: ::c_long = 241; +pub const SYS_io_destroy: ::c_long = 242; +pub const SYS_io_getevents_time32: ::c_long = 243; +pub const SYS_io_submit: ::c_long = 244; +pub const SYS_io_cancel: ::c_long = 245; +pub const SYS_fadvise64: ::c_long = 246; +pub const SYS_exit_group: ::c_long = 247; +pub const SYS_lookup_dcookie: ::c_long = 248; +pub const SYS_epoll_create: ::c_long = 249; +pub const SYS_epoll_ctl: ::c_long = 250; +pub const SYS_epoll_wait: ::c_long = 251; +pub const SYS_remap_file_pages: ::c_long = 252; +pub const SYS_set_tid_address: ::c_long = 253; +pub const SYS_timer_create: ::c_long = 254; +pub const SYS_timer_settime32: ::c_long = 255; +pub const SYS_timer_gettime32: ::c_long = 256; +pub const SYS_timer_getoverrun: ::c_long = 257; +pub const SYS_timer_delete: ::c_long = 258; +pub const SYS_clock_settime32: ::c_long = 259; +pub const SYS_clock_gettime32: ::c_long = 260; +pub const SYS_clock_getres_time32: ::c_long = 261; +pub const SYS_clock_nanosleep_time32: ::c_long = 262; +pub const SYS_statfs64: ::c_long = 263; +pub const SYS_fstatfs64: ::c_long = 264; +pub const SYS_tgkill: ::c_long = 265; +pub const SYS_utimes_time32: ::c_long = 266; +pub const SYS_fadvise64_64: ::c_long = 267; +pub const SYS_mbind: ::c_long = 268; +pub const SYS_get_mempolicy: ::c_long = 269; +pub const SYS_set_mempolicy: ::c_long = 270; +pub const SYS_mq_open: ::c_long = 271; +pub const SYS_mq_unlink: ::c_long = 272; +pub const SYS_mq_timedsend_time32: ::c_long = 273; +pub const SYS_mq_timedreceive_time32: ::c_long = 274; +pub const SYS_mq_notify: ::c_long = 275; +pub const SYS_mq_getsetattr: ::c_long = 276; +pub const SYS_waitid: ::c_long = 277; +pub const SYS_add_key: ::c_long = 279; +pub const SYS_request_key: ::c_long = 280; +pub const SYS_keyctl: ::c_long = 281; +pub const SYS_ioprio_set: ::c_long = 282; +pub const SYS_ioprio_get: ::c_long = 283; +pub const SYS_inotify_init: ::c_long = 284; +pub const SYS_inotify_add_watch: ::c_long = 285; +pub const SYS_inotify_rm_watch: ::c_long = 286; +pub const SYS_migrate_pages: ::c_long = 287; +pub const SYS_openat: ::c_long = 288; +pub const SYS_mkdirat: ::c_long = 289; +pub const SYS_mknodat: ::c_long = 290; +pub const SYS_fchownat: ::c_long = 291; +pub const SYS_futimesat_time32: ::c_long = 292; +pub const SYS_fstatat64: ::c_long = 293; +pub const SYS_unlinkat: ::c_long = 294; +pub const SYS_renameat: ::c_long = 295; +pub const SYS_linkat: ::c_long = 296; +pub const SYS_symlinkat: ::c_long = 297; +pub const SYS_readlinkat: ::c_long = 298; +pub const SYS_fchmodat: ::c_long = 299; +pub const SYS_faccessat: ::c_long = 300; +pub const SYS_pselect6_time32: ::c_long = 301; +pub const SYS_ppoll_time32: ::c_long = 302; +pub const SYS_unshare: ::c_long = 303; +pub const SYS_set_robust_list: ::c_long = 304; +pub const SYS_get_robust_list: ::c_long = 305; +pub const SYS_splice: ::c_long = 306; +pub const SYS_sync_file_range: ::c_long = 307; +pub const SYS_tee: ::c_long = 308; +pub const SYS_vmsplice: ::c_long = 309; +pub const SYS_move_pages: ::c_long = 310; +pub const SYS_sched_setaffinity: ::c_long = 311; +pub const SYS_sched_getaffinity: ::c_long = 312; +pub const SYS_kexec_load: ::c_long = 313; +pub const SYS_getcpu: ::c_long = 314; +pub const SYS_epoll_pwait: ::c_long = 315; +pub const SYS_utimensat_time32: ::c_long = 316; +pub const SYS_signalfd: ::c_long = 317; +pub const SYS_timerfd_create: ::c_long = 318; +pub const SYS_eventfd: ::c_long = 319; +pub const SYS_fallocate: ::c_long = 320; +pub const SYS_timerfd_settime32: ::c_long = 321; +pub const SYS_timerfd_gettime32: ::c_long = 322; +pub const SYS_signalfd4: ::c_long = 323; +pub const SYS_eventfd2: ::c_long = 324; +pub const SYS_epoll_create1: ::c_long = 325; +pub const SYS_dup3: ::c_long = 326; +pub const SYS_pipe2: ::c_long = 327; +pub const SYS_inotify_init1: ::c_long = 328; +pub const SYS_preadv: ::c_long = 329; +pub const SYS_pwritev: ::c_long = 330; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 331; +pub const SYS_perf_event_open: ::c_long = 332; +pub const SYS_get_thread_area: ::c_long = 333; +pub const SYS_set_thread_area: ::c_long = 334; +pub const SYS_atomic_cmpxchg_32: ::c_long = 335; +pub const SYS_atomic_barrier: ::c_long = 336; +pub const SYS_fanotify_init: ::c_long = 337; +pub const SYS_fanotify_mark: ::c_long = 338; +pub const SYS_prlimit64: ::c_long = 339; +pub const SYS_name_to_handle_at: ::c_long = 340; +pub const SYS_open_by_handle_at: ::c_long = 341; +pub const SYS_clock_adjtime32: ::c_long = 342; +pub const SYS_syncfs: ::c_long = 343; +pub const SYS_setns: ::c_long = 344; +pub const SYS_process_vm_readv: ::c_long = 345; +pub const SYS_process_vm_writev: ::c_long = 346; +pub const SYS_kcmp: ::c_long = 347; +pub const SYS_finit_module: ::c_long = 348; +pub const SYS_sched_setattr: ::c_long = 349; +pub const SYS_sched_getattr: ::c_long = 350; +pub const SYS_renameat2: ::c_long = 351; +pub const SYS_getrandom: ::c_long = 352; +pub const SYS_memfd_create: ::c_long = 353; +pub const SYS_bpf: ::c_long = 354; +pub const SYS_execveat: ::c_long = 355; +pub const SYS_socket: ::c_long = 356; +pub const SYS_socketpair: ::c_long = 357; +pub const SYS_bind: ::c_long = 358; +pub const SYS_connect: ::c_long = 359; +pub const SYS_listen: ::c_long = 360; +pub const SYS_accept4: ::c_long = 361; +pub const SYS_getsockopt: ::c_long = 362; +pub const SYS_setsockopt: ::c_long = 363; +pub const SYS_getsockname: ::c_long = 364; +pub const SYS_getpeername: ::c_long = 365; +pub const SYS_sendto: ::c_long = 366; +pub const SYS_sendmsg: ::c_long = 367; +pub const SYS_recvfrom: ::c_long = 368; +pub const SYS_recvmsg: ::c_long = 369; +pub const SYS_shutdown: ::c_long = 370; +pub const SYS_recvmmsg_time32: ::c_long = 371; +pub const SYS_sendmmsg: ::c_long = 372; +pub const SYS_userfaultfd: ::c_long = 373; +pub const SYS_membarrier: ::c_long = 374; +pub const SYS_mlock2: ::c_long = 375; +pub const SYS_copy_file_range: ::c_long = 376; +pub const SYS_preadv2: ::c_long = 377; +pub const SYS_pwritev2: ::c_long = 378; +pub const SYS_statx: ::c_long = 379; +pub const SYS_seccomp: ::c_long = 380; +pub const SYS_pkey_mprotect: ::c_long = 381; +pub const SYS_pkey_alloc: ::c_long = 382; +pub const SYS_pkey_free: ::c_long = 383; +pub const SYS_rseq: ::c_long = 384; +pub const SYS_semget: ::c_long = 393; +pub const SYS_semctl: ::c_long = 394; +pub const SYS_shmget: ::c_long = 395; +pub const SYS_shmctl: ::c_long = 396; +pub const SYS_shmat: ::c_long = 397; +pub const SYS_shmdt: ::c_long = 398; +pub const SYS_msgget: ::c_long = 399; +pub const SYS_msgsnd: ::c_long = 400; +pub const SYS_msgrcv: ::c_long = 401; +pub const SYS_msgctl: ::c_long = 402; +pub const SYS_clock_gettime: ::c_long = 403; +pub const SYS_clock_settime: ::c_long = 404; +pub const SYS_clock_adjtime: ::c_long = 405; +pub const SYS_clock_getres: ::c_long = 406; +pub const SYS_clock_nanosleep: ::c_long = 407; +pub const SYS_timer_gettime: ::c_long = 408; +pub const SYS_timer_settime: ::c_long = 409; +pub const SYS_timerfd_gettime: ::c_long = 410; +pub const SYS_timerfd_settime: ::c_long = 411; +pub const SYS_utimensat: ::c_long = 412; +pub const SYS_pselect6: ::c_long = 413; +pub const SYS_ppoll: ::c_long = 414; +pub const SYS_io_pgetevents: ::c_long = 416; +pub const SYS_recvmmsg: ::c_long = 417; +pub const SYS_mq_timedsend: ::c_long = 418; +pub const SYS_mq_timedreceive: ::c_long = 419; +pub const SYS_semtimedop: ::c_long = 420; +pub const SYS_rt_sigtimedwait: ::c_long = 421; +pub const SYS_futex: ::c_long = 422; +pub const SYS_sched_rr_get_interval: ::c_long = 423; +pub const SYS_pidfd_send_signal: ::c_long = 424; +pub const SYS_io_uring_setup: ::c_long = 425; +pub const SYS_io_uring_enter: ::c_long = 426; +pub const SYS_io_uring_register: ::c_long = 427; +pub const SYS_open_tree: ::c_long = 428; +pub const SYS_move_mount: ::c_long = 429; +pub const SYS_fsopen: ::c_long = 430; +pub const SYS_fsconfig: ::c_long = 431; +pub const SYS_fsmount: ::c_long = 432; +pub const SYS_fspick: ::c_long = 433; +pub const SYS_pidfd_open: ::c_long = 434; +pub const SYS_clone3: ::c_long = 435; +pub const SYS_close_range: ::c_long = 436; +pub const SYS_openat2: ::c_long = 437; +pub const SYS_pidfd_getfd: ::c_long = 438; +pub const SYS_faccessat2: ::c_long = 439; +pub const SYS_process_madvise: ::c_long = 440; +pub const SYS_epoll_pwait2: ::c_long = 441; +pub const SYS_mount_setattr: ::c_long = 442; +pub const SYS_quotactl_fd: ::c_long = 443; +pub const SYS_landlock_create_ruleset: ::c_long = 444; +pub const SYS_landlock_add_rule: ::c_long = 445; +pub const SYS_landlock_restrict_self: ::c_long = 446; +pub const SYS_process_mrelease: ::c_long = 448; +pub const SYS_futex_waitv: ::c_long = 449; +pub const SYS_set_mempolicy_home_node: ::c_long = 450; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -516,6 +516,7 @@ pub const SYS_pkey_alloc: ::c_long = 4000 + 364; pub const SYS_pkey_free: ::c_long = 4000 + 365; pub const SYS_statx: ::c_long = 4000 + 366; +pub const SYS_rseq: ::c_long = 4000 + 367; pub const SYS_pidfd_send_signal: ::c_long = 4000 + 424; pub const SYS_io_uring_setup: ::c_long = 4000 + 425; pub const SYS_io_uring_enter: ::c_long = 4000 + 426; @@ -540,13 +541,6 @@ pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; -pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 6; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 8; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 9; - pub const O_APPEND: ::c_int = 8; pub const O_CREAT: ::c_int = 256; pub const O_EXCL: ::c_int = 1024; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -135,12 +135,6 @@ pub _f: [::c_char; 8], } - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } - pub struct semid_ds { pub sem_perm: ipc_perm, #[cfg(target_arch = "powerpc")] @@ -344,6 +338,9 @@ } else if #[cfg(target_arch = "mips")] { mod mips; pub use self::mips::*; + } else if #[cfg(target_arch = "m68k")] { + mod m68k; + pub use self::m68k::*; } else if #[cfg(target_arch = "powerpc")] { mod powerpc; pub use self::powerpc::*; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs 2022-04-20 13:48:09.000000000 +0000 @@ -163,7 +163,6 @@ } } -pub const RLIM_INFINITY: ::rlim_t = !0; pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; @@ -183,11 +182,6 @@ pub const O_FSYNC: ::c_int = 0x101000; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; @@ -800,6 +794,7 @@ pub const SYS_pwritev2: ::c_long = 381; pub const SYS_kexec_file_load: ::c_long = 382; pub const SYS_statx: ::c_long = 383; +pub const SYS_rseq: ::c_long = 387; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,44 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub __uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [::c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + #[allow(missing_debug_implementations)] + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_f_ext_state { + pub __f: [::c_uint; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_d_ext_state { + pub __f: [::c_ulonglong; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [::c_ulonglong; 64], + pub __fcsr: ::c_uint, + pub __glibc_reserved: [::c_uint; 3], + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -198,16 +198,11 @@ } } -pub const RLIM_INFINITY: ::rlim_t = !0; +pub const O_LARGEFILE: ::c_int = 0; pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; @@ -457,6 +452,16 @@ pub const EXTPROC: ::tcflag_t = 65536; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const NGREG: usize = 32; +pub const REG_PC: usize = 0; +pub const REG_RA: usize = 1; +pub const REG_SP: usize = 2; +pub const REG_TP: usize = 4; +pub const REG_S0: usize = 8; +pub const REG_S1: usize = 9; +pub const REG_A0: usize = 10; +pub const REG_S2: usize = 18; +pub const REG_NARGS: usize = 8; pub const SYS_read: ::c_long = 63; pub const SYS_write: ::c_long = 64; @@ -733,6 +738,7 @@ pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; pub const SYS_statx: ::c_long = 291; +pub const SYS_rseq: ::c_long = 293; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; @@ -752,3 +758,10 @@ pub const SYS_process_madvise: ::c_long = 440; pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -193,18 +193,11 @@ } } -pub const RLIM_INFINITY: ::rlim_t = !0; pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 6; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 7; - pub const O_APPEND: ::c_int = 0x8; pub const O_CREAT: ::c_int = 0x200; pub const O_EXCL: ::c_int = 0x800; @@ -825,6 +818,7 @@ pub const SYS_preadv2: ::c_long = 358; pub const SYS_pwritev2: ::c_long = 359; pub const SYS_statx: ::c_long = 360; +pub const SYS_rseq: ::c_long = 365; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -370,7 +370,6 @@ } } -pub const RLIM_INFINITY: ::rlim_t = !0; pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; @@ -390,11 +389,6 @@ pub const O_FSYNC: ::c_int = 0x101000; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MAP_LOCKED: ::c_int = 0x02000; @@ -1026,6 +1020,7 @@ pub const SYS_pkey_alloc: ::c_long = 381; pub const SYS_pkey_free: ::c_long = 382; pub const SYS_statx: ::c_long = 383; +pub const SYS_rseq: ::c_long = 386; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,7 @@ +s! { + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: u32, + pub fpcr: u32, + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -197,12 +197,6 @@ pub ss_size: ::size_t } - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } - pub struct seccomp_notif_sizes { pub seccomp_notif: ::__u16, pub seccomp_notif_resp: ::__u16, @@ -216,12 +210,6 @@ pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; - pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; @@ -861,6 +849,7 @@ pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; pub const SYS_statx: ::c_long = 291; +pub const SYS_rseq: ::c_long = 293; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; @@ -908,3 +897,10 @@ pub use self::align::*; } } + +cfg_if! { + if #[cfg(libc_int128)] { + mod int128; + pub use self::int128::*; + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -567,6 +567,7 @@ pub const SYS_pkey_alloc: ::c_long = 5000 + 324; pub const SYS_pkey_free: ::c_long = 5000 + 325; pub const SYS_statx: ::c_long = 5000 + 326; +pub const SYS_rseq: ::c_long = 5000 + 327; pub const SYS_pidfd_send_signal: ::c_long = 5000 + 424; pub const SYS_io_uring_setup: ::c_long = 5000 + 425; pub const SYS_io_uring_enter: ::c_long = 5000 + 426; @@ -629,12 +630,6 @@ pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 6; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 8; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 9; - pub const O_APPEND: ::c_int = 8; pub const O_CREAT: ::c_int = 256; pub const O_EXCL: ::c_int = 1024; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -89,7 +89,6 @@ } } -pub const RLIM_INFINITY: ::rlim_t = !0; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; pub const O_LARGEFILE: ::c_int = 0; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -191,12 +191,6 @@ pub ss_flags: ::c_int, pub ss_size: ::size_t } - - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } } pub const POSIX_FADV_DONTNEED: ::c_int = 4; @@ -208,12 +202,6 @@ pub const VEOF: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; - pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; @@ -940,6 +928,7 @@ pub const SYS_pwritev2: ::c_long = 381; pub const SYS_kexec_file_load: ::c_long = 382; pub const SYS_statx: ::c_long = 383; +pub const SYS_rseq: ::c_long = 387; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,44 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub __uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [::c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + #[allow(missing_debug_implementations)] + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_f_ext_state { + pub __f: [::c_uint; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_d_ext_state { + pub __f: [::c_ulonglong; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [::c_ulonglong; 64], + pub __fcsr: ::c_uint, + pub __glibc_reserved: [::c_uint; 3], + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -192,12 +192,6 @@ pub l_len: ::off64_t, pub l_pid: ::pid_t, } - - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } } pub const POSIX_FADV_DONTNEED: ::c_int = 4; @@ -206,11 +200,6 @@ pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; @@ -399,6 +388,12 @@ pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; +pub const PTRACE_GETFPREGS: ::c_uint = 14; +pub const PTRACE_SETFPREGS: ::c_uint = 15; +pub const PTRACE_GETFPXREGS: ::c_uint = 18; +pub const PTRACE_SETFPXREGS: ::c_uint = 19; +pub const PTRACE_GETREGS: ::c_uint = 12; +pub const PTRACE_SETREGS: ::c_uint = 13; pub const MCL_CURRENT: ::c_int = 1; pub const MCL_FUTURE: ::c_int = 2; pub const SIGSTKSZ: ::size_t = 8192; @@ -496,6 +491,17 @@ pub const EXTPROC: ::tcflag_t = 65536; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const NGREG: usize = 32; +pub const REG_PC: usize = 0; +pub const REG_RA: usize = 1; +pub const REG_SP: usize = 2; +pub const REG_TP: usize = 4; +pub const REG_S0: usize = 8; +pub const REG_S1: usize = 9; +pub const REG_A0: usize = 10; +pub const REG_S2: usize = 18; +pub const REG_NARGS: usize = 8; + pub const SYS_read: ::c_long = 63; pub const SYS_write: ::c_long = 64; pub const SYS_close: ::c_long = 57; @@ -771,6 +777,7 @@ pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; pub const SYS_statx: ::c_long = 291; +pub const SYS_rseq: ::c_long = 293; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; @@ -790,3 +797,10 @@ pub const SYS_process_madvise: ::c_long = 440; pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs 2022-04-20 13:48:09.000000000 +0000 @@ -345,12 +345,6 @@ pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; - pub const O_NOCTTY: ::c_int = 256; pub const O_SYNC: ::c_int = 1052672; pub const O_RSYNC: ::c_int = 1052672; @@ -921,6 +915,7 @@ pub const SYS_setfsgid: ::c_long = 216; pub const SYS_newfstatat: ::c_long = 293; pub const SYS_statx: ::c_long = 379; +pub const SYS_rseq: ::c_long = 383; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -205,12 +205,6 @@ pub const RTLD_NOLOAD: ::c_int = 0x4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 6; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 7; - pub const O_APPEND: ::c_int = 0x8; pub const O_CREAT: ::c_int = 0x200; pub const O_EXCL: ::c_int = 0x800; @@ -885,6 +879,7 @@ pub const SYS_preadv2: ::c_long = 358; pub const SYS_pwritev2: ::c_long = 359; pub const SYS_statx: ::c_long = 360; +pub const SYS_rseq: ::c_long = 365; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -260,12 +260,6 @@ __unused5: u64 } - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } - pub struct seccomp_notif_sizes { pub seccomp_notif: ::__u16, pub seccomp_notif_resp: ::__u16, @@ -406,12 +400,6 @@ pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; -pub const RLIMIT_AS: ::__rlimit_resource_t = 9; -pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; -pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; -pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; - pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs 2022-04-20 13:48:09.000000000 +0000 @@ -409,6 +409,7 @@ pub const SYS_pkey_alloc: ::c_long = 330; pub const SYS_pkey_free: ::c_long = 331; pub const SYS_statx: ::c_long = 332; +pub const SYS_rseq: ::c_long = 334; pub const SYS_pidfd_send_signal: ::c_long = 424; pub const SYS_io_uring_setup: ::c_long = 425; pub const SYS_io_uring_enter: ::c_long = 426; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs 2022-04-20 13:48:09.000000000 +0000 @@ -337,6 +337,7 @@ pub const SYS_pkey_alloc: ::c_long = __X32_SYSCALL_BIT + 330; pub const SYS_pkey_free: ::c_long = __X32_SYSCALL_BIT + 331; pub const SYS_statx: ::c_long = __X32_SYSCALL_BIT + 332; +pub const SYS_rseq: ::c_long = __X32_SYSCALL_BIT + 334; pub const SYS_pidfd_send_signal: ::c_long = __X32_SYSCALL_BIT + 424; pub const SYS_io_uring_setup: ::c_long = __X32_SYSCALL_BIT + 425; pub const SYS_io_uring_enter: ::c_long = __X32_SYSCALL_BIT + 426; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -629,20 +629,6 @@ pub const MAP_HUGE_2GB: ::c_int = HUGETLB_FLAG_ENCODE_2GB; pub const MAP_HUGE_16GB: ::c_int = HUGETLB_FLAG_ENCODE_16GB; -pub const RLIMIT_CPU: ::__rlimit_resource_t = 0; -pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1; -pub const RLIMIT_DATA: ::__rlimit_resource_t = 2; -pub const RLIMIT_STACK: ::__rlimit_resource_t = 3; -pub const RLIMIT_CORE: ::__rlimit_resource_t = 4; -pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10; -pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11; -pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12; -pub const RLIMIT_NICE: ::__rlimit_resource_t = 13; -pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14; -pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15; -pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = 16; -pub const RLIM_NLIMITS: ::__rlimit_resource_t = RLIMIT_NLIMITS; - pub const PRIO_PROCESS: ::__priority_which_t = 0; pub const PRIO_PGRP: ::__priority_which_t = 1; pub const PRIO_USER: ::__priority_which_t = 2; @@ -846,116 +832,15 @@ pub const ST_RELATIME: ::c_ulong = 4096; pub const NI_MAXHOST: ::socklen_t = 1025; +// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the +// following are only available on newer Linux versions than the versions +// currently used in CI in some configurations, so we define them here. cfg_if! { if #[cfg(not(target_arch = "s390x"))] { - pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; - pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; - pub const AFS_SUPER_MAGIC: ::c_long = 0x5346414f; - pub const AUTOFS_SUPER_MAGIC: ::c_long = 0x0187; pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70; - pub const BPF_FS_MAGIC: ::c_long = 0xcafe4a11; - pub const BTRFS_SUPER_MAGIC: ::c_long = 0x9123683e; - pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270; - pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb; - pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; - pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; - pub const DEBUGFS_MAGIC: ::c_long = 0x64626720; - pub const DEVPTS_SUPER_MAGIC: ::c_long = 0x1cd1; - pub const ECRYPTFS_SUPER_MAGIC: ::c_long = 0xf15f; - pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; - pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; - pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; - pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; - pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010; - pub const FUSE_SUPER_MAGIC: ::c_long = 0x65735546; - pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea; - pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee; - pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; - pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; - pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; - pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; - pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; - pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; - pub const MINIX3_SUPER_MAGIC: ::c_long = 0x4d5a; - pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; - pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; - pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; - pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; - pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; - pub const NILFS_SUPER_MAGIC: ::c_long = 0x3434; - pub const OCFS2_SUPER_MAGIC: ::c_long = 0x7461636f; - pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; - pub const OVERLAYFS_SUPER_MAGIC: ::c_long = 0x794c7630; - pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; - pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; - pub const QNX6_SUPER_MAGIC: ::c_long = 0x68191122; - pub const RDTGROUP_SUPER_MAGIC: ::c_long = 0x7655821; - pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; - pub const SECURITYFS_MAGIC: ::c_long = 0x73636673; - pub const SELINUX_MAGIC: ::c_long = 0xf97cff8c; - pub const SMACK_MAGIC: ::c_long = 0x43415d53; - pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; - pub const SYSFS_MAGIC: ::c_long = 0x62656572; - pub const TMPFS_MAGIC: ::c_long = 0x01021994; - pub const TRACEFS_MAGIC: ::c_long = 0x74726163; - pub const UDF_SUPER_MAGIC: ::c_long = 0x15013346; - pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; - pub const XENFS_SUPER_MAGIC: ::c_long = 0xabba1974; pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342; } else if #[cfg(target_arch = "s390x")] { - pub const ADFS_SUPER_MAGIC: ::c_uint = 0x0000adf5; - pub const AFFS_SUPER_MAGIC: ::c_uint = 0x0000adff; - pub const AFS_SUPER_MAGIC: ::c_uint = 0x5346414f; - pub const AUTOFS_SUPER_MAGIC: ::c_uint = 0x0187; pub const BINDERFS_SUPER_MAGIC: ::c_uint = 0x6c6f6f70; - pub const BPF_FS_MAGIC: ::c_uint = 0xcafe4a11; - pub const BTRFS_SUPER_MAGIC: ::c_uint = 0x9123683e; - pub const CGROUP2_SUPER_MAGIC: ::c_uint = 0x63677270; - pub const CGROUP_SUPER_MAGIC: ::c_uint = 0x27e0eb; - pub const CODA_SUPER_MAGIC: ::c_uint = 0x73757245; - pub const CRAMFS_MAGIC: ::c_uint = 0x28cd3d45; - pub const DEBUGFS_MAGIC: ::c_uint = 0x64626720; - pub const DEVPTS_SUPER_MAGIC: ::c_uint = 0x1cd1; - pub const ECRYPTFS_SUPER_MAGIC: ::c_uint = 0xf15f; - pub const EFS_SUPER_MAGIC: ::c_uint = 0x00414a53; - pub const EXT2_SUPER_MAGIC: ::c_uint = 0x0000ef53; - pub const EXT3_SUPER_MAGIC: ::c_uint = 0x0000ef53; - pub const EXT4_SUPER_MAGIC: ::c_uint = 0x0000ef53; - pub const F2FS_SUPER_MAGIC: ::c_uint = 0xf2f52010; - pub const FUSE_SUPER_MAGIC: ::c_uint = 0x65735546; - pub const FUTEXFS_SUPER_MAGIC: ::c_uint = 0xbad1dea; - pub const HOSTFS_SUPER_MAGIC: ::c_uint = 0x00c0ffee; - pub const HPFS_SUPER_MAGIC: ::c_uint = 0xf995e849; - pub const HUGETLBFS_MAGIC: ::c_uint = 0x958458f6; - pub const ISOFS_SUPER_MAGIC: ::c_uint = 0x00009660; - pub const JFFS2_SUPER_MAGIC: ::c_uint = 0x000072b6; - pub const MINIX2_SUPER_MAGIC2: ::c_uint = 0x00002478; - pub const MINIX2_SUPER_MAGIC: ::c_uint = 0x00002468; - pub const MINIX3_SUPER_MAGIC: ::c_uint = 0x4d5a; - pub const MINIX_SUPER_MAGIC2: ::c_uint = 0x0000138f; - pub const MINIX_SUPER_MAGIC: ::c_uint = 0x0000137f; - pub const MSDOS_SUPER_MAGIC: ::c_uint = 0x00004d44; - pub const NCP_SUPER_MAGIC: ::c_uint = 0x0000564c; - pub const NFS_SUPER_MAGIC: ::c_uint = 0x00006969; - pub const NILFS_SUPER_MAGIC: ::c_uint = 0x3434; - pub const OCFS2_SUPER_MAGIC: ::c_uint = 0x7461636f; - pub const OPENPROM_SUPER_MAGIC: ::c_uint = 0x00009fa1; - pub const OVERLAYFS_SUPER_MAGIC: ::c_uint = 0x794c7630; - pub const PROC_SUPER_MAGIC: ::c_uint = 0x00009fa0; - pub const QNX4_SUPER_MAGIC: ::c_uint = 0x0000002f; - pub const QNX6_SUPER_MAGIC: ::c_uint = 0x68191122; - pub const RDTGROUP_SUPER_MAGIC: ::c_uint = 0x7655821; - pub const REISERFS_SUPER_MAGIC: ::c_uint = 0x52654973; - pub const SECURITYFS_MAGIC: ::c_uint = 0x73636673; - pub const SELINUX_MAGIC: ::c_uint = 0xf97cff8c; - pub const SMACK_MAGIC: ::c_uint = 0x43415d53; - pub const SMB_SUPER_MAGIC: ::c_uint = 0x0000517b; - pub const SYSFS_MAGIC: ::c_uint = 0x62656572; - pub const TMPFS_MAGIC: ::c_uint = 0x01021994; - pub const TRACEFS_MAGIC: ::c_uint = 0x74726163; - pub const UDF_SUPER_MAGIC: ::c_uint = 0x15013346; - pub const USBDEVICE_SUPER_MAGIC: ::c_uint = 0x00009fa2; - pub const XENFS_SUPER_MAGIC: ::c_uint = 0xabba1974; pub const XFS_SUPER_MAGIC: ::c_uint = 0x58465342; } } @@ -1300,6 +1185,7 @@ mask: ::c_uint, statxbuf: *mut statx, ) -> ::c_int; + pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; pub fn getauxval(type_: ::c_ulong) -> ::c_ulong; @@ -1439,6 +1325,7 @@ cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "arm", + target_arch = "m68k", target_arch = "mips", target_arch = "powerpc", target_arch = "sparc", diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -39,7 +39,12 @@ // linux/can.h pub type canid_t = u32; + +// linux/can/j1939.h pub type can_err_mask_t = u32; +pub type pgn_t = u32; +pub type priority_t = u8; +pub type name_t = u64; pub type iconv_t = *mut ::c_void; @@ -543,6 +548,16 @@ pub can_mask: canid_t, } + // linux/can/j1939.h + pub struct j1939_filter { + pub name: name_t, + pub name_mask: name_t, + pub pgn: pgn_t, + pub pgn_mask: pgn_t, + pub addr: u8, + pub addr_mask: u8, + } + // linux/filter.h pub struct sock_filter { pub code: ::__u16, @@ -1477,6 +1492,16 @@ pub const AT_EACCESS: ::c_int = 0x200; +// linux/mempolicy.h +pub const MPOL_DEFAULT: ::c_int = 0; +pub const MPOL_PREFERRED: ::c_int = 1; +pub const MPOL_BIND: ::c_int = 2; +pub const MPOL_INTERLEAVE: ::c_int = 3; +pub const MPOL_LOCAL: ::c_int = 4; +pub const MPOL_F_NUMA_BALANCING: ::c_int = 1 << 13; +pub const MPOL_F_RELATIVE_NODES: ::c_int = 1 << 14; +pub const MPOL_F_STATIC_NODES: ::c_int = 1 << 15; + align_const! { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { size: [0; __SIZEOF_PTHREAD_MUTEX_T], @@ -1751,6 +1776,9 @@ pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3; pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4; +pub const PR_SET_VMA: ::c_int = 0x53564d41; +pub const PR_SET_VMA_ANON_NAME: ::c_int = 0; + pub const GRND_NONBLOCK: ::c_uint = 0x0001; pub const GRND_RANDOM: ::c_uint = 0x0002; @@ -1820,6 +1848,20 @@ pub const MFD_CLOEXEC: ::c_uint = 0x0001; pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002; pub const MFD_HUGETLB: ::c_uint = 0x0004; +pub const MFD_HUGE_64KB: ::c_uint = 0x40000000; +pub const MFD_HUGE_512KB: ::c_uint = 0x4c000000; +pub const MFD_HUGE_1MB: ::c_uint = 0x50000000; +pub const MFD_HUGE_2MB: ::c_uint = 0x54000000; +pub const MFD_HUGE_8MB: ::c_uint = 0x5c000000; +pub const MFD_HUGE_16MB: ::c_uint = 0x60000000; +pub const MFD_HUGE_32MB: ::c_uint = 0x64000000; +pub const MFD_HUGE_256MB: ::c_uint = 0x70000000; +pub const MFD_HUGE_512MB: ::c_uint = 0x74000000; +pub const MFD_HUGE_1GB: ::c_uint = 0x78000000; +pub const MFD_HUGE_2GB: ::c_uint = 0x7c000000; +pub const MFD_HUGE_16GB: ::c_uint = 0x88000000; +pub const MFD_HUGE_MASK: ::c_uint = 63; +pub const MFD_HUGE_SHIFT: ::c_uint = 26; // linux/close_range.h pub const CLOSE_RANGE_UNSHARE: ::c_uint = 1 << 1; @@ -3161,6 +3203,47 @@ pub const CAN_RAW_FD_FRAMES: ::c_int = 5; pub const CAN_RAW_JOIN_FILTERS: ::c_int = 6; +// linux/can/j1939.h +pub const SOL_CAN_J1939: ::c_int = SOL_CAN_BASE + CAN_J1939; + +pub const J1939_MAX_UNICAST_ADDR: ::c_uchar = 0xfd; +pub const J1939_IDLE_ADDR: ::c_uchar = 0xfe; +pub const J1939_NO_ADDR: ::c_uchar = 0xff; +pub const J1939_NO_NAME: ::c_ulong = 0; +pub const J1939_PGN_REQUEST: ::c_uint = 0x0ea00; +pub const J1939_PGN_ADDRESS_CLAIMED: ::c_uint = 0x0ee00; +pub const J1939_PGN_ADDRESS_COMMANDED: ::c_uint = 0x0fed8; +pub const J1939_PGN_PDU1_MAX: ::c_uint = 0x3ff00; +pub const J1939_PGN_MAX: ::c_uint = 0x3ffff; +pub const J1939_NO_PGN: ::c_uint = 0x40000; + +pub const SO_J1939_FILTER: ::c_int = 1; +pub const SO_J1939_PROMISC: ::c_int = 2; +pub const SO_J1939_SEND_PRIO: ::c_int = 3; +pub const SO_J1939_ERRQUEUE: ::c_int = 4; + +pub const SCM_J1939_DEST_ADDR: ::c_int = 1; +pub const SCM_J1939_DEST_NAME: ::c_int = 2; +pub const SCM_J1939_PRIO: ::c_int = 3; +pub const SCM_J1939_ERRQUEUE: ::c_int = 4; + +pub const J1939_NLA_PAD: ::c_int = 0; +pub const J1939_NLA_BYTES_ACKED: ::c_int = 1; +pub const J1939_NLA_TOTAL_SIZE: ::c_int = 2; +pub const J1939_NLA_PGN: ::c_int = 3; +pub const J1939_NLA_SRC_NAME: ::c_int = 4; +pub const J1939_NLA_DEST_NAME: ::c_int = 5; +pub const J1939_NLA_SRC_ADDR: ::c_int = 6; +pub const J1939_NLA_DEST_ADDR: ::c_int = 7; + +pub const J1939_EE_INFO_NONE: ::c_int = 0; +pub const J1939_EE_INFO_TX_ABORT: ::c_int = 1; +pub const J1939_EE_INFO_RX_RTS: ::c_int = 2; +pub const J1939_EE_INFO_RX_DPO: ::c_int = 3; +pub const J1939_EE_INFO_RX_ABORT: ::c_int = 4; + +pub const J1939_FILTER_MAX: ::c_int = 512; + f! { pub fn NLA_ALIGN(len: ::c_int) -> ::c_int { return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1) diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -150,6 +150,77 @@ pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], } + + pub struct mcontext_t { + pub trap_no: ::c_ulong, + pub error_code: ::c_ulong, + pub oldmask: ::c_ulong, + pub arm_r0: ::c_ulong, + pub arm_r1: ::c_ulong, + pub arm_r2: ::c_ulong, + pub arm_r3: ::c_ulong, + pub arm_r4: ::c_ulong, + pub arm_r5: ::c_ulong, + pub arm_r6: ::c_ulong, + pub arm_r7: ::c_ulong, + pub arm_r8: ::c_ulong, + pub arm_r9: ::c_ulong, + pub arm_r10: ::c_ulong, + pub arm_fp: ::c_ulong, + pub arm_ip: ::c_ulong, + pub arm_sp: ::c_ulong, + pub arm_lr: ::c_ulong, + pub arm_pc: ::c_ulong, + pub arm_cpsr: ::c_ulong, + pub fault_address: ::c_ulong, + } +} + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + pub uc_regspace: [::c_ulonglong; 64], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + } + } + impl Eq for ucontext_t {} + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_link) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + .finish() + } + } + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + } + } + } } pub const SIGSTKSZ: ::size_t = 8192; @@ -161,14 +232,6 @@ pub const O_ASYNC: ::c_int = 0x2000; pub const O_LARGEFILE: ::c_int = 0o400000; -pub const RLIMIT_RSS: ::c_int = 5; -pub const RLIMIT_NOFILE: ::c_int = 7; -pub const RLIMIT_AS: ::c_int = 9; -pub const RLIMIT_NPROC: ::c_int = 6; -pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const RLIMIT_NLIMITS: ::c_int = 15; -pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; - pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs 2022-04-20 13:48:09.000000000 +0000 @@ -265,13 +265,7 @@ pub const PF_KCM: ::c_int = 41; pub const PF_MAX: ::c_int = 43; pub const PF_QIPCRTR: ::c_int = 42; -pub const RLIMIT_AS: ::c_int = 9; -pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const RLIMIT_NOFILE: ::c_int = 7; -pub const RLIMIT_NPROC: ::c_int = 6; -pub const RLIMIT_RSS: ::c_int = 5; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] -pub const RLIM_NLIMITS: ::c_int = 16; pub const SA_ONSTACK: ::c_int = 0x08000000; pub const SA_SIGINFO: ::c_int = 0x00000004; pub const SA_NOCLDWAIT: ::c_int = 0x00000002; @@ -649,6 +643,25 @@ pub const SYS_write: ::c_int = 64; pub const SYS_writev: ::c_int = 66; pub const SYS_statx: ::c_int = 291; +pub const SYS_pidfd_send_signal: ::c_long = 424; +pub const SYS_io_uring_setup: ::c_long = 425; +pub const SYS_io_uring_enter: ::c_long = 426; +pub const SYS_io_uring_register: ::c_long = 427; +pub const SYS_open_tree: ::c_long = 428; +pub const SYS_move_mount: ::c_long = 429; +pub const SYS_fsopen: ::c_long = 430; +pub const SYS_fsconfig: ::c_long = 431; +pub const SYS_fsmount: ::c_long = 432; +pub const SYS_fspick: ::c_long = 433; +pub const SYS_pidfd_open: ::c_long = 434; +pub const SYS_clone3: ::c_long = 435; +pub const SYS_close_range: ::c_long = 436; +pub const SYS_openat2: ::c_long = 437; +pub const SYS_pidfd_getfd: ::c_long = 438; +pub const SYS_faccessat2: ::c_long = 439; +pub const SYS_process_madvise: ::c_long = 440; +pub const SYS_epoll_pwait2: ::c_long = 441; +pub const SYS_mount_setattr: ::c_long = 442; pub const TIOCM_LOOP: ::c_int = 32768; pub const TIOCM_OUT1: ::c_int = 8192; pub const TIOCM_OUT2: ::c_int = 16384; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -172,14 +172,6 @@ pub const O_ASYNC: ::c_int = 0o10000; pub const O_LARGEFILE: ::c_int = 0x2000; -pub const RLIMIT_RSS: ::c_int = 7; -pub const RLIMIT_NOFILE: ::c_int = 5; -pub const RLIMIT_AS: ::c_int = 6; -pub const RLIMIT_NPROC: ::c_int = 8; -pub const RLIMIT_MEMLOCK: ::c_int = 9; -pub const RLIMIT_NLIMITS: ::c_int = 15; -pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; - pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs 2022-04-20 13:48:09.000000000 +0000 @@ -165,14 +165,6 @@ pub const O_ASYNC: ::c_int = 0x2000; pub const O_LARGEFILE: ::c_int = 0x10000; -pub const RLIMIT_RSS: ::c_int = 5; -pub const RLIMIT_NOFILE: ::c_int = 7; -pub const RLIMIT_AS: ::c_int = 9; -pub const RLIMIT_NPROC: ::c_int = 6; -pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const RLIMIT_NLIMITS: ::c_int = 15; -pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; - pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; pub const CBAUD: ::tcflag_t = 0o0000377; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -221,14 +221,6 @@ pub const O_ASYNC: ::c_int = 0x2000; pub const O_LARGEFILE: ::c_int = 0o0100000; -pub const RLIMIT_RSS: ::c_int = 5; -pub const RLIMIT_NOFILE: ::c_int = 7; -pub const RLIMIT_AS: ::c_int = 9; -pub const RLIMIT_NPROC: ::c_int = 6; -pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const RLIMIT_NLIMITS: ::c_int = 15; -pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; - pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,7 @@ +s! { + pub struct user_fpsimd_struct { + pub vregs: [::__uint128_t; 32], + pub fpsr: u32, + pub fpcr: u32, + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -556,8 +556,6 @@ pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; -pub const RLIMIT_NLIMITS: ::c_int = 15; -pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; @@ -644,3 +642,10 @@ pub use self::align::*; } } + +cfg_if! { + if #[cfg(libc_int128)] { + mod int128; + pub use self::int128::*; + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs 2022-04-20 13:48:09.000000000 +0000 @@ -458,6 +458,7 @@ pub const O_RSYNC: ::c_int = 0x4010; pub const O_DSYNC: ::c_int = 0x10; pub const O_ASYNC: ::c_int = 0x1000; +pub const O_LARGEFILE: ::c_int = 0; pub const EDEADLK: ::c_int = 45; pub const ENAMETOOLONG: ::c_int = 78; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -133,12 +133,6 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; -pub const RLIMIT_RSS: ::c_int = 5; -pub const RLIMIT_NOFILE: ::c_int = 7; -pub const RLIMIT_AS: ::c_int = 9; -pub const RLIMIT_NPROC: ::c_int = 6; -pub const RLIMIT_MEMLOCK: ::c_int = 8; - pub const SOCK_NONBLOCK: ::c_int = 2048; pub const SOCK_SEQPACKET: ::c_int = 5; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs 2022-04-20 13:48:09.000000000 +0000 @@ -612,8 +612,6 @@ pub const TOSTOP: ::tcflag_t = 0x00400000; pub const FLUSHO: ::tcflag_t = 0x00800000; -pub const RLIMIT_NLIMITS: ::c_int = 15; -pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; pub const CBAUD: ::tcflag_t = 0xff; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/align.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/align.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/align.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/align.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,44 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub __uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [::c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + #[allow(missing_debug_implementations)] + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_f_ext_state { + pub __f: [::c_uint; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_d_ext_state { + pub __f: [::c_ulonglong; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [::c_ulonglong; 64], + pub __fcsr: ::c_uint, + pub __glibc_reserved: [::c_uint; 3], + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -465,6 +465,25 @@ pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; pub const SYS_statx: ::c_long = 291; +pub const SYS_pidfd_send_signal: ::c_long = 424; +pub const SYS_io_uring_setup: ::c_long = 425; +pub const SYS_io_uring_enter: ::c_long = 426; +pub const SYS_io_uring_register: ::c_long = 427; +pub const SYS_open_tree: ::c_long = 428; +pub const SYS_move_mount: ::c_long = 429; +pub const SYS_fsopen: ::c_long = 430; +pub const SYS_fsconfig: ::c_long = 431; +pub const SYS_fsmount: ::c_long = 432; +pub const SYS_fspick: ::c_long = 433; +pub const SYS_pidfd_open: ::c_long = 434; +pub const SYS_clone3: ::c_long = 435; +pub const SYS_close_range: ::c_long = 436; +pub const SYS_openat2: ::c_long = 437; +pub const SYS_pidfd_getfd: ::c_long = 438; +pub const SYS_faccessat2: ::c_long = 439; +pub const SYS_process_madvise: ::c_long = 440; +pub const SYS_epoll_pwait2: ::c_long = 441; +pub const SYS_mount_setattr: ::c_long = 442; pub const O_APPEND: ::c_int = 1024; pub const O_DIRECT: ::c_int = 0x4000; @@ -548,6 +567,11 @@ pub const EALREADY: ::c_int = 114; pub const EINPROGRESS: ::c_int = 115; pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; pub const EDQUOT: ::c_int = 122; pub const ENOMEDIUM: ::c_int = 123; pub const EMEDIUMTYPE: ::c_int = 124; @@ -618,7 +642,6 @@ pub const MAP_HUGETLB: ::c_int = 0x040000; pub const MAP_SYNC: ::c_int = 0x080000; -pub const RLIMIT_NLIMITS: ::c_int = 15; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; @@ -697,3 +720,21 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; + +pub const NGREG: usize = 32; +pub const REG_PC: usize = 0; +pub const REG_RA: usize = 1; +pub const REG_SP: usize = 2; +pub const REG_TP: usize = 4; +pub const REG_S0: usize = 8; +pub const REG_S1: usize = 9; +pub const REG_A0: usize = 10; +pub const REG_S2: usize = 18; +pub const REG_NARGS: usize = 8; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -817,8 +817,6 @@ pub const MAP_HUGETLB: ::c_int = 0x040000; pub const MAP_SYNC: ::c_int = 0x080000; -pub const RLIMIT_NLIMITS: ::c_int = 15; -pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/musl/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -218,12 +218,6 @@ pub rt_irtt: ::c_ushort, } - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } - pub struct __exit_status { pub e_termination: ::c_short, pub e_exit: ::c_short, @@ -530,9 +524,6 @@ pub const POSIX_MADV_DONTNEED: ::c_int = 4; -pub const RLIM_INFINITY: ::rlim_t = !0; -pub const RLIMIT_RTTIME: ::c_int = 15; - pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; pub const SOCK_DCCP: ::c_int = 6; @@ -625,17 +616,6 @@ pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const RLIMIT_CPU: ::c_int = 0; -pub const RLIMIT_FSIZE: ::c_int = 1; -pub const RLIMIT_DATA: ::c_int = 2; -pub const RLIMIT_STACK: ::c_int = 3; -pub const RLIMIT_CORE: ::c_int = 4; -pub const RLIMIT_LOCKS: ::c_int = 10; -pub const RLIMIT_SIGPENDING: ::c_int = 11; -pub const RLIMIT_MSGQUEUE: ::c_int = 12; -pub const RLIMIT_NICE: ::c_int = 13; -pub const RLIMIT_RTPRIO: ::c_int = 14; - pub const REG_OK: ::c_int = 0; pub const PRIO_PROCESS: ::c_int = 0; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/no_align.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/no_align.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/no_align.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/no_align.rs 2022-04-20 13:48:09.000000000 +0000 @@ -62,6 +62,7 @@ pub struct pthread_mutex_t { #[cfg(any(target_arch = "mips", target_arch = "arm", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", all(target_arch = "x86_64", @@ -69,6 +70,7 @@ __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", all(target_arch = "x86_64", @@ -80,6 +82,7 @@ pub struct pthread_rwlock_t { #[cfg(any(target_arch = "mips", target_arch = "arm", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", all(target_arch = "x86_64", @@ -87,6 +90,7 @@ __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", all(target_arch = "x86_64", diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -10,7 +10,6 @@ pub type ino_t = ::c_ulong; pub type off_t = ::c_long; pub type pthread_t = ::c_ulong; -pub type rlim_t = ::c_ulong; pub type suseconds_t = ::c_long; pub type nlink_t = ::c_uint; @@ -244,7 +243,6 @@ } pub const O_CLOEXEC: ::c_int = 0o2000000; -pub const RLIM_INFINITY: rlim_t = !0; pub const __SIZEOF_PTHREAD_ATTR_T: usize = 36; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,6 @@ pub type nlink_t = u32; pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; -pub type rlim_t = ::c_ulong; pub type __u64 = ::c_ulonglong; pub type fsblkcnt64_t = u64; pub type fsfilcnt64_t = u64; @@ -265,8 +264,6 @@ pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; -pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff; - pub const SYS_syscall: ::c_long = 4000 + 0; pub const SYS_exit: ::c_long = 4000 + 1; pub const SYS_fork: ::c_long = 4000 + 2; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -8,7 +8,6 @@ pub type ino_t = u64; pub type nlink_t = u64; pub type off_t = i64; -pub type rlim_t = ::c_ulong; pub type suseconds_t = i64; pub type time_t = i64; pub type wchar_t = i32; @@ -193,8 +192,6 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -pub const RLIM_INFINITY: ::rlim_t = 0xffff_ffff_ffff_ffff; - pub const SYS_gettid: ::c_long = 5178; // Valid for n64 cfg_if! { diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -39,9 +39,6 @@ pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; -pub const RLIMIT_NLIMITS: ::c_int = 15; -pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; - pub const O_APPEND: ::c_int = 8; pub const O_CREAT: ::c_int = 256; pub const O_EXCL: ::c_int = 1024; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,7 +2,8 @@ pub type msgqnum_t = ::c_ulong; pub type msglen_t = ::c_ulong; pub type regoff_t = ::c_int; -pub type __rlimit_resource_t = ::c_uint; +pub type rlim_t = ::c_ulong; +pub type __rlimit_resource_t = ::c_ulong; pub type __priority_which_t = ::c_uint; cfg_if! { @@ -80,6 +81,32 @@ } } +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut ::c_void { + #[repr(C)] + struct siginfo_sigfault { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + si_addr: *mut ::c_void, + } + (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + } + + pub unsafe fn si_value(&self) -> ::sigval { + #[repr(C)] + struct siginfo_si_value { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + _si_timerid: ::c_int, + _si_overrun: ::c_int, + si_value: ::sigval, + } + (*(self as *const siginfo_t as *const siginfo_si_value)).si_value + } +} + pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; @@ -87,55 +114,10 @@ pub const AF_VSOCK: ::c_int = 40; -pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; -pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; -pub const AFS_SUPER_MAGIC: ::c_long = 0x5346414f; -pub const AUTOFS_SUPER_MAGIC: ::c_long = 0x0187; +// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the +// following are only available on newer Linux versions than the versions +// currently used in CI in some configurations, so we define them here. pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70; -pub const BPF_FS_MAGIC: ::c_long = 0xcafe4a11; -pub const BTRFS_SUPER_MAGIC: ::c_long = 0x9123683e; -pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270; -pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb; -pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; -pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; -pub const DEBUGFS_MAGIC: ::c_long = 0x64626720; -pub const DEVPTS_SUPER_MAGIC: ::c_long = 0x1cd1; -pub const ECRYPTFS_SUPER_MAGIC: ::c_long = 0xf15f; -pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; -pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010; -pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea; -pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee; -pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; -pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; -pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; -pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; -pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; -pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; -pub const MINIX3_SUPER_MAGIC: ::c_long = 0x4d5a; -pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; -pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; -pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; -pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; -pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; -pub const NILFS_SUPER_MAGIC: ::c_long = 0x3434; -pub const OCFS2_SUPER_MAGIC: ::c_long = 0x7461636f; -pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; -pub const OVERLAYFS_SUPER_MAGIC: ::c_long = 0x794c7630; -pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; -pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; -pub const QNX6_SUPER_MAGIC: ::c_long = 0x68191122; -pub const RDTGROUP_SUPER_MAGIC: ::c_long = 0x7655821; -pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; -pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; -pub const SYSFS_MAGIC: ::c_long = 0x62656572; -pub const TMPFS_MAGIC: ::c_long = 0x01021994; -pub const TRACEFS_MAGIC: ::c_long = 0x74726163; -pub const UDF_SUPER_MAGIC: ::c_long = 0x15013346; -pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; -pub const XENFS_SUPER_MAGIC: ::c_long = 0xabba1974; pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342; pub const PTRACE_TRACEME: ::c_int = 0; @@ -170,17 +152,6 @@ pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; -pub const RLIMIT_CPU: ::c_int = 0; -pub const RLIMIT_FSIZE: ::c_int = 1; -pub const RLIMIT_DATA: ::c_int = 2; -pub const RLIMIT_STACK: ::c_int = 3; -pub const RLIMIT_CORE: ::c_int = 4; -pub const RLIMIT_LOCKS: ::c_int = 10; -pub const RLIMIT_SIGPENDING: ::c_int = 11; -pub const RLIMIT_MSGQUEUE: ::c_int = 12; -pub const RLIMIT_NICE: ::c_int = 13; -pub const RLIMIT_RTPRIO: ::c_int = 14; - // These are different than GNU! pub const LC_CTYPE: ::c_int = 0; pub const LC_NUMERIC: ::c_int = 1; @@ -310,13 +281,6 @@ pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const PTRACE_EVENT_STOP: ::c_int = 128; pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; -pub const RLIMIT_AS: ::c_int = 9; -pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const RLIMIT_NLIMITS: ::c_int = 15; -pub const RLIMIT_NOFILE: ::c_int = 7; -pub const RLIMIT_NPROC: ::c_int = 6; -pub const RLIMIT_RSS: ::c_int = 5; -pub const RLIMIT_RTTIME: ::c_int = 15; pub const RTLD_NOLOAD: ::c_int = 0x00004; pub const RUSAGE_THREAD: ::c_int = 1; pub const SHM_EXEC: ::c_int = 0100000; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/x86_64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/x86_64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/x86_64/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/linux/uclibc/x86_64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -11,7 +11,6 @@ pub type ino_t = ::c_ulong; pub type nlink_t = ::c_uint; pub type off_t = ::c_long; -pub type rlim_t = c_ulong; // [uClibc docs] Note stat64 has the same shape as stat for x86-64. pub type stat64 = stat; pub type suseconds_t = ::c_long; @@ -317,6 +316,7 @@ pub const O_CREAT: ::c_int = 0100; pub const O_DIRECTORY: ::c_int = 0200000; pub const O_EXCL: ::c_int = 0200; +pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_NONBLOCK: ::c_int = 04000; pub const O_TRUNC: ::c_int = 01000; pub const NCCS: usize = 32; @@ -325,7 +325,6 @@ pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const SOCK_DGRAM: ::c_int = 2; // connectionless, unreliable datagrams pub const SOCK_STREAM: ::c_int = 1; // …/common/bits/socket_type.h -pub const RLIM_INFINITY: u64 = 0xffffffffffffffff; pub const __SIZEOF_PTHREAD_COND_T: usize = 48; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; diff -Nru cargo-0.58.0/vendor/libc/src/unix/linux_like/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/linux_like/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/linux_like/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -25,6 +25,12 @@ pub imr_interface: in_addr, } + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: ::c_int, + } + pub struct ip_mreq_source { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, @@ -1365,6 +1371,118 @@ pub const ARPHRD_VOID: u16 = 0xFFFF; pub const ARPHRD_NONE: u16 = 0xFFFE; +cfg_if! { + if #[cfg(target_os = "emscripten")] { + // Emscripten does not define any `*_SUPER_MAGIC` constants. + } else if #[cfg(not(target_arch = "s390x"))] { + pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; + pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; + pub const AFS_SUPER_MAGIC: ::c_long = 0x5346414f; + pub const AUTOFS_SUPER_MAGIC: ::c_long = 0x0187; + pub const BPF_FS_MAGIC: ::c_long = 0xcafe4a11; + pub const BTRFS_SUPER_MAGIC: ::c_long = 0x9123683e; + pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270; + pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb; + pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; + pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; + pub const DEBUGFS_MAGIC: ::c_long = 0x64626720; + pub const DEVPTS_SUPER_MAGIC: ::c_long = 0x1cd1; + pub const ECRYPTFS_SUPER_MAGIC: ::c_long = 0xf15f; + pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; + pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; + pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; + pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; + pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010; + pub const FUSE_SUPER_MAGIC: ::c_long = 0x65735546; + pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea; + pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee; + pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; + pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; + pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; + pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; + pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; + pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; + pub const MINIX3_SUPER_MAGIC: ::c_long = 0x4d5a; + pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; + pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; + pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; + pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; + pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; + pub const NILFS_SUPER_MAGIC: ::c_long = 0x3434; + pub const OCFS2_SUPER_MAGIC: ::c_long = 0x7461636f; + pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; + pub const OVERLAYFS_SUPER_MAGIC: ::c_long = 0x794c7630; + pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; + pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; + pub const QNX6_SUPER_MAGIC: ::c_long = 0x68191122; + pub const RDTGROUP_SUPER_MAGIC: ::c_long = 0x7655821; + pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; + pub const SECURITYFS_MAGIC: ::c_long = 0x73636673; + pub const SELINUX_MAGIC: ::c_long = 0xf97cff8c; + pub const SMACK_MAGIC: ::c_long = 0x43415d53; + pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; + pub const SYSFS_MAGIC: ::c_long = 0x62656572; + pub const TMPFS_MAGIC: ::c_long = 0x01021994; + pub const TRACEFS_MAGIC: ::c_long = 0x74726163; + pub const UDF_SUPER_MAGIC: ::c_long = 0x15013346; + pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; + pub const XENFS_SUPER_MAGIC: ::c_long = 0xabba1974; + } else if #[cfg(target_arch = "s390x")] { + pub const ADFS_SUPER_MAGIC: ::c_uint = 0x0000adf5; + pub const AFFS_SUPER_MAGIC: ::c_uint = 0x0000adff; + pub const AFS_SUPER_MAGIC: ::c_uint = 0x5346414f; + pub const AUTOFS_SUPER_MAGIC: ::c_uint = 0x0187; + pub const BPF_FS_MAGIC: ::c_uint = 0xcafe4a11; + pub const BTRFS_SUPER_MAGIC: ::c_uint = 0x9123683e; + pub const CGROUP2_SUPER_MAGIC: ::c_uint = 0x63677270; + pub const CGROUP_SUPER_MAGIC: ::c_uint = 0x27e0eb; + pub const CODA_SUPER_MAGIC: ::c_uint = 0x73757245; + pub const CRAMFS_MAGIC: ::c_uint = 0x28cd3d45; + pub const DEBUGFS_MAGIC: ::c_uint = 0x64626720; + pub const DEVPTS_SUPER_MAGIC: ::c_uint = 0x1cd1; + pub const ECRYPTFS_SUPER_MAGIC: ::c_uint = 0xf15f; + pub const EFS_SUPER_MAGIC: ::c_uint = 0x00414a53; + pub const EXT2_SUPER_MAGIC: ::c_uint = 0x0000ef53; + pub const EXT3_SUPER_MAGIC: ::c_uint = 0x0000ef53; + pub const EXT4_SUPER_MAGIC: ::c_uint = 0x0000ef53; + pub const F2FS_SUPER_MAGIC: ::c_uint = 0xf2f52010; + pub const FUSE_SUPER_MAGIC: ::c_uint = 0x65735546; + pub const FUTEXFS_SUPER_MAGIC: ::c_uint = 0xbad1dea; + pub const HOSTFS_SUPER_MAGIC: ::c_uint = 0x00c0ffee; + pub const HPFS_SUPER_MAGIC: ::c_uint = 0xf995e849; + pub const HUGETLBFS_MAGIC: ::c_uint = 0x958458f6; + pub const ISOFS_SUPER_MAGIC: ::c_uint = 0x00009660; + pub const JFFS2_SUPER_MAGIC: ::c_uint = 0x000072b6; + pub const MINIX2_SUPER_MAGIC2: ::c_uint = 0x00002478; + pub const MINIX2_SUPER_MAGIC: ::c_uint = 0x00002468; + pub const MINIX3_SUPER_MAGIC: ::c_uint = 0x4d5a; + pub const MINIX_SUPER_MAGIC2: ::c_uint = 0x0000138f; + pub const MINIX_SUPER_MAGIC: ::c_uint = 0x0000137f; + pub const MSDOS_SUPER_MAGIC: ::c_uint = 0x00004d44; + pub const NCP_SUPER_MAGIC: ::c_uint = 0x0000564c; + pub const NFS_SUPER_MAGIC: ::c_uint = 0x00006969; + pub const NILFS_SUPER_MAGIC: ::c_uint = 0x3434; + pub const OCFS2_SUPER_MAGIC: ::c_uint = 0x7461636f; + pub const OPENPROM_SUPER_MAGIC: ::c_uint = 0x00009fa1; + pub const OVERLAYFS_SUPER_MAGIC: ::c_uint = 0x794c7630; + pub const PROC_SUPER_MAGIC: ::c_uint = 0x00009fa0; + pub const QNX4_SUPER_MAGIC: ::c_uint = 0x0000002f; + pub const QNX6_SUPER_MAGIC: ::c_uint = 0x68191122; + pub const RDTGROUP_SUPER_MAGIC: ::c_uint = 0x7655821; + pub const REISERFS_SUPER_MAGIC: ::c_uint = 0x52654973; + pub const SECURITYFS_MAGIC: ::c_uint = 0x73636673; + pub const SELINUX_MAGIC: ::c_uint = 0xf97cff8c; + pub const SMACK_MAGIC: ::c_uint = 0x43415d53; + pub const SMB_SUPER_MAGIC: ::c_uint = 0x0000517b; + pub const SYSFS_MAGIC: ::c_uint = 0x62656572; + pub const TMPFS_MAGIC: ::c_uint = 0x01021994; + pub const TRACEFS_MAGIC: ::c_uint = 0x74726163; + pub const UDF_SUPER_MAGIC: ::c_uint = 0x15013346; + pub const USBDEVICE_SUPER_MAGIC: ::c_uint = 0x00009fa2; + pub const XENFS_SUPER_MAGIC: ::c_uint = 0xabba1974; + } +} + const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { len + ::mem::size_of::() - 1 & !(::mem::size_of::() - 1) diff -Nru cargo-0.58.0/vendor/libc/src/unix/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -23,13 +23,21 @@ pub type ssize_t = isize; pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; pub type in_addr_t = u32; pub type in_port_t = u16; pub type sighandler_t = ::size_t; pub type cc_t = ::c_uchar; +cfg_if! { + if #[cfg(any(target_os = "espidf", target_os = "horizon"))] { + pub type uid_t = ::c_ushort; + pub type gid_t = ::c_ushort; + } else { + pub type uid_t = u32; + pub type gid_t = u32; + } +} + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum DIR {} impl ::Copy for DIR {} @@ -348,6 +356,7 @@ extern {} } else if #[cfg(any(target_os = "macos", target_os = "ios", + target_os = "watchos", target_os = "android", target_os = "openbsd"))] { #[link(name = "c")] @@ -1017,7 +1026,7 @@ pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; #[cfg_attr( - any(target_os = "macos", target_os = "ios"), + any(target_os = "macos", target_os = "ios", target_os = "watchos"), link_name = "realpath$DARWIN_EXTSN" )] pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char; @@ -1183,7 +1192,10 @@ ), link_name = "__res_init" )] - #[cfg_attr(any(target_os = "macos", target_os = "ios"), link_name = "res_9_init")] + #[cfg_attr( + any(target_os = "macos", target_os = "ios", target_os = "watchos"), + link_name = "res_9_init" + )] pub fn res_init() -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] @@ -1456,6 +1468,7 @@ pub use self::linux_like::*; } else if #[cfg(any(target_os = "macos", target_os = "ios", + target_os = "watchos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", diff -Nru cargo-0.58.0/vendor/libc/src/unix/newlib/aarch64/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/aarch64/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/newlib/aarch64/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/aarch64/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -50,3 +50,5 @@ pub const MSG_WAITALL: ::c_int = 0; pub const MSG_MORE: ::c_int = 0; pub const MSG_NOSIGNAL: ::c_int = 0; + +pub use crate::unix::newlib::generic::{sigset_t, stat}; diff -Nru cargo-0.58.0/vendor/libc/src/unix/newlib/arm/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/arm/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/newlib/arm/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/arm/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -52,3 +52,5 @@ pub const MSG_WAITALL: ::c_int = 0; pub const MSG_MORE: ::c_int = 0; pub const MSG_NOSIGNAL: ::c_int = 0; + +pub use crate::unix::newlib::generic::{sigset_t, stat}; diff -Nru cargo-0.58.0/vendor/libc/src/unix/newlib/espidf/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/espidf/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/newlib/espidf/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/espidf/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -101,3 +101,5 @@ #[link_name = "lwip_recvmsg"] pub fn recvmsg(s: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; } + +pub use crate::unix::newlib::generic::{sigset_t, stat}; diff -Nru cargo-0.58.0/vendor/libc/src/unix/newlib/generic.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/generic.rs --- cargo-0.58.0/vendor/libc/src/unix/newlib/generic.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/generic.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,27 @@ +//! Common types used by most newlib platforms + +s! { + pub struct sigset_t { + __val: [::c_ulong; 16], + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_atime: ::time_t, + pub st_spare1: ::c_long, + pub st_mtime: ::time_t, + pub st_spare2: ::c_long, + pub st_ctime: ::time_t, + pub st_spare3: ::c_long, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_spare4: [::c_long; 2usize], + } +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/newlib/horizon/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/horizon/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/newlib/horizon/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/horizon/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,268 @@ +//! ARMv6K Nintendo 3DS C Newlib definitions + +pub type c_char = u8; +pub type c_long = i32; +pub type c_ulong = u32; + +pub type wchar_t = ::c_uint; + +pub type u_register_t = ::c_uint; +pub type u_char = ::c_uchar; +pub type u_short = ::c_ushort; +pub type u_int = ::c_uint; +pub type u_long = c_ulong; +pub type ushort = ::c_ushort; +pub type uint = ::c_uint; +pub type ulong = c_ulong; +pub type clock_t = c_ulong; +pub type daddr_t = c_long; +pub type caddr_t = *mut c_char; +pub type sbintime_t = ::c_longlong; +pub type sigset_t = ::c_ulong; + +s! { + pub struct sockaddr { + pub sa_family: ::sa_family_t, + pub sa_data: [::c_char; 26usize], + } + + pub struct sockaddr_storage { + pub ss_family: ::sa_family_t, + pub __ss_padding: [::c_char; 26usize], + } + + pub struct sockaddr_in { + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + } + + pub struct sockaddr_in6 { + pub sin6_family: ::sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_un { + pub sun_len: ::c_uchar, + pub sun_family: ::sa_family_t, + pub sun_path: [::c_char; 104usize], + } + + pub struct sched_param { + pub sched_priority: ::c_int, + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_size: ::off_t, + pub st_atim: ::timespec, + pub st_mtim: ::timespec, + pub st_ctim: ::timespec, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt_t, + pub st_spare4: [::c_long; 2usize], + } +} + +pub const SIGEV_NONE: ::c_int = 1; +pub const SIGEV_SIGNAL: ::c_int = 2; +pub const SIGEV_THREAD: ::c_int = 3; +pub const SA_NOCLDSTOP: ::c_int = 1; +pub const MINSIGSTKSZ: ::c_int = 2048; +pub const SIGSTKSZ: ::c_int = 8192; +pub const SS_ONSTACK: ::c_int = 1; +pub const SS_DISABLE: ::c_int = 2; +pub const SIG_SETMASK: ::c_int = 0; +pub const SIG_BLOCK: ::c_int = 1; +pub const SIG_UNBLOCK: ::c_int = 2; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGTRAP: ::c_int = 5; +pub const SIGABRT: ::c_int = 6; +pub const SIGEMT: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGBUS: ::c_int = 10; +pub const SIGSEGV: ::c_int = 11; +pub const SIGSYS: ::c_int = 12; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; +pub const SIGURG: ::c_int = 16; +pub const SIGSTOP: ::c_int = 17; +pub const SIGTSTP: ::c_int = 18; +pub const SIGCONT: ::c_int = 19; +pub const SIGCHLD: ::c_int = 20; +pub const SIGCLD: ::c_int = 20; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGIO: ::c_int = 23; +pub const SIGPOLL: ::c_int = 23; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGLOST: ::c_int = 29; +pub const SIGUSR1: ::c_int = 30; +pub const SIGUSR2: ::c_int = 31; +pub const NSIG: ::c_int = 32; +pub const CLOCK_ENABLED: ::c_uint = 1; +pub const CLOCK_DISABLED: ::c_uint = 0; +pub const CLOCK_ALLOWED: ::c_uint = 1; +pub const CLOCK_DISALLOWED: ::c_uint = 0; +pub const TIMER_ABSTIME: ::c_uint = 4; +pub const SOL_SOCKET: ::c_int = 65535; +pub const MSG_OOB: ::c_int = 1; +pub const MSG_PEEK: ::c_int = 2; +pub const MSG_DONTWAIT: ::c_int = 4; +pub const MSG_DONTROUTE: ::c_int = 0; +pub const MSG_WAITALL: ::c_int = 0; +pub const MSG_MORE: ::c_int = 0; +pub const MSG_NOSIGNAL: ::c_int = 0; +pub const SOL_CONFIG: ::c_uint = 65534; + +pub const _SC_PAGESIZE: ::c_int = 8; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51; + +pub const PTHREAD_STACK_MIN: ::size_t = 4096; +pub const WNOHANG: ::c_int = 1; + +pub const POLLIN: ::c_short = 0x0001; +pub const POLLPRI: ::c_short = 0x0002; +pub const POLLOUT: ::c_short = 0x0004; +pub const POLLRDNORM: ::c_short = 0x0040; +pub const POLLWRNORM: ::c_short = POLLOUT; +pub const POLLRDBAND: ::c_short = 0x0080; +pub const POLLWRBAND: ::c_short = 0x0100; +pub const POLLERR: ::c_short = 0x0008; +pub const POLLHUP: ::c_short = 0x0010; +pub const POLLNVAL: ::c_short = 0x0020; + +pub const EAI_AGAIN: ::c_int = 2; +pub const EAI_BADFLAGS: ::c_int = 3; +pub const EAI_FAIL: ::c_int = 4; +pub const EAI_SERVICE: ::c_int = 9; +pub const EAI_SYSTEM: ::c_int = 11; +pub const EAI_BADHINTS: ::c_int = 12; +pub const EAI_PROTOCOL: ::c_int = 13; +pub const EAI_OVERFLOW: ::c_int = 14; +pub const EAI_MAX: ::c_int = 15; + +pub const AF_UNIX: ::c_int = 1; +pub const AF_INET6: ::c_int = 23; + +pub const FIONBIO: ::c_ulong = 1; + +pub const RTLD_DEFAULT: *mut ::c_void = 0 as *mut ::c_void; + +// For pthread get/setschedparam +pub const SCHED_FIFO: ::c_int = 1; +pub const SCHED_RR: ::c_int = 2; + +// For getrandom() +pub const GRND_NONBLOCK: ::c_uint = 0x1; +pub const GRND_RANDOM: ::c_uint = 0x2; + +// Horizon OS works doesn't or can't hold any of this information +safe_f! { + pub {const} fn WIFSTOPPED(_status: ::c_int) -> bool { + false + } + + pub {const} fn WSTOPSIG(_status: ::c_int) -> ::c_int { + 0 + } + + pub {const} fn WIFCONTINUED(_status: ::c_int) -> bool { + true + } + + pub {const} fn WIFSIGNALED(_status: ::c_int) -> bool { + false + } + + pub {const} fn WTERMSIG(_status: ::c_int) -> ::c_int { + 0 + } + + pub {const} fn WIFEXITED(_status: ::c_int) -> bool { + true + } + + pub {const} fn WEXITSTATUS(_status: ::c_int) -> ::c_int { + 0 + } + + pub {const} fn WCOREDUMP(_status: ::c_int) -> bool { + false + } +} + +extern "C" { + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(_: *mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + + pub fn pthread_attr_getschedparam( + attr: *const ::pthread_attr_t, + param: *mut sched_param, + ) -> ::c_int; + + pub fn pthread_attr_setschedparam( + attr: *mut ::pthread_attr_t, + param: *const sched_param, + ) -> ::c_int; + + pub fn pthread_attr_getprocessorid_np( + attr: *const ::pthread_attr_t, + processor_id: *mut ::c_int, + ) -> ::c_int; + + pub fn pthread_attr_setprocessorid_np( + attr: *mut ::pthread_attr_t, + processor_id: ::c_int, + ) -> ::c_int; + + pub fn pthread_getschedparam( + native: ::pthread_t, + policy: *mut ::c_int, + param: *mut ::sched_param, + ) -> ::c_int; + + pub fn pthread_setschedparam( + native: ::pthread_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + + pub fn pthread_condattr_getclock( + attr: *const ::pthread_condattr_t, + clock_id: *mut ::clockid_t, + ) -> ::c_int; + + pub fn pthread_condattr_setclock( + attr: *mut ::pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + + pub fn pthread_getprocessorid_np() -> ::c_int; + + pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; + + pub fn gethostid() -> ::c_long; +} diff -Nru cargo-0.58.0/vendor/libc/src/unix/newlib/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/newlib/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,28 +1,53 @@ pub type blkcnt_t = i32; pub type blksize_t = i32; pub type clockid_t = ::c_ulong; -pub type dev_t = u32; + +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub type dev_t = ::c_short; + pub type ino_t = ::c_ushort; + pub type off_t = ::c_long; + } else { + pub type dev_t = u32; + pub type ino_t = u32; + pub type off_t = i64; + } +} + pub type fsblkcnt_t = u64; pub type fsfilcnt_t = u32; pub type id_t = u32; -pub type ino_t = u32; pub type key_t = ::c_int; pub type loff_t = ::c_longlong; pub type mode_t = ::c_uint; pub type nfds_t = u32; pub type nlink_t = ::c_ushort; -pub type off_t = i64; pub type pthread_t = ::c_ulong; pub type pthread_key_t = ::c_uint; pub type rlim_t = u32; -pub type sa_family_t = u8; + +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub type sa_family_t = u16; + } else { + pub type sa_family_t = u8; + } +} + pub type socklen_t = u32; pub type speed_t = u32; pub type suseconds_t = i32; pub type tcflag_t = ::c_uint; -pub type time_t = i32; pub type useconds_t = u32; +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub type time_t = ::c_longlong; + } else { + pub type time_t = i32; + } +} + s! { // The order of the `ai_addr` field in this struct is crucial // for converting between the Rust and C types. @@ -114,26 +139,6 @@ pub tm_isdst: ::c_int, } - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - pub st_rdev: dev_t, - pub st_size: off_t, - pub st_atime: time_t, - pub st_spare1: ::c_long, - pub st_mtime: time_t, - pub st_spare2: ::c_long, - pub st_ctime: time_t, - pub st_spare3: ::c_long, - pub st_blksize: blksize_t, - pub st_blocks: blkcnt_t, - pub st_spare4: [::c_long; 2usize], - } - pub struct statvfs { pub f_bsize: ::c_ulong, pub f_frsize: ::c_ulong, @@ -148,10 +153,6 @@ pub f_namemax: ::c_ulong, } - pub struct sigset_t { - __val: [::c_ulong; 16], - } - pub struct sigaction { pub sa_handler: extern fn(arg1: ::c_int), pub sa_mask: sigset_t, @@ -268,7 +269,14 @@ pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; -pub const FD_SETSIZE: usize = 1024; + +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub const FD_SETSIZE: usize = 64; + } else { + pub const FD_SETSIZE: usize = 1024; + } +} // intentionally not public, only used for fd_set const ULONG_SIZE: usize = 32; @@ -477,7 +485,13 @@ pub const SO_RCVLOWAT: ::c_int = 0x1004; pub const SO_SNDTIMEO: ::c_int = 0x1005; pub const SO_RCVTIMEO: ::c_int = 0x1006; -pub const SO_ERROR: ::c_int = 0x1007; +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub const SO_ERROR: ::c_int = 0x1009; + } else { + pub const SO_ERROR: ::c_int = 0x1007; + } +} pub const SO_TYPE: ::c_int = 0x1008; pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; @@ -512,7 +526,13 @@ pub const TCP_KEEPINTVL: ::c_int = 512; pub const TCP_KEEPCNT: ::c_int = 1024; -pub const IP_TOS: ::c_int = 3; +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub const IP_TOS: ::c_int = 7; + } else { + pub const IP_TOS: ::c_int = 3; + } +} pub const IP_TTL: ::c_int = 8; pub const IP_MULTICAST_IF: ::c_int = 9; pub const IP_MULTICAST_TTL: ::c_int = 10; @@ -702,10 +722,15 @@ pub fn uname(buf: *mut ::utsname) -> ::c_int; } +mod generic; + cfg_if! { if #[cfg(target_os = "espidf")] { mod espidf; pub use self::espidf::*; + } else if #[cfg(target_os = "horizon")] { + mod horizon; + pub use self::horizon::*; } else if #[cfg(target_arch = "arm")] { mod arm; pub use self::arm::*; diff -Nru cargo-0.58.0/vendor/libc/src/unix/newlib/powerpc/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/powerpc/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/newlib/powerpc/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/newlib/powerpc/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -5,6 +5,8 @@ pub type c_long = i32; pub type c_ulong = u32; +pub use crate::unix::newlib::generic::{sigset_t, stat}; + // the newlib shipped with devkitPPC does not support the following components: // - sockaddr // - AF_INET6 diff -Nru cargo-0.58.0/vendor/libc/src/unix/redox/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/redox/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/redox/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/redox/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -151,12 +151,20 @@ } pub struct sigaction { - pub sa_handler: ::sighandler_t, + pub sa_sigaction: ::sighandler_t, pub sa_flags: ::c_ulong, pub sa_restorer: ::Option, pub sa_mask: ::sigset_t, } + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + _pad: [::c_int; 29], + _align: [usize; 0], + } + pub struct sockaddr { pub sa_family: ::sa_family_t, pub sa_data: [::c_char; 14], diff -Nru cargo-0.58.0/vendor/libc/src/unix/solarish/illumos.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/solarish/illumos.rs --- cargo-0.58.0/vendor/libc/src/unix/solarish/illumos.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/solarish/illumos.rs 2022-04-20 13:48:09.000000000 +0000 @@ -33,11 +33,14 @@ pub const TCP_KEEPINTVL: ::c_int = 36; pub const TCP_CONGESTION: ::c_int = 37; -pub const F_OFD_GETLK: ::c_int = 50; -pub const F_OFD_SETLKL: ::c_int = 51; -pub const F_OFD_SETLKW: ::c_int = 52; -pub const F_FLOCK: ::c_int = 55; -pub const F_FLOCKW: ::c_int = 56; +// These constants are correct for 64-bit programs or 32-bit programs that are +// not using large-file mode. If Rust ever supports anything other than 64-bit +// compilation on illumos, this may require adjustment: +pub const F_OFD_GETLK: ::c_int = 47; +pub const F_OFD_SETLK: ::c_int = 48; +pub const F_OFD_SETLKW: ::c_int = 49; +pub const F_FLOCK: ::c_int = 53; +pub const F_FLOCKW: ::c_int = 54; pub const FIL_ATTACH: ::c_int = 0x1; pub const FIL_DETACH: ::c_int = 0x2; @@ -50,6 +53,18 @@ pub const MR_HDR_AOUT: ::c_uint = 0x3; +pub const B1000000: ::speed_t = 24; +pub const B1152000: ::speed_t = 25; +pub const B1500000: ::speed_t = 26; +pub const B2000000: ::speed_t = 27; +pub const B2500000: ::speed_t = 28; +pub const B3000000: ::speed_t = 29; +pub const B3500000: ::speed_t = 30; +pub const B4000000: ::speed_t = 31; + +// sys/systeminfo.h +pub const SI_ADDRESS_WIDTH: ::c_int = 520; + extern "C" { pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; diff -Nru cargo-0.58.0/vendor/libc/src/unix/solarish/mod.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/solarish/mod.rs --- cargo-0.58.0/vendor/libc/src/unix/solarish/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/solarish/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -27,6 +27,8 @@ pub type zoneid_t = ::c_int; pub type psetid_t = ::c_int; pub type processorid_t = ::c_int; +pub type chipid_t = ::c_int; +pub type ctid_t = ::id_t; pub type suseconds_t = ::c_long; pub type off_t = ::c_long; @@ -43,6 +45,16 @@ pub type idtype_t = ::c_uint; pub type shmatt_t = ::c_ulong; +pub type lgrp_rsrc_t = ::c_int; +pub type lgrp_affinity_t = ::c_int; +pub type lgrp_id_t = ::id_t; +pub type lgrp_mem_size_t = ::c_longlong; +pub type lgrp_cookie_t = ::uintptr_t; +pub type lgrp_content_t = ::c_uint; +pub type lgrp_lat_between_t = ::c_uint; +pub type lgrp_mem_size_flag_t = ::c_uint; +pub type lgrp_view_t = ::c_uint; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} impl ::Copy for timezone {} @@ -71,6 +83,12 @@ pub imr_interface: in_addr, } + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_sourceaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct ipc_perm { pub uid: ::uid_t, pub gid: ::gid_t, @@ -429,11 +447,25 @@ pub struct mmapobj_result_t { pub mr_addr: ::caddr_t, pub mr_msize: ::size_t, - pub mr_fize: ::size_t, + pub mr_fsize: ::size_t, pub mr_offset: ::size_t, pub mr_prot: ::c_uint, pub mr_flags: ::c_uint, } + + pub struct lgrp_affinity_args { + pub idtype: ::idtype_t, + pub id: ::id_t, + pub lgrp: ::lgrp_id_t, + pub aff: ::lgrp_affinity_t, + } + + pub struct processor_info_t { + pub pi_state: ::c_int, + pub pi_processor_type: [::c_char; PI_TYPELEN as usize], + pub pi_fputypes: [::c_char; PI_FPUTYPE as usize], + pub pi_clock: ::c_int, + } } s_no_extra_traits! { @@ -491,13 +523,15 @@ __ss_pad2: [u8; 240], } + #[cfg_attr(all(target_pointer_width = "64", libc_align), repr(align(8)))] pub struct siginfo_t { pub si_signo: ::c_int, pub si_code: ::c_int, pub si_errno: ::c_int, + #[cfg(target_pointer_width = "64")] pub si_pad: ::c_int, - pub si_addr: *mut ::c_void, - __pad: [u8; 232], + + __data_pad: [::c_int; SIGINFO_DATA_SIZE], } pub struct sockaddr_dl { @@ -520,14 +554,16 @@ } #[cfg(libc_union)] + #[cfg_attr(libc_align, repr(align(16)))] pub union pad128_t { - pub _q: ::c_double, + // pub _q in this structure would be a "long double", of 16 bytes pub _l: [i32; 4], } #[cfg(libc_union)] + #[cfg_attr(libc_align, repr(align(16)))] pub union upad128_t { - pub _q: ::c_double, + // pub _q in this structure would be a "long double", of 16 bytes pub _l: [u32; 4], } } @@ -746,17 +782,52 @@ } } + impl siginfo_t { + /// The siginfo_t will have differing contents based on the delivered signal. Based on + /// `si_signo`, this determines how many of the `c_int` pad fields contain valid data + /// exposed by the C unions. + /// + /// It is not yet exhausitive for the OS-defined types, and defaults to assuming the + /// entire data pad area is "valid" for otherwise unrecognized signal numbers. + fn data_field_count(&self) -> usize { + match self.si_signo { + ::SIGSEGV | ::SIGBUS | ::SIGILL | ::SIGTRAP | ::SIGFPE => { + ::mem::size_of::() / ::mem::size_of::<::c_int>() + } + ::SIGCLD => ::mem::size_of::() / ::mem::size_of::<::c_int>(), + ::SIGHUP + | ::SIGINT + | ::SIGQUIT + | ::SIGABRT + | ::SIGSYS + | ::SIGPIPE + | ::SIGALRM + | ::SIGTERM + | ::SIGUSR1 + | ::SIGUSR2 + | ::SIGPWR + | ::SIGWINCH + | ::SIGURG => ::mem::size_of::() / ::mem::size_of::<::c_int>(), + _ => SIGINFO_DATA_SIZE, + } + } + } impl PartialEq for siginfo_t { fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo + if self.si_signo == other.si_signo && self.si_code == other.si_code - && self.si_errno == other.si_errno - && self.si_addr == other.si_addr - && self - .__pad - .iter() - .zip(other.__pad.iter()) - .all(|(a, b)| a == b) + && self.si_errno == other.si_errno { + // FIXME: The `si_pad` field in the 64-bit version of the struct is ignored + // (for now) when doing comparisons. + + let field_count = self.data_field_count(); + self.__data_pad[..field_count] + .iter() + .zip(other.__data_pad[..field_count].iter()) + .all(|(a, b)| a == b) + } else { + false + } } } impl Eq for siginfo_t {} @@ -766,7 +837,6 @@ .field("si_signo", &self.si_signo) .field("si_code", &self.si_code) .field("si_errno", &self.si_errno) - .field("si_addr", &self.si_addr) // FIXME: .field("__pad", &self.__pad) .finish() } @@ -776,8 +846,12 @@ self.si_signo.hash(state); self.si_code.hash(state); self.si_errno.hash(state); - self.si_addr.hash(state); - self.__pad.hash(state); + + // FIXME: The `si_pad` field in the 64-bit version of the struct is ignored + // (for now) when doing hashing. + + let field_count = self.data_field_count(); + self.__data_pad[..field_count].hash(state) } } @@ -859,7 +933,7 @@ impl PartialEq for pad128_t { fn eq(&self, other: &pad128_t) -> bool { unsafe { - self._q == other._q || + // FIXME: self._q == other._q || self._l == other._l } } @@ -871,7 +945,7 @@ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { f.debug_struct("pad128_t") - .field("_q", &{self._q}) + // FIXME: .field("_q", &{self._q}) .field("_l", &{self._l}) .finish() } @@ -881,7 +955,7 @@ impl ::hash::Hash for pad128_t { fn hash(&self, state: &mut H) { unsafe { - state.write_i64(self._q as i64); + // FIXME: state.write_i64(self._q as i64); self._l.hash(state); } } @@ -890,7 +964,7 @@ impl PartialEq for upad128_t { fn eq(&self, other: &upad128_t) -> bool { unsafe { - self._q == other._q || + // FIXME: self._q == other._q || self._l == other._l } } @@ -902,7 +976,7 @@ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { f.debug_struct("upad128_t") - .field("_q", &{self._q}) + // FIXME: .field("_q", &{self._q}) .field("_l", &{self._l}) .finish() } @@ -912,7 +986,7 @@ impl ::hash::Hash for upad128_t { fn hash(&self, state: &mut H) { unsafe { - state.write_i64(self._q as i64); + // FIXME: state.write_i64(self._q as i64); self._l.hash(state); } } @@ -920,6 +994,116 @@ } } +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + const SIGINFO_DATA_SIZE: usize = 60; + } else { + const SIGINFO_DATA_SIZE: usize = 29; + } +} + +#[repr(C)] +struct siginfo_fault { + addr: *mut ::c_void, + trapno: ::c_int, + pc: *mut ::caddr_t, +} +impl ::Copy for siginfo_fault {} +impl ::Clone for siginfo_fault { + fn clone(&self) -> Self { + *self + } +} + +#[repr(C)] +struct siginfo_cldval { + utime: ::clock_t, + status: ::c_int, + stime: ::clock_t, +} +impl ::Copy for siginfo_cldval {} +impl ::Clone for siginfo_cldval { + fn clone(&self) -> Self { + *self + } +} + +#[repr(C)] +struct siginfo_killval { + uid: ::uid_t, + value: ::sigval, + // Pad out to match the SIGCLD value size + _pad: *mut ::c_void, +} +impl ::Copy for siginfo_killval {} +impl ::Clone for siginfo_killval { + fn clone(&self) -> Self { + *self + } +} + +#[repr(C)] +struct siginfo_sigcld { + pid: ::pid_t, + val: siginfo_cldval, + ctid: ::ctid_t, + zoneid: ::zoneid_t, +} +impl ::Copy for siginfo_sigcld {} +impl ::Clone for siginfo_sigcld { + fn clone(&self) -> Self { + *self + } +} + +#[repr(C)] +struct siginfo_kill { + pid: ::pid_t, + val: siginfo_killval, + ctid: ::ctid_t, + zoneid: ::zoneid_t, +} +impl ::Copy for siginfo_kill {} +impl ::Clone for siginfo_kill { + fn clone(&self) -> Self { + *self + } +} + +impl siginfo_t { + unsafe fn sidata(&self) -> T { + *((&self.__data_pad) as *const ::c_int as *const T) + } + pub unsafe fn si_addr(&self) -> *mut ::c_void { + let sifault: siginfo_fault = self.sidata(); + sifault.addr + } + pub unsafe fn si_uid(&self) -> ::uid_t { + let kill: siginfo_kill = self.sidata(); + kill.val.uid + } + pub unsafe fn si_value(&self) -> ::sigval { + let kill: siginfo_kill = self.sidata(); + kill.val.value + } + pub unsafe fn si_pid(&self) -> ::pid_t { + let sigcld: siginfo_sigcld = self.sidata(); + sigcld.pid + } + pub unsafe fn si_status(&self) -> ::c_int { + let sigcld: siginfo_sigcld = self.sidata(); + sigcld.val.status + } + pub unsafe fn si_utime(&self) -> ::c_long { + let sigcld: siginfo_sigcld = self.sidata(); + sigcld.val.utime + } + pub unsafe fn si_stime(&self) -> ::c_long { + let sigcld: siginfo_sigcld = self.sidata(); + sigcld.val.stime + } +} + pub const LC_CTYPE: ::c_int = 0; pub const LC_NUMERIC: ::c_int = 1; pub const LC_TIME: ::c_int = 2; @@ -1028,6 +1212,7 @@ pub const FIOGETOWN: ::c_int = 0x4004667b; pub const SIGCHLD: ::c_int = 18; +pub const SIGCLD: ::c_int = ::SIGCHLD; pub const SIGBUS: ::c_int = 10; pub const SIGINFO: ::c_int = 41; pub const SIG_BLOCK: ::c_int = 1; @@ -1038,6 +1223,13 @@ pub const SIGEV_SIGNAL: ::c_int = 2; pub const SIGEV_THREAD: ::c_int = 3; +pub const CLD_EXITED: ::c_int = 1; +pub const CLD_KILLED: ::c_int = 2; +pub const CLD_DUMPED: ::c_int = 3; +pub const CLD_TRAPPED: ::c_int = 4; +pub const CLD_STOPPED: ::c_int = 5; +pub const CLD_CONTINUED: ::c_int = 6; + pub const IP_RECVDSTADDR: ::c_int = 0x7; pub const IP_SEC_OPT: ::c_int = 0x22; @@ -1061,6 +1253,7 @@ pub const ST_NOSUID: ::c_ulong = 2; pub const NI_MAXHOST: ::socklen_t = 1025; +pub const NI_MAXSERV: ::socklen_t = 32; pub const EXIT_FAILURE: ::c_int = 1; pub const EXIT_SUCCESS: ::c_int = 0; @@ -1144,6 +1337,14 @@ pub const F_BLKSIZE: ::c_int = 19; pub const F_SHARE: ::c_int = 40; pub const F_UNSHARE: ::c_int = 41; +pub const F_ISSTREAM: ::c_int = 13; +pub const F_PRIV: ::c_int = 15; +pub const F_NPRIV: ::c_int = 16; +pub const F_QUOTACTL: ::c_int = 17; +pub const F_GETOWN: ::c_int = 23; +pub const F_SETOWN: ::c_int = 24; +pub const F_REVOKE: ::c_int = 25; +pub const F_HASREMOTELOCKS: ::c_int = 26; pub const SIGHUP: ::c_int = 1; pub const SIGINT: ::c_int = 2; pub const SIGQUIT: ::c_int = 3; @@ -1217,7 +1418,7 @@ pub const PS_MYID: ::c_int = -3; pub const PS_SOFT: ::c_int = -4; pub const PS_HARD: ::c_int = -5; -pub const PS_QUERY_TIME: ::c_int = -6; +pub const PS_QUERY_TYPE: ::c_int = -6; pub const PS_SYSTEM: ::c_int = 1; pub const PS_PRIVATE: ::c_int = 2; @@ -1390,6 +1591,14 @@ pub const EAI_SYSTEM: ::c_int = 11; pub const EAI_OVERFLOW: ::c_int = 12; +pub const NI_NOFQDN: ::c_uint = 0x0001; +pub const NI_NUMERICHOST: ::c_uint = 0x0002; +pub const NI_NAMEREQD: ::c_uint = 0x0004; +pub const NI_NUMERICSERV: ::c_uint = 0x0008; +pub const NI_DGRAM: ::c_uint = 0x0010; +pub const NI_WITHSCOPEID: ::c_uint = 0x0020; +pub const NI_NUMERICSCOPE: ::c_uint = 0x0040; + pub const F_DUPFD: ::c_int = 0; pub const F_DUP2FD: ::c_int = 9; pub const F_DUP2FD_CLOEXEC: ::c_int = 36; @@ -1511,6 +1720,42 @@ pub const AF_TRILL: ::c_int = 31; pub const AF_PACKET: ::c_int = 32; +pub const PF_UNSPEC: ::c_int = AF_UNSPEC; +pub const PF_UNIX: ::c_int = AF_UNIX; +pub const PF_LOCAL: ::c_int = PF_UNIX; +pub const PF_FILE: ::c_int = PF_UNIX; +pub const PF_INET: ::c_int = AF_INET; +pub const PF_IMPLINK: ::c_int = AF_IMPLINK; +pub const PF_PUP: ::c_int = AF_PUP; +pub const PF_CHAOS: ::c_int = AF_CHAOS; +pub const PF_NS: ::c_int = AF_NS; +pub const PF_NBS: ::c_int = AF_NBS; +pub const PF_ECMA: ::c_int = AF_ECMA; +pub const PF_DATAKIT: ::c_int = AF_DATAKIT; +pub const PF_CCITT: ::c_int = AF_CCITT; +pub const PF_SNA: ::c_int = AF_SNA; +pub const PF_DECnet: ::c_int = AF_DECnet; +pub const PF_DLI: ::c_int = AF_DLI; +pub const PF_LAT: ::c_int = AF_LAT; +pub const PF_HYLINK: ::c_int = AF_HYLINK; +pub const PF_APPLETALK: ::c_int = AF_APPLETALK; +pub const PF_NIT: ::c_int = AF_NIT; +pub const PF_802: ::c_int = AF_802; +pub const PF_OSI: ::c_int = AF_OSI; +pub const PF_X25: ::c_int = AF_X25; +pub const PF_OSINET: ::c_int = AF_OSINET; +pub const PF_GOSIP: ::c_int = AF_GOSIP; +pub const PF_IPX: ::c_int = AF_IPX; +pub const PF_ROUTE: ::c_int = AF_ROUTE; +pub const PF_LINK: ::c_int = AF_LINK; +pub const PF_INET6: ::c_int = AF_INET6; +pub const PF_KEY: ::c_int = AF_KEY; +pub const PF_NCA: ::c_int = AF_NCA; +pub const PF_POLICY: ::c_int = AF_POLICY; +pub const PF_INET_OFFLOAD: ::c_int = AF_INET_OFFLOAD; +pub const PF_TRILL: ::c_int = AF_TRILL; +pub const PF_PACKET: ::c_int = AF_PACKET; + pub const SOCK_DGRAM: ::c_int = 1; pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_RAW: ::c_int = 4; @@ -1525,6 +1770,10 @@ pub const IP_DROP_MEMBERSHIP: ::c_int = 20; pub const IPV6_JOIN_GROUP: ::c_int = 9; pub const IPV6_LEAVE_GROUP: ::c_int = 10; +pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 23; +pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 24; +pub const IP_BLOCK_SOURCE: ::c_int = 21; +pub const IP_UNBLOCK_SOURCE: ::c_int = 22; // These TCP socket options are common between illumos and Solaris, while higher // numbers have generally diverged: @@ -2055,6 +2304,10 @@ pub const CSTART: ::tcflag_t = 0o21; pub const CSTOP: ::tcflag_t = 0o23; pub const CSWTCH: ::tcflag_t = 0o32; +pub const CBAUD: ::tcflag_t = 0o17; +pub const CIBAUD: ::tcflag_t = 0o3600000; +pub const CBAUDEXT: ::tcflag_t = 0o10000000; +pub const CIBAUDEXT: ::tcflag_t = 0o20000000; pub const CSIZE: ::tcflag_t = 0o000060; pub const CS5: ::tcflag_t = 0; pub const CS6: ::tcflag_t = 0o000020; @@ -2078,20 +2331,26 @@ pub const INLCR: ::tcflag_t = 0o000100; pub const IGNCR: ::tcflag_t = 0o000200; pub const ICRNL: ::tcflag_t = 0o000400; +pub const IUCLC: ::tcflag_t = 0o001000; pub const IXON: ::tcflag_t = 0o002000; pub const IXOFF: ::tcflag_t = 0o010000; pub const IXANY: ::tcflag_t = 0o004000; pub const IMAXBEL: ::tcflag_t = 0o020000; +pub const DOSMODE: ::tcflag_t = 0o100000; pub const OPOST: ::tcflag_t = 0o000001; +pub const OLCUC: ::tcflag_t = 0o000002; pub const ONLCR: ::tcflag_t = 0o000004; pub const OCRNL: ::tcflag_t = 0o000010; pub const ONOCR: ::tcflag_t = 0o000020; pub const ONLRET: ::tcflag_t = 0o000040; +pub const OFILL: ::tcflag_t = 0o0000100; +pub const OFDEL: ::tcflag_t = 0o0000200; pub const CREAD: ::tcflag_t = 0o000200; pub const PARENB: ::tcflag_t = 0o000400; pub const PARODD: ::tcflag_t = 0o001000; pub const HUPCL: ::tcflag_t = 0o002000; pub const CLOCAL: ::tcflag_t = 0o004000; +pub const CRTSXOFF: ::tcflag_t = 0o10000000000; pub const CRTSCTS: ::tcflag_t = 0o20000000000; pub const ISIG: ::tcflag_t = 0o000001; pub const ICANON: ::tcflag_t = 0o000002; @@ -2233,6 +2492,69 @@ pub const NET_MAC_AWARE: ::c_uint = 0x0010; pub const NET_MAC_AWARE_INHERIT: ::c_uint = 0x0020; pub const PRIV_AWARE_RESET: ::c_uint = 0x0040; +pub const PRIV_XPOLICY: ::c_uint = 0x0080; +pub const PRIV_PFEXEC: ::c_uint = 0x0100; +pub const PRIV_USER: ::c_uint = PRIV_DEBUG + | NET_MAC_AWARE + | NET_MAC_AWARE_INHERIT + | PRIV_XPOLICY + | PRIV_AWARE_RESET + | PRIV_PFEXEC; + +// sys/systeminfo.h +pub const SI_SYSNAME: ::c_int = 1; +pub const SI_HOSTNAME: ::c_int = 2; +pub const SI_RELEASE: ::c_int = 3; +pub const SI_VERSION: ::c_int = 4; +pub const SI_MACHINE: ::c_int = 5; +pub const SI_ARCHITECTURE: ::c_int = 6; +pub const SI_HW_SERIAL: ::c_int = 7; +pub const SI_HW_PROVIDER: ::c_int = 8; +pub const SI_SET_HOSTNAME: ::c_int = 258; +pub const SI_SET_SRPC_DOMAIN: ::c_int = 265; +pub const SI_PLATFORM: ::c_int = 513; +pub const SI_ISALIST: ::c_int = 514; +pub const SI_DHCP_CACHE: ::c_int = 515; +pub const SI_ARCHITECTURE_32: ::c_int = 516; +pub const SI_ARCHITECTURE_64: ::c_int = 517; +pub const SI_ARCHITECTURE_K: ::c_int = 518; +pub const SI_ARCHITECTURE_NATIVE: ::c_int = 519; + +// sys/lgrp_user.h +pub const LGRP_COOKIE_NONE: ::lgrp_cookie_t = 0; +pub const LGRP_AFF_NONE: ::lgrp_affinity_t = 0x0; +pub const LGRP_AFF_WEAK: ::lgrp_affinity_t = 0x10; +pub const LGRP_AFF_STRONG: ::lgrp_affinity_t = 0x100; +pub const LGRP_RSRC_COUNT: ::lgrp_rsrc_t = 2; +pub const LGRP_RSRC_CPU: ::lgrp_rsrc_t = 0; +pub const LGRP_RSRC_MEM: ::lgrp_rsrc_t = 1; +pub const LGRP_CONTENT_ALL: ::lgrp_content_t = 0; +pub const LGRP_CONTENT_HIERARCHY: ::lgrp_content_t = LGRP_CONTENT_ALL; +pub const LGRP_CONTENT_DIRECT: ::lgrp_content_t = 1; +pub const LGRP_LAT_CPU_TO_MEM: ::lgrp_lat_between_t = 0; +pub const LGRP_MEM_SZ_FREE: ::lgrp_mem_size_flag_t = 0; +pub const LGRP_MEM_SZ_INSTALLED: ::lgrp_mem_size_flag_t = 1; +pub const LGRP_VIEW_CALLER: ::lgrp_view_t = 0; +pub const LGRP_VIEW_OS: ::lgrp_view_t = 1; + +// sys/processor.h + +pub const P_OFFLINE: ::c_int = 0x001; +pub const P_ONLINE: ::c_int = 0x002; +pub const P_STATUS: ::c_int = 0x003; +pub const P_FAULTED: ::c_int = 0x004; +pub const P_POWEROFF: ::c_int = 0x005; +pub const P_NOINTR: ::c_int = 0x006; +pub const P_SPARE: ::c_int = 0x007; +pub const P_DISABLED: ::c_int = 0x008; +pub const P_FORCED: ::c_int = 0x10000000; +pub const PI_TYPELEN: ::c_int = 16; +pub const PI_FPUTYPE: ::c_int = 32; + +// sys/auxv.h +pub const AT_SUN_HWCAP: ::c_uint = 2009; +pub const AT_SUN_HWCAP2: ::c_uint = 2023; +pub const AT_SUN_FPTYPE: ::c_uint = 2027; // As per sys/socket.h, header alignment must be 8 bytes on SPARC // and 4 bytes everywhere else: @@ -2801,15 +3123,20 @@ old_binding: *mut processorid_t, ) -> ::c_int; pub fn p_online(processorid: ::processorid_t, flag: ::c_int) -> ::c_int; + pub fn processor_info(processorid: ::processorid_t, infop: *mut processor_info_t) -> ::c_int; pub fn getexecname() -> *const ::c_char; pub fn gethostid() -> ::c_long; - pub fn sethostid(hostid: ::c_long) -> ::c_int; pub fn getpflags(flags: ::c_uint) -> ::c_uint; pub fn setpflags(flags: ::c_uint, value: ::c_uint) -> ::c_int; + pub fn sysinfo(command: ::c_int, buf: *mut ::c_char, count: ::c_long) -> ::c_int; +} + +#[link(name = "sendfile")] +extern "C" { pub fn sendfile(out_fd: ::c_int, in_fd: ::c_int, off: *mut ::off_t, len: ::size_t) -> ::ssize_t; pub fn sendfilev( @@ -2818,6 +3145,18 @@ sfvcnt: ::c_int, xferred: *mut ::size_t, ) -> ::ssize_t; + // #include + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + pub fn dl_iterate_phdr( + callback: ::Option< + unsafe extern "C" fn( + info: *mut dl_phdr_info, + size: usize, + data: *mut ::c_void, + ) -> ::c_int, + >, + data: *mut ::c_void, + ) -> ::c_int; pub fn getpagesize() -> ::c_int; pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int; pub fn mmapobj( @@ -2844,6 +3183,54 @@ loc: ::locale_t, ) -> ::c_int; pub fn strsep(string: *mut *mut ::c_char, delim: *const ::c_char) -> *mut ::c_char; + + pub fn getisax(array: *mut u32, n: ::c_uint) -> ::c_uint; + + pub fn backtrace(buffer: *mut *mut ::c_void, size: ::c_int) -> ::c_int; + pub fn backtrace_symbols(buffer: *const *mut ::c_void, size: ::c_int) -> *mut *mut ::c_char; + pub fn backtrace_symbols_fd(buffer: *const *mut ::c_void, size: ::c_int, fd: ::c_int); +} + +#[link(name = "lgrp")] +extern "C" { + pub fn lgrp_init(view: lgrp_view_t) -> lgrp_cookie_t; + pub fn lgrp_fini(cookie: lgrp_cookie_t) -> ::c_int; + pub fn lgrp_affinity_get( + idtype: ::idtype_t, + id: ::id_t, + lgrp: ::lgrp_id_t, + ) -> ::lgrp_affinity_t; + pub fn lgrp_affinity_set( + idtype: ::idtype_t, + id: ::id_t, + lgrp: ::lgrp_id_t, + aff: lgrp_affinity_t, + ) -> ::lgrp_affinity_t; + pub fn lgrp_cpus( + cookie: ::lgrp_cookie_t, + lgrp: ::lgrp_id_t, + cpuids: *mut ::processorid_t, + count: ::c_uint, + content: ::lgrp_content_t, + ) -> ::c_int; + pub fn lgrp_mem_size( + cookie: ::lgrp_cookie_t, + lgrp: ::lgrp_id_t, + tpe: ::lgrp_mem_size_flag_t, + content: ::lgrp_content_t, + ) -> ::lgrp_mem_size_t; + pub fn lgrp_nlgrps(cookie: ::lgrp_cookie_t) -> ::c_int; + pub fn lgrp_view(cookie: ::lgrp_cookie_t) -> ::lgrp_view_t; + pub fn lgrp_home(idtype: ::idtype_t, id: ::id_t) -> ::lgrp_id_t; + pub fn lgrp_version(version: ::c_int) -> ::c_int; + pub fn lgrp_resources( + cookie: ::lgrp_cookie_t, + lgrp: ::lgrp_id_t, + lgrps: *mut ::lgrp_id_t, + count: ::c_uint, + tpe: ::lgrp_rsrc_t, + ) -> ::c_int; + pub fn lgrp_root(cookie: ::lgrp_cookie_t) -> ::lgrp_id_t; } mod compat; @@ -2864,6 +3251,13 @@ cfg_if! { if #[cfg(target_arch = "x86_64")] { mod x86_64; + mod x86_common; pub use self::x86_64::*; + pub use self::x86_common::*; + } else if #[cfg(target_arch = "x86")] { + mod x86; + mod x86_common; + pub use self::x86::*; + pub use self::x86_common::*; } } diff -Nru cargo-0.58.0/vendor/libc/src/unix/solarish/x86_64.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/solarish/x86_64.rs --- cargo-0.58.0/vendor/libc/src/unix/solarish/x86_64.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/solarish/x86_64.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,5 +1,15 @@ pub type greg_t = ::c_long; +pub type Elf64_Addr = ::c_ulong; +pub type Elf64_Half = ::c_ushort; +pub type Elf64_Off = ::c_ulong; +pub type Elf64_Sword = ::c_int; +pub type Elf64_Sxword = ::c_long; +pub type Elf64_Word = ::c_uint; +pub type Elf64_Xword = ::c_ulong; +pub type Elf64_Lword = ::c_ulong; +pub type Elf64_Phdr = __c_anonymous_Elf64_Phdr; + s! { pub struct __c_anonymous_fpchip_state { pub cw: u16, @@ -17,6 +27,26 @@ pub status: u32, pub xstatus: u32, } + + pub struct __c_anonymous_Elf64_Phdr { + pub p_type: ::Elf64_Word, + pub p_flags: ::Elf64_Word, + pub p_offset: ::Elf64_Off, + pub p_vaddr: ::Elf64_Addr, + pub p_paddr: ::Elf64_Addr, + pub p_filesz: ::Elf64_Xword, + pub p_memsz: ::Elf64_Xword, + pub p_align: ::Elf64_Xword, + } + + pub struct dl_phdr_info { + pub dlpi_addr: ::Elf64_Addr, + pub dlpi_name: *const ::c_char, + pub dlpi_phdr: *const ::Elf64_Phdr, + pub dlpi_phnum: ::Elf64_Half, + pub dlpi_adds: ::c_ulonglong, + pub dlpi_subs: ::c_ulonglong, + } } s_no_extra_traits! { @@ -32,7 +62,7 @@ pub struct mcontext_t { pub gregs: [::greg_t; 28], - pub fpgregs: fpregset_t, + pub fpregs: fpregset_t, } pub struct ucontext_t { @@ -89,7 +119,7 @@ impl PartialEq for mcontext_t { fn eq(&self, other: &mcontext_t) -> bool { self.gregs == other.gregs && - self.fpgregs == other.fpgregs + self.fpregs == other.fpregs } } impl Eq for mcontext_t {} @@ -97,7 +127,7 @@ fn fmt(&self, f:&mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("mcontext_t") .field("gregs", &self.gregs) - .field("fpgregs", &self.fpgregs) + .field("fpregs", &self.fpregs) .finish() } } diff -Nru cargo-0.58.0/vendor/libc/src/unix/solarish/x86_common.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/solarish/x86_common.rs --- cargo-0.58.0/vendor/libc/src/unix/solarish/x86_common.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/solarish/x86_common.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,65 @@ +// AT_SUN_HWCAP +pub const AV_386_FPU: u32 = 0x00001; +pub const AV_386_TSC: u32 = 0x00002; +pub const AV_386_CX8: u32 = 0x00004; +pub const AV_386_SEP: u32 = 0x00008; +pub const AV_386_AMD_SYSC: u32 = 0x00010; +pub const AV_386_CMOV: u32 = 0x00020; +pub const AV_386_MMX: u32 = 0x00040; +pub const AV_386_AMD_MMX: u32 = 0x00080; +pub const AV_386_AMD_3DNow: u32 = 0x00100; +pub const AV_386_AMD_3DNowx: u32 = 0x00200; +pub const AV_386_FXSR: u32 = 0x00400; +pub const AV_386_SSE: u32 = 0x00800; +pub const AV_386_SSE2: u32 = 0x01000; +pub const AV_386_CX16: u32 = 0x10000; +pub const AV_386_AHF: u32 = 0x20000; +pub const AV_386_TSCP: u32 = 0x40000; +pub const AV_386_AMD_SSE4A: u32 = 0x80000; +pub const AV_386_POPCNT: u32 = 0x100000; +pub const AV_386_AMD_LZCNT: u32 = 0x200000; +pub const AV_386_SSSE3: u32 = 0x400000; +pub const AV_386_SSE4_1: u32 = 0x800000; +pub const AV_386_SSE4_2: u32 = 0x1000000; +pub const AV_386_MOVBE: u32 = 0x2000000; +pub const AV_386_AES: u32 = 0x4000000; +pub const AV_386_PCLMULQDQ: u32 = 0x8000000; +pub const AV_386_XSAVE: u32 = 0x10000000; +pub const AV_386_AVX: u32 = 0x20000000; +pub const AV_386_VMX: u32 = 0x40000000; +pub const AV_386_AMD_SVM: u32 = 0x80000000; +// AT_SUN_HWCAP2 +pub const AV_386_2_F16C: u32 = 0x00000001; +pub const AV_386_2_RDRAND: u32 = 0x00000002; +pub const AV_386_2_BMI1: u32 = 0x00000004; +pub const AV_386_2_BMI2: u32 = 0x00000008; +pub const AV_386_2_FMA: u32 = 0x00000010; +pub const AV_386_2_AVX2: u32 = 0x00000020; +pub const AV_386_2_ADX: u32 = 0x00000040; +pub const AV_386_2_RDSEED: u32 = 0x00000080; +pub const AV_386_2_AVX512F: u32 = 0x00000100; +pub const AV_386_2_AVX512DQ: u32 = 0x00000200; +pub const AV_386_2_AVX512IFMA: u32 = 0x00000400; +pub const AV_386_2_AVX512PF: u32 = 0x00000800; +pub const AV_386_2_AVX512ER: u32 = 0x00001000; +pub const AV_386_2_AVX512CD: u32 = 0x00002000; +pub const AV_386_2_AVX512BW: u32 = 0x00004000; +pub const AV_386_2_AVX512VL: u32 = 0x00008000; +pub const AV_386_2_AVX512VBMI: u32 = 0x00010000; +pub const AV_386_2_AVX512VPOPCDQ: u32 = 0x00020000; +pub const AV_386_2_AVX512_4NNIW: u32 = 0x00040000; +pub const AV_386_2_AVX512_4FMAPS: u32 = 0x00080000; +pub const AV_386_2_SHA: u32 = 0x00100000; +pub const AV_386_2_FSGSBASE: u32 = 0x00200000; +pub const AV_386_2_CLFLUSHOPT: u32 = 0x00400000; +pub const AV_386_2_CLWB: u32 = 0x00800000; +pub const AV_386_2_MONITORX: u32 = 0x01000000; +pub const AV_386_2_CLZERO: u32 = 0x02000000; +pub const AV_386_2_AVX512_VNNI: u32 = 0x04000000; +pub const AV_386_2_VPCLMULQDQ: u32 = 0x08000000; +pub const AV_386_2_VAES: u32 = 0x10000000; +// AT_SUN_FPTYPE +pub const AT_386_FPINFO_NONE: u32 = 0; +pub const AT_386_FPINFO_FXSAVE: u32 = 1; +pub const AT_386_FPINFO_XSAVE: u32 = 2; +pub const AT_386_FPINFO_XSAVE_AMD: u32 = 3; diff -Nru cargo-0.58.0/vendor/libc/src/unix/solarish/x86.rs cargo-0.60.0ubuntu1/vendor/libc/src/unix/solarish/x86.rs --- cargo-0.58.0/vendor/libc/src/unix/solarish/x86.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/unix/solarish/x86.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,29 @@ +pub type Elf32_Addr = ::c_ulong; +pub type Elf32_Half = ::c_ushort; +pub type Elf32_Off = ::c_ulong; +pub type Elf32_Sword = ::c_long; +pub type Elf32_Word = ::c_ulong; +pub type Elf32_Lword = ::c_ulonglong; +pub type Elf32_Phdr = __c_anonymous_Elf32_Phdr; + +s! { + pub struct __c_anonymous_Elf32_Phdr { + pub p_type: ::Elf32_Word, + pub p_offset: ::Elf32_Off, + pub p_vaddr: ::Elf32_Addr, + pub p_paddr: ::Elf32_Addr, + pub p_filesz: ::Elf32_Word, + pub p_memsz: ::Elf32_Word, + pub p_flags: ::Elf32_Word, + pub p_align: ::Elf32_Word, + } + + pub struct dl_phdr_info { + pub dlpi_addr: ::Elf32_Addr, + pub dlpi_name: *const ::c_char, + pub dlpi_phdr: *const ::Elf32_Phdr, + pub dlpi_phnum: ::Elf32_Half, + pub dlpi_adds: ::c_ulonglong, + pub dlpi_subs: ::c_ulonglong, + } +} diff -Nru cargo-0.58.0/vendor/libc/src/wasi.rs cargo-0.60.0ubuntu1/vendor/libc/src/wasi.rs --- cargo-0.58.0/vendor/libc/src/wasi.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libc/src/wasi.rs 2022-04-20 13:48:09.000000000 +0000 @@ -38,6 +38,7 @@ pub type blkcnt_t = i64; pub type nfds_t = c_ulong; pub type wchar_t = i32; +pub type nl_item = c_int; s_no_extra_traits! { #[repr(align(16))] @@ -369,6 +370,71 @@ pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; +pub const ABDAY_1: ::nl_item = 0x20000; +pub const ABDAY_2: ::nl_item = 0x20001; +pub const ABDAY_3: ::nl_item = 0x20002; +pub const ABDAY_4: ::nl_item = 0x20003; +pub const ABDAY_5: ::nl_item = 0x20004; +pub const ABDAY_6: ::nl_item = 0x20005; +pub const ABDAY_7: ::nl_item = 0x20006; + +pub const DAY_1: ::nl_item = 0x20007; +pub const DAY_2: ::nl_item = 0x20008; +pub const DAY_3: ::nl_item = 0x20009; +pub const DAY_4: ::nl_item = 0x2000A; +pub const DAY_5: ::nl_item = 0x2000B; +pub const DAY_6: ::nl_item = 0x2000C; +pub const DAY_7: ::nl_item = 0x2000D; + +pub const ABMON_1: ::nl_item = 0x2000E; +pub const ABMON_2: ::nl_item = 0x2000F; +pub const ABMON_3: ::nl_item = 0x20010; +pub const ABMON_4: ::nl_item = 0x20011; +pub const ABMON_5: ::nl_item = 0x20012; +pub const ABMON_6: ::nl_item = 0x20013; +pub const ABMON_7: ::nl_item = 0x20014; +pub const ABMON_8: ::nl_item = 0x20015; +pub const ABMON_9: ::nl_item = 0x20016; +pub const ABMON_10: ::nl_item = 0x20017; +pub const ABMON_11: ::nl_item = 0x20018; +pub const ABMON_12: ::nl_item = 0x20019; + +pub const MON_1: ::nl_item = 0x2001A; +pub const MON_2: ::nl_item = 0x2001B; +pub const MON_3: ::nl_item = 0x2001C; +pub const MON_4: ::nl_item = 0x2001D; +pub const MON_5: ::nl_item = 0x2001E; +pub const MON_6: ::nl_item = 0x2001F; +pub const MON_7: ::nl_item = 0x20020; +pub const MON_8: ::nl_item = 0x20021; +pub const MON_9: ::nl_item = 0x20022; +pub const MON_10: ::nl_item = 0x20023; +pub const MON_11: ::nl_item = 0x20024; +pub const MON_12: ::nl_item = 0x20025; + +pub const AM_STR: ::nl_item = 0x20026; +pub const PM_STR: ::nl_item = 0x20027; + +pub const D_T_FMT: ::nl_item = 0x20028; +pub const D_FMT: ::nl_item = 0x20029; +pub const T_FMT: ::nl_item = 0x2002A; +pub const T_FMT_AMPM: ::nl_item = 0x2002B; + +pub const ERA: ::nl_item = 0x2002C; +pub const ERA_D_FMT: ::nl_item = 0x2002E; +pub const ALT_DIGITS: ::nl_item = 0x2002F; +pub const ERA_D_T_FMT: ::nl_item = 0x20030; +pub const ERA_T_FMT: ::nl_item = 0x20031; + +pub const CODESET: ::nl_item = 14; +pub const CRNCYSTR: ::nl_item = 0x4000F; +pub const RADIXCHAR: ::nl_item = 0x10000; +pub const THOUSEP: ::nl_item = 0x10001; +pub const YESEXPR: ::nl_item = 0x50000; +pub const NOEXPR: ::nl_item = 0x50001; +pub const YESSTR: ::nl_item = 0x50002; +pub const NOSTR: ::nl_item = 0x50003; + #[cfg_attr( feature = "rustc-dep-of-std", link( @@ -657,6 +723,9 @@ pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; pub fn chdir(dir: *const c_char) -> ::c_int; + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + pub fn nl_langinfo_l(item: ::nl_item, loc: ::locale_t) -> *mut ::c_char; + pub fn __wasilibc_register_preopened_fd(fd: c_int, path: *const c_char) -> c_int; pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int; pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int; diff -Nru cargo-0.58.0/vendor/libgit2-sys/build.rs cargo-0.60.0ubuntu1/vendor/libgit2-sys/build.rs --- cargo-0.58.0/vendor/libgit2-sys/build.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libgit2-sys/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -14,7 +14,7 @@ let try_to_use_system_libgit2 = !vendored && !zlib_ng_compat; if try_to_use_system_libgit2 { let mut cfg = pkg_config::Config::new(); - if let Ok(lib) = cfg.atleast_version("1.1.0").probe("libgit2") { + if let Ok(lib) = cfg.atleast_version("1.3.0").probe("libgit2") { for include in &lib.include_paths { println!("cargo:root={}", include.display()); } @@ -24,7 +24,7 @@ println!("cargo:rustc-cfg=libgit2_vendored"); - if !Path::new("libgit2/.git").exists() { + if false { let _ = Command::new("git") .args(&["submodule", "update", "--init", "libgit2"]) .status(); diff -Nru cargo-0.58.0/vendor/libgit2-sys/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/libgit2-sys/.cargo-checksum.json --- cargo-0.58.0/vendor/libgit2-sys/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libgit2-sys/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c"} \ No newline at end of file +{"files":{},"package":"19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/libgit2-sys/Cargo.lock cargo-0.60.0ubuntu1/vendor/libgit2-sys/Cargo.lock --- cargo-0.58.0/vendor/libgit2-sys/Cargo.lock 2022-01-21 03:14:44.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libgit2-sys/Cargo.lock 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "cc" -version = "1.0.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" -dependencies = [ - "jobserver", -] - -[[package]] -name = "cmake" -version = "0.1.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" -dependencies = [ - "cc", -] - -[[package]] -name = "jobserver" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" -dependencies = [ - "libc", -] - -[[package]] -name = "libc" -version = "0.2.113" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9" - -[[package]] -name = "libgit2-sys" -version = "0.12.24+1.3.0" -dependencies = [ - "cc", - "libc", - "libssh2-sys", - "libz-sys", - "openssl-sys", - "pkg-config", -] - -[[package]] -name = "libssh2-sys" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "libz-sys" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" -dependencies = [ - "cc", - "cmake", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "openssl-src" -version = "111.17.0+1.1.1m" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d6a336abd10814198f66e2a91ccd7336611f30334119ca8ce300536666fcf4" -dependencies = [ - "cc", -] - -[[package]] -name = "openssl-sys" -version = "0.9.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" -dependencies = [ - "autocfg", - "cc", - "libc", - "openssl-src", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "pkg-config" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" diff -Nru cargo-0.58.0/vendor/libgit2-sys/Cargo.toml cargo-0.60.0ubuntu1/vendor/libgit2-sys/Cargo.toml --- cargo-0.58.0/vendor/libgit2-sys/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libgit2-sys/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "libgit2-sys" -version = "0.12.24+1.3.0" +version = "0.12.26+1.3.0" authors = ["Josh Triplett ", "Alex Crichton "] build = "build.rs" links = "git2" @@ -48,7 +48,6 @@ ssh_key_from_memory = [] vendored = [] vendored-openssl = ["openssl-sys/vendored"] -zlib-ng-compat = ["libz-sys/zlib-ng", "libssh2-sys/zlib-ng-compat"] [target."cfg(unix)".dependencies.openssl-sys] version = "0.9" optional = true diff -Nru cargo-0.58.0/vendor/libgit2-sys/debian/patches/disable-vendor.patch cargo-0.60.0ubuntu1/vendor/libgit2-sys/debian/patches/disable-vendor.patch --- cargo-0.58.0/vendor/libgit2-sys/debian/patches/disable-vendor.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libgit2-sys/debian/patches/disable-vendor.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,11 @@ +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -46,8 +46,6 @@ + https = ["openssl-sys"] + ssh = ["libssh2-sys"] + ssh_key_from_memory = [] +-vendored = [] +-vendored-openssl = ["openssl-sys/vendored"] + [target."cfg(unix)".dependencies.openssl-sys] + version = "0.9" + optional = true diff -Nru cargo-0.58.0/vendor/libgit2-sys/debian/patches/no-special-snowflake-env.patch cargo-0.60.0ubuntu1/vendor/libgit2-sys/debian/patches/no-special-snowflake-env.patch --- cargo-0.58.0/vendor/libgit2-sys/debian/patches/no-special-snowflake-env.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libgit2-sys/debian/patches/no-special-snowflake-env.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,11 @@ +--- a/build.rs ++++ b/build.rs +@@ -24,7 +24,7 @@ + + println!("cargo:rustc-cfg=libgit2_vendored"); + +- if !Path::new("libgit2/.git").exists() { ++ if false { + let _ = Command::new("git") + .args(&["submodule", "update", "--init", "libgit2"]) + .status(); diff -Nru cargo-0.58.0/vendor/libgit2-sys/debian/patches/remove-zlib-ng-compat.patch cargo-0.60.0ubuntu1/vendor/libgit2-sys/debian/patches/remove-zlib-ng-compat.patch --- cargo-0.58.0/vendor/libgit2-sys/debian/patches/remove-zlib-ng-compat.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libgit2-sys/debian/patches/remove-zlib-ng-compat.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,10 @@ +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -48,7 +48,6 @@ + ssh_key_from_memory = [] + vendored = [] + vendored-openssl = ["openssl-sys/vendored"] +-zlib-ng-compat = ["libz-sys/zlib-ng", "libssh2-sys/zlib-ng-compat"] + [target."cfg(unix)".dependencies.openssl-sys] + version = "0.9" + optional = true diff -Nru cargo-0.58.0/vendor/libgit2-sys/debian/patches/series cargo-0.60.0ubuntu1/vendor/libgit2-sys/debian/patches/series --- cargo-0.58.0/vendor/libgit2-sys/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libgit2-sys/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,3 @@ +no-special-snowflake-env.patch +remove-zlib-ng-compat.patch +# disable-vendor.patch diff -Nru cargo-0.58.0/vendor/libgit2-sys/lib.rs cargo-0.60.0ubuntu1/vendor/libgit2-sys/lib.rs --- cargo-0.58.0/vendor/libgit2-sys/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libgit2-sys/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -143,7 +143,7 @@ } #[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct git_time { pub time: git_time_t, pub offset: c_int, @@ -817,7 +817,7 @@ pub const GIT_INDEX_ENTRY_STAGESHIFT: u16 = 12; #[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct git_index_time { pub seconds: i32, pub nanoseconds: u32, @@ -1953,6 +1953,20 @@ } } +#[repr(C)] +pub struct git_message_trailer { + pub key: *const c_char, + pub value: *const c_char, +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct git_message_trailer_array { + pub trailers: *mut git_message_trailer, + pub count: size_t, + pub _trailer_block: *mut c_char, +} + extern "C" { // threads pub fn git_libgit2_init() -> c_int; @@ -3678,6 +3692,13 @@ comment_char: c_char, ) -> c_int; + pub fn git_message_trailers( + out: *mut git_message_trailer_array, + message: *const c_char, + ) -> c_int; + + pub fn git_message_trailer_array_free(trailer: *mut git_message_trailer_array); + // packbuilder pub fn git_packbuilder_new(out: *mut *mut git_packbuilder, repo: *mut git_repository) -> c_int; pub fn git_packbuilder_set_threads(pb: *mut git_packbuilder, n: c_uint) -> c_uint; diff -Nru cargo-0.58.0/vendor/libz-sys/build.rs cargo-0.60.0ubuntu1/vendor/libz-sys/build.rs --- cargo-0.58.0/vendor/libz-sys/build.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libz-sys/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -41,8 +41,11 @@ .cargo_metadata(true) .print_system_libs(false) .probe("zlib"); - if zlib.is_ok() { - return; + match zlib { + Ok(_) => return, + Err(e) => { + println!("cargo-warning={}", e.to_string()) + } } } @@ -65,12 +68,17 @@ // Situations where we build unconditionally. // // MSVC basically never has it preinstalled, MinGW picks up a bunch of weird - // paths we don't like, `want_static` may force us, cross compiling almost - // never has a prebuilt version, and musl is almost always static. + // paths we don't like, `want_static` may force us, and cross compiling almost + // never has a prebuilt version. + // + // Apple platforms have libz.1.dylib, and it's usually available even when + // cross compiling (via fat binary or in the target's Xcode SDK) + let cross_compiling = target != host; + let apple_to_apple = host.contains("-apple-") && target.contains("-apple-"); if target.contains("msvc") || target.contains("pc-windows-gnu") || want_static - || target != host + || (cross_compiling && !apple_to_apple) { return build_zlib(&mut cfg, &target); } @@ -154,22 +162,35 @@ #[cfg(feature = "zlib-ng")] fn build_zlib_ng(target: &str) { - let install_dir = cmake::Config::new("src/zlib-ng") + let mut cmake = cmake::Config::new("src/zlib-ng"); + cmake .define("BUILD_SHARED_LIBS", "OFF") .define("ZLIB_COMPAT", "ON") - .define("WITH_GZFILEOP", "ON") - .build(); + .define("WITH_GZFILEOP", "ON"); + if target.contains("s390x") { + // Enable hardware compression on s390x. + cmake + .define("WITH_DFLTCC_DEFLATE", "1") + .define("WITH_DFLTCC_INFLATE", "1") + .cflag("-DDFLTCC_LEVEL_MASK=0x7e"); + } + if target.contains("apple") { + cmake.cflag("-D_DARWIN_C_SOURCE=1"); + } + + let install_dir = cmake.build(); + let includedir = install_dir.join("include"); let libdir = install_dir.join("lib"); println!( "cargo:rustc-link-search=native={}", libdir.to_str().unwrap() ); - let libname = if target.contains("windows") { - if target.contains("msvc") && env::var("OPT_LEVEL").unwrap() == "0" { - "zlibd" + let libname = if target.contains("windows") && target.contains("msvc") { + if env::var("OPT_LEVEL").unwrap() == "0" { + "zlibstaticd" } else { - "zlib" + "zlibstatic" } } else { "z" diff -Nru cargo-0.58.0/vendor/libz-sys/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/libz-sys/.cargo-checksum.json --- cargo-0.58.0/vendor/libz-sys/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libz-sys/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66"} \ No newline at end of file +{"files":{},"package":"6f35facd4a5673cb5a48822be2be1d4236c1c99cb4113cab7061ac720d5bf859"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/libz-sys/Cargo.toml cargo-0.60.0ubuntu1/vendor/libz-sys/Cargo.toml --- cargo-0.58.0/vendor/libz-sys/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/libz-sys/Cargo.toml 2022-04-20 13:48:09.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 = "libz-sys" -version = "1.1.3" +version = "1.1.5" authors = ["Alex Crichton ", "Josh Triplett "] build = "build.rs" links = "z" diff -Nru cargo-0.58.0/vendor/log/build.rs cargo-0.60.0ubuntu1/vendor/log/build.rs --- cargo-0.58.0/vendor/log/build.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/log/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -33,7 +33,10 @@ fn target_has_atomics(target: &str) -> bool { match &target[..] { - "msp430-none-elf" | "riscv32i-unknown-none-elf" | "riscv32imc-unknown-none-elf" => false, + "thumbv4t-none-eabi" + | "msp430-none-elf" + | "riscv32i-unknown-none-elf" + | "riscv32imc-unknown-none-elf" => false, _ => true, } } diff -Nru cargo-0.58.0/vendor/log/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/log/.cargo-checksum.json --- cargo-0.58.0/vendor/log/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/log/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"} \ No newline at end of file +{"files":{},"package":"6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/log/Cargo.toml cargo-0.60.0ubuntu1/vendor/log/Cargo.toml --- cargo-0.58.0/vendor/log/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/log/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -3,28 +3,36 @@ # 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 = "log" -version = "0.4.14" +version = "0.4.16" authors = ["The Rust Project Developers"] build = "build.rs" -exclude = ["rfcs/**/*", "/.travis.yml", "/appveyor.yml"] -description = "A lightweight logging facade for Rust\n" +exclude = ["rfcs/**/*"] +description = """ +A lightweight logging facade for Rust +""" documentation = "https://docs.rs/log" readme = "README.md" keywords = ["logging"] categories = ["development-tools::debugging"] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/log" + [package.metadata.docs.rs] -features = ["std", "serde", "kv_unstable_std", "kv_unstable_serde"] +features = [ + "std", + "serde", + "kv_unstable_std", + "kv_unstable_sval", + "kv_unstable_serde", +] [[test]] name = "filters" @@ -35,6 +43,7 @@ name = "macros" path = "tests/macros.rs" harness = true + [dependencies.cfg-if] version = "1.0" @@ -43,10 +52,19 @@ optional = true default-features = false +[dependencies.sval] +version = "=1.0.0-alpha.5" +optional = true +default-features = false + [dependencies.value-bag] -version = "1.0.0-alpha.6" +version = "=1.0.0-alpha.8" optional = true default-features = false + +[dev-dependencies.rustversion] +version = "1.0" + [dev-dependencies.serde] version = "1.0" features = ["derive"] @@ -54,14 +72,31 @@ [dev-dependencies.serde_test] version = "1.0" +[dev-dependencies.sval] +version = "=1.0.0-alpha.5" +features = ["derive"] + [dev-dependencies.value-bag] -version = "1.0.0-alpha.6" +version = "=1.0.0-alpha.8" features = ["test"] [features] kv_unstable = ["value-bag"] -kv_unstable_serde = ["kv_unstable_std", "value-bag/serde", "serde"] -kv_unstable_std = ["std", "kv_unstable", "value-bag/error"] +kv_unstable_serde = [ + "kv_unstable_std", + "value-bag/serde", + "serde", +] +kv_unstable_std = [ + "std", + "kv_unstable", + "value-bag/error", +] +kv_unstable_sval = [ + "kv_unstable", + "value-bag/sval", + "sval", +] max_level_debug = [] max_level_error = [] max_level_info = [] diff -Nru cargo-0.58.0/vendor/log/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/log/CHANGELOG.md --- cargo-0.58.0/vendor/log/CHANGELOG.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/log/CHANGELOG.md 2022-04-20 13:48:09.000000000 +0000 @@ -2,6 +2,25 @@ ## [Unreleased] +## [0.4.16] - 2022-03-22 + +* Fix a conflict with unqualified `Option` use in macros. + +## [0.4.15] - 2022-02-23 + +* Silence a warning about the deprecated `spin_loop_hint`. +* Relax ordering in the atomic `set_max_level` call. +* Add thumbv4t-none-eabi to targets that don't support atomics +* Allow levels to be iterated over. +* Implement `Log` on some common wrapper types. +* Improvements to test coverage. +* Improvements to documentation. +* Add key-value support to the `log!` macros. +* Tighten `kv_unstable` internal dependencies so they don't bump past their current alpha. +* Add a simple visit API to `kv_unstable`. +* Support `NonZero*` integers as values in structured logging +* Support static strings as keys in structured logging + ## [0.4.14] - 2021-01-27 * Remove the `__private_api_log_lit` special case. @@ -196,7 +215,9 @@ Look at the [release tags] for information about older releases. -[Unreleased]: https://github.com/rust-lang-nursery/log/compare/0.4.14...HEAD +[Unreleased]: https://github.com/rust-lang-nursery/log/compare/0.4.16...HEAD +[0.4.16]: https://github.com/rust-lang-nursery/log/compare/0.4.15...0.4.16 +[0.4.15]: https://github.com/rust-lang-nursery/log/compare/0.4.13...0.4.15 [0.4.14]: https://github.com/rust-lang-nursery/log/compare/0.4.13...0.4.14 [0.4.13]: https://github.com/rust-lang-nursery/log/compare/0.4.11...0.4.13 [0.4.12]: https://github.com/rust-lang-nursery/log/compare/0.4.11...0.4.12 diff -Nru cargo-0.58.0/vendor/log/debian/patches/series cargo-0.60.0ubuntu1/vendor/log/debian/patches/series --- cargo-0.58.0/vendor/log/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/log/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -1 +0,0 @@ -ignore-sval.diff diff -Nru cargo-0.58.0/vendor/log/README.md cargo-0.60.0ubuntu1/vendor/log/README.md --- cargo-0.58.0/vendor/log/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/log/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -24,7 +24,7 @@ ## Usage -## In libraries +### In libraries Libraries should link only to the `log` crate, and use the provided macros to log whatever information will be useful to downstream consumers: @@ -55,15 +55,15 @@ } ``` -## In executables +### In executables In order to produce log output, executables have to use a logger implementation compatible with the facade. There are many available implementations to choose from, here are some of the most popular ones: * Simple minimal loggers: * [`env_logger`](https://docs.rs/env_logger/*/env_logger/) - * [`simple_logger`](https://github.com/borntyping/rust-simple_logger) - * [`simplelog`](https://github.com/drakulix/simplelog.rs) + * [`simple_logger`](https://docs.rs/simple_logger/*/simple_logger/) + * [`simplelog`](https://docs.rs/simplelog/*/simplelog/) * [`pretty_env_logger`](https://docs.rs/pretty_env_logger/*/pretty_env_logger/) * [`stderrlog`](https://docs.rs/stderrlog/*/stderrlog/) * [`flexi_logger`](https://docs.rs/flexi_logger/*/flexi_logger/) @@ -72,11 +72,16 @@ * [`fern`](https://docs.rs/fern/*/fern/) * Adaptors for other facilities: * [`syslog`](https://docs.rs/syslog/*/syslog/) + * [`systemd-journal-logger`](https://docs.rs/systemd-journal-logger/*/systemd_journal_logger/) * [`slog-stdlog`](https://docs.rs/slog-stdlog/*/slog_stdlog/) * [`android_log`](https://docs.rs/android_log/*/android_log/) * [`win_dbg_logger`](https://docs.rs/win_dbg_logger/*/win_dbg_logger/) * For WebAssembly binaries: * [`console_log`](https://docs.rs/console_log/*/console_log/) +* For dynamic libraries: + * You may need to construct [an FFI-safe wrapper over `log`](https://github.com/rust-lang/log/issues/421) to initialize in your libraries. +* Utilities: + * [`log_err`](https://docs.rs/log_err/*/log_err/) Executables should choose a logger implementation and initialize it early in the runtime of the program. Logger implementations will typically include a @@ -84,3 +89,28 @@ initialized will be ignored. The executable itself may use the `log` crate to log as well. + +## Structured logging + +If you enable the `kv_unstable` feature, you can associate structured data with your log records: + +```rust +use log::{info, trace, warn, as_serde, as_error}; + +pub fn shave_the_yak(yak: &mut Yak) { + trace!(target = "yak_events", yak = as_serde!(yak); "Commencing yak shaving"); + + loop { + match find_a_razor() { + Ok(razor) => { + info!(razor = razor; "Razor located"); + yak.shave(razor); + break; + } + Err(err) => { + warn!(err = as_error!(err); "Unable to locate a razor, retrying"); + } + } + } +} +``` diff -Nru cargo-0.58.0/vendor/log/src/kv/error.rs cargo-0.60.0ubuntu1/vendor/log/src/kv/error.rs --- cargo-0.58.0/vendor/log/src/kv/error.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/log/src/kv/error.rs 2022-04-20 13:48:09.000000000 +0000 @@ -11,6 +11,7 @@ #[cfg(feature = "std")] Boxed(std_support::BoxedError), Msg(&'static str), + Value(value_bag::Error), Fmt, } @@ -21,6 +22,24 @@ inner: Inner::Msg(msg), } } + + // Not public so we don't leak the `value_bag` API + pub(super) fn from_value(err: value_bag::Error) -> Self { + Error { + inner: Inner::Value(err), + } + } + + // Not public so we don't leak the `value_bag` API + pub(super) fn into_value(self) -> value_bag::Error { + match self.inner { + Inner::Value(err) => err, + #[cfg(feature = "kv_unstable_std")] + _ => value_bag::Error::boxed(self), + #[cfg(not(feature = "kv_unstable_std"))] + _ => value_bag::Error::msg("error inspecting a value"), + } + } } impl fmt::Display for Error { @@ -29,6 +48,7 @@ match &self.inner { #[cfg(feature = "std")] &Boxed(ref err) => err.fmt(f), + &Value(ref err) => err.fmt(f), &Msg(ref msg) => msg.fmt(f), &Fmt => fmt::Error.fmt(f), } diff -Nru cargo-0.58.0/vendor/log/src/kv/value.rs cargo-0.60.0ubuntu1/vendor/log/src/kv/value.rs --- cargo-0.58.0/vendor/log/src/kv/value.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/log/src/kv/value.rs 2022-04-20 13:48:09.000000000 +0000 @@ -37,6 +37,49 @@ } } +/// Get a value from a type implementing `std::fmt::Debug`. +#[macro_export] +macro_rules! as_debug { + ($capture:expr) => { + $crate::kv::Value::from_debug(&$capture) + }; +} + +/// Get a value from a type implementing `std::fmt::Display`. +#[macro_export] +macro_rules! as_display { + ($capture:expr) => { + $crate::kv::Value::from_display(&$capture) + }; +} + +/// Get a value from an error. +#[cfg(feature = "kv_unstable_std")] +#[macro_export] +macro_rules! as_error { + ($capture:expr) => { + $crate::kv::Value::from_dyn_error(&$capture) + }; +} + +#[cfg(feature = "kv_unstable_serde")] +/// Get a value from a type implementing `serde::Serialize`. +#[macro_export] +macro_rules! as_serde { + ($capture:expr) => { + $crate::kv::Value::from_serde(&$capture) + }; +} + +/// Get a value from a type implementing `sval::value::Value`. +#[cfg(feature = "kv_unstable_sval")] +#[macro_export] +macro_rules! as_sval { + ($capture:expr) => { + $crate::kv::Value::from_sval(&$capture) + }; +} + /// A value in a structured key-value pair. /// /// # Capturing values @@ -263,6 +306,78 @@ pub fn downcast_ref(&self) -> Option<&T> { self.inner.downcast_ref::() } + + /// Inspect this value using a simple visitor. + pub fn visit(&self, visitor: impl Visit<'v>) -> Result<(), Error> { + struct Visitor(V); + + impl<'v, V> value_bag::visit::Visit<'v> for Visitor + where + V: Visit<'v>, + { + fn visit_any(&mut self, value: ValueBag) -> Result<(), value_bag::Error> { + self.0 + .visit_any(Value { inner: value }) + .map_err(Error::into_value) + } + + fn visit_u64(&mut self, value: u64) -> Result<(), value_bag::Error> { + self.0.visit_u64(value).map_err(Error::into_value) + } + + fn visit_i64(&mut self, value: i64) -> Result<(), value_bag::Error> { + self.0.visit_i64(value).map_err(Error::into_value) + } + + fn visit_u128(&mut self, value: u128) -> Result<(), value_bag::Error> { + self.0.visit_u128(value).map_err(Error::into_value) + } + + fn visit_i128(&mut self, value: i128) -> Result<(), value_bag::Error> { + self.0.visit_i128(value).map_err(Error::into_value) + } + + fn visit_f64(&mut self, value: f64) -> Result<(), value_bag::Error> { + self.0.visit_f64(value).map_err(Error::into_value) + } + + fn visit_bool(&mut self, value: bool) -> Result<(), value_bag::Error> { + self.0.visit_bool(value).map_err(Error::into_value) + } + + fn visit_str(&mut self, value: &str) -> Result<(), value_bag::Error> { + self.0.visit_str(value).map_err(Error::into_value) + } + + fn visit_borrowed_str(&mut self, value: &'v str) -> Result<(), value_bag::Error> { + self.0.visit_borrowed_str(value).map_err(Error::into_value) + } + + fn visit_char(&mut self, value: char) -> Result<(), value_bag::Error> { + self.0.visit_char(value).map_err(Error::into_value) + } + + #[cfg(feature = "kv_unstable_std")] + fn visit_error( + &mut self, + err: &(dyn std::error::Error + 'static), + ) -> Result<(), value_bag::Error> { + self.0.visit_error(err).map_err(Error::into_value) + } + + #[cfg(feature = "kv_unstable_std")] + fn visit_borrowed_error( + &mut self, + err: &'v (dyn std::error::Error + 'static), + ) -> Result<(), value_bag::Error> { + self.0.visit_borrowed_error(err).map_err(Error::into_value) + } + } + + self.inner + .visit(&mut Visitor(visitor)) + .map_err(Error::from_value) + } } impl<'v> fmt::Debug for Value<'v> { @@ -368,6 +483,24 @@ }; } +macro_rules! impl_to_value_nonzero_primitive { + ($($into_ty:ident,)*) => { + $( + impl ToValue for std::num::$into_ty { + fn to_value(&self) -> Value { + Value::from(self.get()) + } + } + + impl<'v> From for Value<'v> { + fn from(value: std::num::$into_ty) -> Self { + Value::from(value.get()) + } + } + )* + }; +} + macro_rules! impl_value_to_primitive { ($(#[doc = $doc:tt] $into_name:ident -> $into_ty:ty,)*) => { impl<'v> Value<'v> { @@ -385,6 +518,12 @@ usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64, char, bool, ]; +#[rustfmt::skip] +impl_to_value_nonzero_primitive![ + NonZeroUsize, NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, + NonZeroIsize, NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, +]; + impl_value_to_primitive![ #[doc = "Try convert this value into a `u64`."] to_u64 -> u64, @@ -448,6 +587,142 @@ self.inner.to_str() } } + + impl<'v> From<&'v String> for Value<'v> { + fn from(v: &'v String) -> Self { + Value::from(&**v) + } + } +} + +/// A visitor for a `Value`. +pub trait Visit<'v> { + /// Visit a `Value`. + /// + /// This is the only required method on `Visit` and acts as a fallback for any + /// more specific methods that aren't overridden. + /// The `Value` may be formatted using its `fmt::Debug` or `fmt::Display` implementation, + /// or serialized using its `sval::Value` or `serde::Serialize` implementation. + fn visit_any(&mut self, value: Value) -> Result<(), Error>; + + /// Visit an unsigned integer. + fn visit_u64(&mut self, value: u64) -> Result<(), Error> { + self.visit_any(value.into()) + } + + /// Visit a signed integer. + fn visit_i64(&mut self, value: i64) -> Result<(), Error> { + self.visit_any(value.into()) + } + + /// Visit a big unsigned integer. + fn visit_u128(&mut self, value: u128) -> Result<(), Error> { + self.visit_any(value.into()) + } + + /// Visit a big signed integer. + fn visit_i128(&mut self, value: i128) -> Result<(), Error> { + self.visit_any(value.into()) + } + + /// Visit a floating point. + fn visit_f64(&mut self, value: f64) -> Result<(), Error> { + self.visit_any(value.into()) + } + + /// Visit a boolean. + fn visit_bool(&mut self, value: bool) -> Result<(), Error> { + self.visit_any(value.into()) + } + + /// Visit a string. + fn visit_str(&mut self, value: &str) -> Result<(), Error> { + self.visit_any(value.into()) + } + + /// Visit a string. + fn visit_borrowed_str(&mut self, value: &'v str) -> Result<(), Error> { + self.visit_str(value) + } + + /// Visit a Unicode character. + fn visit_char(&mut self, value: char) -> Result<(), Error> { + let mut b = [0; 4]; + self.visit_str(&*value.encode_utf8(&mut b)) + } + + /// Visit an error. + #[cfg(feature = "kv_unstable_std")] + fn visit_error(&mut self, err: &(dyn std::error::Error + 'static)) -> Result<(), Error> { + self.visit_any(Value::from_dyn_error(err)) + } + + /// Visit an error. + #[cfg(feature = "kv_unstable_std")] + fn visit_borrowed_error( + &mut self, + err: &'v (dyn std::error::Error + 'static), + ) -> Result<(), Error> { + self.visit_any(Value::from_dyn_error(err)) + } +} + +impl<'a, 'v, T: ?Sized> Visit<'v> for &'a mut T +where + T: Visit<'v>, +{ + fn visit_any(&mut self, value: Value) -> Result<(), Error> { + (**self).visit_any(value) + } + + fn visit_u64(&mut self, value: u64) -> Result<(), Error> { + (**self).visit_u64(value) + } + + fn visit_i64(&mut self, value: i64) -> Result<(), Error> { + (**self).visit_i64(value) + } + + fn visit_u128(&mut self, value: u128) -> Result<(), Error> { + (**self).visit_u128(value) + } + + fn visit_i128(&mut self, value: i128) -> Result<(), Error> { + (**self).visit_i128(value) + } + + fn visit_f64(&mut self, value: f64) -> Result<(), Error> { + (**self).visit_f64(value) + } + + fn visit_bool(&mut self, value: bool) -> Result<(), Error> { + (**self).visit_bool(value) + } + + fn visit_str(&mut self, value: &str) -> Result<(), Error> { + (**self).visit_str(value) + } + + fn visit_borrowed_str(&mut self, value: &'v str) -> Result<(), Error> { + (**self).visit_borrowed_str(value) + } + + fn visit_char(&mut self, value: char) -> Result<(), Error> { + (**self).visit_char(value) + } + + #[cfg(feature = "kv_unstable_std")] + fn visit_error(&mut self, err: &(dyn std::error::Error + 'static)) -> Result<(), Error> { + (**self).visit_error(err) + } + + #[cfg(feature = "kv_unstable_std")] + fn visit_borrowed_error( + &mut self, + err: &'v (dyn std::error::Error + 'static), + ) -> Result<(), Error> { + (**self).visit_borrowed_error(err) + } } #[cfg(test)] @@ -469,6 +744,11 @@ Value::from(32u32), Value::from(64u64), Value::from(1usize), + Value::from(std::num::NonZeroU8::new(8).unwrap()), + Value::from(std::num::NonZeroU16::new(16).unwrap()), + Value::from(std::num::NonZeroU32::new(32).unwrap()), + Value::from(std::num::NonZeroU64::new(64).unwrap()), + Value::from(std::num::NonZeroUsize::new(1).unwrap()), ] .into_iter() } @@ -480,6 +760,11 @@ Value::from(-32i32), Value::from(-64i64), Value::from(-1isize), + Value::from(std::num::NonZeroI8::new(-8).unwrap()), + Value::from(std::num::NonZeroI16::new(-16).unwrap()), + Value::from(std::num::NonZeroI32::new(-32).unwrap()), + Value::from(std::num::NonZeroI64::new(-64).unwrap()), + Value::from(std::num::NonZeroIsize::new(-1).unwrap()), ] .into_iter() } @@ -652,4 +937,50 @@ assert!(v.is::()); assert_eq!(42u64, v.downcast_ref::().expect("invalid downcast").0); } + + #[test] + fn test_visit_integer() { + struct Extract(Option); + + impl<'v> Visit<'v> for Extract { + fn visit_any(&mut self, value: Value) -> Result<(), Error> { + unimplemented!("unexpected value: {:?}", value) + } + + fn visit_u64(&mut self, value: u64) -> Result<(), Error> { + self.0 = Some(value); + + Ok(()) + } + } + + let mut extract = Extract(None); + Value::from(42u64).visit(&mut extract).unwrap(); + + assert_eq!(Some(42), extract.0); + } + + #[test] + fn test_visit_borrowed_str() { + struct Extract<'v>(Option<&'v str>); + + impl<'v> Visit<'v> for Extract<'v> { + fn visit_any(&mut self, value: Value) -> Result<(), Error> { + unimplemented!("unexpected value: {:?}", value) + } + + fn visit_borrowed_str(&mut self, value: &'v str) -> Result<(), Error> { + self.0 = Some(value); + + Ok(()) + } + } + + let mut extract = Extract(None); + + let short_lived = String::from("A short-lived string"); + Value::from(&*short_lived).visit(&mut extract).unwrap(); + + assert_eq!(Some("A short-lived string"), extract.0); + } } diff -Nru cargo-0.58.0/vendor/log/src/lib.rs cargo-0.60.0ubuntu1/vendor/log/src/lib.rs --- cargo-0.58.0/vendor/log/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/log/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -24,7 +24,7 @@ //! though that default may be overridden. Logger implementations typically use //! the target to filter requests based on some user configuration. //! -//! # Use +//! # Usage //! //! The basic use of the log crate is through the five logging macros: [`error!`], //! [`warn!`], [`info!`], [`debug!`] and [`trace!`] @@ -86,6 +86,42 @@ //! //! The logging system may only be initialized once. //! +//! ## Structured logging +//! +//! If you enable the `kv_unstable` feature you can associate structured values +//! with your log records. If we take the example from before, we can include +//! some additional context besides what's in the formatted message: +//! +//! ```edition2018 +//! # #[macro_use] extern crate serde; +//! # #[derive(Debug, Serialize)] pub struct Yak(String); +//! # impl Yak { fn shave(&mut self, _: u32) {} } +//! # fn find_a_razor() -> Result { Ok(1) } +//! # #[cfg(feature = "kv_unstable_serde")] +//! # fn main() { +//! use log::{info, warn, as_serde, as_error}; +//! +//! pub fn shave_the_yak(yak: &mut Yak) { +//! info!(target: "yak_events", yak = as_serde!(yak); "Commencing yak shaving"); +//! +//! loop { +//! match find_a_razor() { +//! Ok(razor) => { +//! info!(razor = razor; "Razor located"); +//! yak.shave(razor); +//! break; +//! } +//! Err(err) => { +//! warn!(err = as_error!(err); "Unable to locate a razor, retrying"); +//! } +//! } +//! } +//! } +//! # } +//! # #[cfg(not(feature = "kv_unstable_serde"))] +//! # fn main() {} +//! ``` +//! //! # Available logging implementations //! //! In order to produce log output executables have to use @@ -106,6 +142,13 @@ //! * Adaptors for other facilities: //! * [syslog] //! * [slog-stdlog] +//! * [systemd-journal-logger] +//! * [android_log] +//! * [win_dbg_logger] +//! * For WebAssembly binaries: +//! * [console_log] +//! * For dynamic libraries: +//! * You may need to construct an FFI-safe wrapper over `log` to initialize in your libraries //! //! # Implementing a Logger //! @@ -262,14 +305,18 @@ //! [slog-stdlog]: https://docs.rs/slog-stdlog/*/slog_stdlog/ //! [log4rs]: https://docs.rs/log4rs/*/log4rs/ //! [fern]: https://docs.rs/fern/*/fern/ +//! [systemd-journal-logger]: (https://docs.rs/systemd-journal-logger/*/systemd_journal_logger/) +//! [android_log]: (https://docs.rs/android_log/*/android_log/) +//! [win_dbg_logger]: (https://docs.rs/win_dbg_logger/*/win_dbg_logger/) +//! [console_log]: (https://docs.rs/console_log/*/console_log/) #![doc( html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://docs.rs/log/0.4.14" + html_root_url = "https://docs.rs/log/0.4.16" )] #![warn(missing_docs)] -#![deny(missing_debug_implementations)] +#![deny(missing_debug_implementations, unconditional_recursion)] #![cfg_attr(all(not(feature = "std"), not(test)), no_std)] // When compiled for the rustc compiler itself we want to make sure that this is // an unstable crate @@ -560,6 +607,24 @@ pub fn as_str(&self) -> &'static str { LOG_LEVEL_NAMES[*self as usize] } + + /// Iterate through all supported logging levels. + /// + /// The order of iteration is from more severe to less severe log messages. + /// + /// # Examples + /// + /// ``` + /// use log::Level; + /// + /// let mut levels = Level::iter(); + /// + /// assert_eq!(Some(Level::Error), levels.next()); + /// assert_eq!(Some(Level::Trace), levels.last()); + /// ``` + pub fn iter() -> impl Iterator { + (1..6).map(|i| Self::from_usize(i).unwrap()) + } } /// An enum representing the available verbosity level filters of the logger. @@ -702,6 +767,7 @@ _ => None, } } + /// Returns the most verbose logging level filter. #[inline] pub fn max() -> LevelFilter { @@ -722,6 +788,24 @@ pub fn as_str(&self) -> &'static str { LOG_LEVEL_NAMES[*self as usize] } + + /// Iterate through all supported filtering levels. + /// + /// The order of iteration is from less to more verbose filtering. + /// + /// # Examples + /// + /// ``` + /// use log::LevelFilter; + /// + /// let mut levels = LevelFilter::iter(); + /// + /// assert_eq!(Some(LevelFilter::Off), levels.next()); + /// assert_eq!(Some(LevelFilter::Trace), levels.last()); + /// ``` + pub fn iter() -> impl Iterator { + (0..6).map(|i| Self::from_usize(i).unwrap()) + } } #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] @@ -880,7 +964,7 @@ self.line } - /// The structued key-value pairs associated with the message. + /// The structured key-value pairs associated with the message. #[cfg(feature = "kv_unstable")] #[inline] pub fn key_values(&self) -> &dyn kv::Source { @@ -915,7 +999,6 @@ /// /// # Examples /// -/// /// ```edition2018 /// use log::{Level, Record}; /// @@ -1214,6 +1297,22 @@ fn flush(&self) {} } +impl Log for &'_ T +where + T: ?Sized + Log, +{ + fn enabled(&self, metadata: &Metadata) -> bool { + (**self).enabled(metadata) + } + + fn log(&self, record: &Record) { + (**self).log(record) + } + fn flush(&self) { + (**self).flush() + } +} + #[cfg(feature = "std")] impl Log for std::boxed::Box where @@ -1231,12 +1330,31 @@ } } +#[cfg(feature = "std")] +impl Log for std::sync::Arc +where + T: ?Sized + Log, +{ + fn enabled(&self, metadata: &Metadata) -> bool { + self.as_ref().enabled(metadata) + } + + fn log(&self, record: &Record) { + self.as_ref().log(record) + } + fn flush(&self) { + self.as_ref().flush() + } +} + /// Sets the global maximum log level. /// /// Generally, this should only be called by the active logging implementation. +/// +/// Note that `Trace` is the maximum level, because it provides the maximum amount of detail in the emitted logs. #[inline] pub fn set_max_level(level: LevelFilter) { - MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::SeqCst) + MAX_LOG_LEVEL_FILTER.store(level as usize, Ordering::Relaxed) } /// Returns the current maximum log level. @@ -1362,6 +1480,8 @@ } INITIALIZING => { while STATE.load(Ordering::SeqCst) == INITIALIZING { + // TODO: replace with `hint::spin_loop` once MSRV is 1.49.0. + #[allow(deprecated)] std::sync::atomic::spin_loop_hint(); } Err(SetLoggerError(())) @@ -1452,10 +1572,39 @@ // WARNING: this is not part of the crate's public API and is subject to change at any time #[doc(hidden)] +#[cfg(not(feature = "kv_unstable"))] +pub fn __private_api_log( + args: fmt::Arguments, + level: Level, + &(target, module_path, file, line): &(&str, &'static str, &'static str, u32), + kvs: Option<&[(&str, &str)]>, +) { + if kvs.is_some() { + panic!( + "key-value support is experimental and must be enabled using the `kv_unstable` feature" + ) + } + + logger().log( + &Record::builder() + .args(args) + .level(level) + .target(target) + .module_path_static(Some(module_path)) + .file_static(Some(file)) + .line(Some(line)) + .build(), + ); +} + +// WARNING: this is not part of the crate's public API and is subject to change at any time +#[doc(hidden)] +#[cfg(feature = "kv_unstable")] pub fn __private_api_log( args: fmt::Arguments, level: Level, &(target, module_path, file, line): &(&str, &'static str, &'static str, u32), + kvs: Option<&[(&str, &dyn kv::ToValue)]>, ) { logger().log( &Record::builder() @@ -1465,6 +1614,7 @@ .module_path_static(Some(module_path)) .file_static(Some(file)) .line(Some(line)) + .key_values(&kvs) .build(), ); } @@ -1475,6 +1625,12 @@ logger().enabled(&Metadata::builder().level(level).target(target).build()) } +// WARNING: this is not part of the crate's public API and is subject to change at any time +#[doc(hidden)] +pub mod __private_api { + pub use std::option::Option; +} + /// The statically resolved maximum log level. /// /// See the crate level documentation for information on how to configure this. @@ -1772,4 +1928,35 @@ .expect("invalid value") ); } + + // Test that the `impl Log for Foo` blocks work + // This test mostly operates on a type level, so failures will be compile errors + #[test] + fn test_foreign_impl() { + use super::Log; + #[cfg(feature = "std")] + use std::sync::Arc; + + fn assert_is_log() {} + + assert_is_log::<&dyn Log>(); + + #[cfg(feature = "std")] + assert_is_log::>(); + + #[cfg(feature = "std")] + assert_is_log::>(); + + // Assert these statements for all T: Log + ?Sized + #[allow(unused)] + fn forall() { + #[cfg(feature = "std")] + assert_is_log::>(); + + assert_is_log::<&T>(); + + #[cfg(feature = "std")] + assert_is_log::>(); + } + } } diff -Nru cargo-0.58.0/vendor/log/src/macros.rs cargo-0.60.0ubuntu1/vendor/log/src/macros.rs --- cargo-0.58.0/vendor/log/src/macros.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/log/src/macros.rs 2022-04-20 13:48:09.000000000 +0000 @@ -29,6 +29,20 @@ /// ``` #[macro_export(local_inner_macros)] macro_rules! log { + // log!(target: "my_target", Level::Info; key1 = 42, key2 = true; "a {} event", "log"); + (target: $target:expr, $lvl:expr, $($key:tt = $value:expr),+; $($arg:tt)+) => ({ + let lvl = $lvl; + if lvl <= $crate::STATIC_MAX_LEVEL && lvl <= $crate::max_level() { + $crate::__private_api_log( + __log_format_args!($($arg)+), + lvl, + &($target, __log_module_path!(), __log_file!(), __log_line!()), + $crate::__private_api::Option::Some(&[$((__log_key!($key), &$value)),+]) + ); + } + }); + + // log!(target: "my_target", Level::Info; "a {} event", "log"); (target: $target:expr, $lvl:expr, $($arg:tt)+) => ({ let lvl = $lvl; if lvl <= $crate::STATIC_MAX_LEVEL && lvl <= $crate::max_level() { @@ -36,10 +50,13 @@ __log_format_args!($($arg)+), lvl, &($target, __log_module_path!(), __log_file!(), __log_line!()), + $crate::__private_api::Option::None, ); } }); - ($lvl:expr, $($arg:tt)+) => (log!(target: __log_module_path!(), $lvl, $($arg)+)) + + // log!(Level::Info, "a log event") + ($lvl:expr, $($arg:tt)+) => (log!(target: __log_module_path!(), $lvl, $($arg)+)); } /// Logs a message at the error level. @@ -58,12 +75,12 @@ /// ``` #[macro_export(local_inner_macros)] macro_rules! error { - (target: $target:expr, $($arg:tt)+) => ( - log!(target: $target, $crate::Level::Error, $($arg)+) - ); - ($($arg:tt)+) => ( - log!($crate::Level::Error, $($arg)+) - ) + // error!(target: "my_target", key1 = 42, key2 = true; "a {} event", "log") + // error!(target: "my_target", "a {} event", "log") + (target: $target:expr, $($arg:tt)+) => (log!(target: $target, $crate::Level::Error, $($arg)+)); + + // error!("a {} event", "log") + ($($arg:tt)+) => (log!($crate::Level::Error, $($arg)+)) } /// Logs a message at the warn level. @@ -82,12 +99,12 @@ /// ``` #[macro_export(local_inner_macros)] macro_rules! warn { - (target: $target:expr, $($arg:tt)+) => ( - log!(target: $target, $crate::Level::Warn, $($arg)+) - ); - ($($arg:tt)+) => ( - log!($crate::Level::Warn, $($arg)+) - ) + // warn!(target: "my_target", key1 = 42, key2 = true; "a {} event", "log") + // warn!(target: "my_target", "a {} event", "log") + (target: $target:expr, $($arg:tt)+) => (log!(target: $target, $crate::Level::Warn, $($arg)+)); + + // warn!("a {} event", "log") + ($($arg:tt)+) => (log!($crate::Level::Warn, $($arg)+)) } /// Logs a message at the info level. @@ -108,12 +125,12 @@ /// ``` #[macro_export(local_inner_macros)] macro_rules! info { - (target: $target:expr, $($arg:tt)+) => ( - log!(target: $target, $crate::Level::Info, $($arg)+) - ); - ($($arg:tt)+) => ( - log!($crate::Level::Info, $($arg)+) - ) + // info!(target: "my_target", key1 = 42, key2 = true; "a {} event", "log") + // info!(target: "my_target", "a {} event", "log") + (target: $target:expr, $($arg:tt)+) => (log!(target: $target, $crate::Level::Info, $($arg)+)); + + // info!("a {} event", "log") + ($($arg:tt)+) => (log!($crate::Level::Info, $($arg)+)) } /// Logs a message at the debug level. @@ -133,12 +150,12 @@ /// ``` #[macro_export(local_inner_macros)] macro_rules! debug { - (target: $target:expr, $($arg:tt)+) => ( - log!(target: $target, $crate::Level::Debug, $($arg)+) - ); - ($($arg:tt)+) => ( - log!($crate::Level::Debug, $($arg)+) - ) + // debug!(target: "my_target", key1 = 42, key2 = true; "a {} event", "log") + // debug!(target: "my_target", "a {} event", "log") + (target: $target:expr, $($arg:tt)+) => (log!(target: $target, $crate::Level::Debug, $($arg)+)); + + // debug!("a {} event", "log") + ($($arg:tt)+) => (log!($crate::Level::Debug, $($arg)+)) } /// Logs a message at the trace level. @@ -160,12 +177,12 @@ /// ``` #[macro_export(local_inner_macros)] macro_rules! trace { - (target: $target:expr, $($arg:tt)+) => ( - log!(target: $target, $crate::Level::Trace, $($arg)+) - ); - ($($arg:tt)+) => ( - log!($crate::Level::Trace, $($arg)+) - ) + // trace!(target: "my_target", key1 = 42, key2 = true; "a {} event", "log") + // trace!(target: "my_target", "a {} event", "log") + (target: $target:expr, $($arg:tt)+) => (log!(target: $target, $crate::Level::Trace, $($arg)+)); + + // trace!("a {} event", "log") + ($($arg:tt)+) => (log!($crate::Level::Trace, $($arg)+)) } /// Determines if a message logged at the specified level in that module will @@ -248,3 +265,16 @@ line!() }; } + +#[doc(hidden)] +#[macro_export] +macro_rules! __log_key { + // key1 = 42 + ($($args:ident)*) => { + stringify!($($args)*) + }; + // "key1" = 42 + ($($args:expr)*) => { + $($args)* + }; +} diff -Nru cargo-0.58.0/vendor/miniz_oxide/build.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/build.rs --- cargo-0.58.0/vendor/miniz_oxide/build.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/build.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -#![forbid(unsafe_code)] -use autocfg; - -fn main() { - autocfg::new().emit_sysroot_crate("alloc"); -} diff -Nru cargo-0.58.0/vendor/miniz_oxide/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/miniz_oxide/.cargo-checksum.json --- cargo-0.58.0/vendor/miniz_oxide/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"} \ No newline at end of file +{"files":{},"package":"d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/miniz_oxide/Cargo.toml cargo-0.60.0ubuntu1/vendor/miniz_oxide/Cargo.toml --- cargo-0.58.0/vendor/miniz_oxide/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -3,19 +3,17 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "miniz_oxide" -version = "0.4.4" +version = "0.5.1" authors = ["Frommi ", "oyvindln "] -build = "build.rs" exclude = ["benches/*", "tests/*"] description = "DEFLATE compression and decompression library rewritten in Rust based on miniz" homepage = "https://github.com/Frommi/miniz_oxide/tree/master/miniz_oxide" @@ -32,8 +30,12 @@ version = "1.0" default-features = false -[build-dependencies.autocfg] -version = "1.0" + +[dependencies.simd-adler32] +version = "0.3" +optional = true +default-features = false [features] -no_extern_crate_alloc = [] +default = [] +simd = ["simd-adler32"] diff -Nru cargo-0.58.0/vendor/miniz_oxide/debian/patches/remove-compiler-builtins.patch cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/remove-compiler-builtins.patch --- cargo-0.58.0/vendor/miniz_oxide/debian/patches/remove-compiler-builtins.patch 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/remove-compiler-builtins.patch 2022-04-20 13:48:09.000000000 +0000 @@ -13,6 +13,6 @@ -version = "0.1.2" -optional = true - - [build-dependencies.autocfg] - version = "1.0" + [dependencies.simd-adler32] + version = "0.3" diff -Nru cargo-0.58.0/vendor/miniz_oxide/debian/patches/remove-compiler-builtins.patch.orig cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/remove-compiler-builtins.patch.orig --- cargo-0.58.0/vendor/miniz_oxide/debian/patches/remove-compiler-builtins.patch.orig 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/remove-compiler-builtins.patch.orig 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,18 @@ +Description: remove compiler-builtins feature. + The feature fails to build and the ftpmasters are rejecting new rust + feature packages. +Author: Peter Michael Green + +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -32,10 +32,6 @@ + version = "1.0" + default-features = false + +-[dependencies.compiler_builtins] +-version = "0.1.2" +-optional = true +- + [build-dependencies.autocfg] + version = "1.0" + diff -Nru cargo-0.58.0/vendor/miniz_oxide/debian/patches/remove-rustc-dep-of-std-etc.patch cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/remove-rustc-dep-of-std-etc.patch --- cargo-0.58.0/vendor/miniz_oxide/debian/patches/remove-rustc-dep-of-std-etc.patch 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/remove-rustc-dep-of-std-etc.patch 2022-04-20 13:48:09.000000000 +0000 @@ -1,6 +1,6 @@ --- a/Cargo.toml +++ b/Cargo.toml -@@ -32,22 +32,12 @@ +@@ -32,26 +32,16 @@ version = "1.0" default-features = false @@ -17,9 +17,13 @@ -version = "1.0.0" -optional = true -package = "rustc-std-workspace-core" - [build-dependencies.autocfg] - version = "1.0" + + [dependencies.simd-adler32] + version = "0.3" + optional = true + default-features = false [features] - no_extern_crate_alloc = [] --rustc-dep-of-std = ["core", "alloc", "compiler_builtins", "adler/rustc-dep-of-std"] + default = [] +-rustc-dep-of-std = ["core", "alloc", "compiler_builtins", "adler/rustc-dep-of-std", "simd-adler32/std"] + simd = ["simd-adler32"] diff -Nru cargo-0.58.0/vendor/miniz_oxide/debian/patches/remove-rustc-dep-of-std-etc.patch.orig cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/remove-rustc-dep-of-std-etc.patch.orig --- cargo-0.58.0/vendor/miniz_oxide/debian/patches/remove-rustc-dep-of-std-etc.patch.orig 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/remove-rustc-dep-of-std-etc.patch.orig 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,25 @@ +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -32,22 +32,12 @@ + version = "1.0" + default-features = false + +-[dependencies.alloc] +-version = "1.0.0" +-optional = true +-package = "rustc-std-workspace-alloc" +- + [dependencies.compiler_builtins] + version = "0.1.2" + optional = true + +-[dependencies.core] +-version = "1.0.0" +-optional = true +-package = "rustc-std-workspace-core" + [build-dependencies.autocfg] + version = "1.0" + + [features] + no_extern_crate_alloc = [] +-rustc-dep-of-std = ["core", "alloc", "compiler_builtins", "adler/rustc-dep-of-std"] diff -Nru cargo-0.58.0/vendor/miniz_oxide/debian/patches/series.rej cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/series.rej --- cargo-0.58.0/vendor/miniz_oxide/debian/patches/series.rej 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/series.rej 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,6 @@ +--- miniz_oxide/debian/patches/series ++++ miniz_oxide/debian/patches/series +@@ -1,3 +1,2 @@ + remove-rustc-dep-of-std-etc.patch + remove-compiler-builtins.patch +-use-adler32.patch diff -Nru cargo-0.58.0/vendor/miniz_oxide/debian/patches/use-adler32.patch cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/use-adler32.patch --- cargo-0.58.0/vendor/miniz_oxide/debian/patches/use-adler32.patch 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/debian/patches/use-adler32.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -Revert to using the adler32 crate as the adler crate is not in Debian. - -Reverts https://github.com/Frommi/miniz_oxide/commit/ad0f8fef9c532720fb9603a0341ff7d176af2fc4 - ---- a/src/shared.rs -+++ b/src/shared.rs -@@ -1,4 +1,4 @@ --use adler::Adler32; -+use adler32::RollingAdler32; - - #[doc(hidden)] - pub const MZ_ADLER32_INIT: u32 = 1; -@@ -12,7 +12,7 @@ - - #[doc(hidden)] - pub fn update_adler32(adler: u32, data: &[u8]) -> u32 { -- let mut hash = Adler32::from_checksum(adler); -- hash.write_slice(data); -- hash.checksum() -+ let mut hash = RollingAdler32::from_value(adler); -+ hash.update_buffer(data); -+ hash.hash() - } ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -28,8 +28,8 @@ - - [lib] - name = "miniz_oxide" --[dependencies.adler] --version = "1.0" -+[dependencies.adler32] -+version = "1.1.0" - default-features = false - - [build-dependencies.autocfg] diff -Nru cargo-0.58.0/vendor/miniz_oxide/Readme.md cargo-0.60.0ubuntu1/vendor/miniz_oxide/Readme.md --- cargo-0.58.0/vendor/miniz_oxide/Readme.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/Readme.md 2022-04-20 13:48:09.000000000 +0000 @@ -1,9 +1,15 @@ # miniz_oxide -A pure rust replacement for the [miniz](https://github.com/richgel999/miniz) DEFLATE/zlib encoder/decoder. +A fully safe, pure rust replacement for the [miniz](https://github.com/richgel999/miniz) DEFLATE/zlib encoder/decoder. The main intention of this crate is to be used as a back-end for the [flate2](https://github.com/alexcrichton/flate2-rs), but it can also be used on it's own. Using flate2 with the ```rust_backend``` feature provides an easy to use streaming API for miniz_oxide. -Requires at least rust 1.34. +The library is fully [no_std](https://docs.rust-embedded.org/book/intro/no-std.html), though it requires the use of the `alloc` and `collection` crates as it allocates memory. + +miniz_oxide 0.5.x Requires at least rust 1.40.0 0.3.x requires at least rust 0.36.0. + +miniz_oxide features no use of unsafe code. + +miniz_oxide can optionally be made to use a simd-accelerated version of adler32 via the [simd-adler32](https://crates.io/crates/simd-adler32) crate by enabling the 'simd' feature. This is not enabled by default as due to the use of simd intrinsics, the simd-adler32 has to use unsafe. The default setup uses the [adler](https://crates.io/crates/adler) crate which features no unsafe code. ## Usage Simple compression/decompression: @@ -15,8 +21,11 @@ use miniz_oxide::deflate::compress_to_vec; fn roundtrip(data: &[u8]) { + # compress the input let compressed = compress_to_vec(data, 6); + # decompress the compressed input let decompressed = decompress_to_vec(decompressed.as_slice()).expect("Failed to decompress!"); } ``` +These simple functions will do everything in one go and are thus not recommended for use cases where the input size may be large or unknown, for that use case consider using miniz_oxide via flate2 or the low-level streaming functions instead. diff -Nru cargo-0.58.0/vendor/miniz_oxide/src/deflate/buffer.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/deflate/buffer.rs --- cargo-0.58.0/vendor/miniz_oxide/src/deflate/buffer.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/deflate/buffer.rs 2022-04-20 13:48:09.000000000 +0000 @@ -17,8 +17,9 @@ /// Size of the chained hash tables. pub const LZ_HASH_SIZE: usize = 1 << LZ_HASH_BITS; -pub fn update_hash(current_hash: u32, byte: u8) -> u32 { - ((current_hash << LZ_HASH_SHIFT) ^ u32::from(byte)) & (LZ_HASH_SIZE as u32 - 1) +#[inline] +pub fn update_hash(current_hash: u16, byte: u8) -> u16 { + ((current_hash << LZ_HASH_SHIFT) ^ u16::from(byte)) & (LZ_HASH_SIZE as u16 - 1) } pub struct HashBuffers { diff -Nru cargo-0.58.0/vendor/miniz_oxide/src/deflate/core.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/deflate/core.rs --- cargo-0.58.0/vendor/miniz_oxide/src/deflate/core.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/deflate/core.rs 2022-04-20 13:48:09.000000000 +0000 @@ -209,15 +209,21 @@ /// A list of deflate flush types. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum TDEFLFlush { - /// Compress as much as there is space for, and then return - /// waiting for more input. + /// Normal operation. + /// + /// Compress as much as there is space for, and then return waiting for more input. None = 0, - /// Try to flush the current data and output an empty raw block. + + /// Try to flush all the current data and output an empty raw block. Sync = 2, - /// Same as sync, but reset the dictionary so that the following data does not depend - /// on previous data. + + /// Same as [`Sync`][Self::Sync], but reset the dictionary so that the following data does not + /// depend on previous data. Full = 3, - /// Try to flush everything and end the stream. + + /// Try to flush everything and end the deflate stream. + /// + /// On success this will yield a [`TDEFLStatus::Done`] return status. Finish = 4, } @@ -245,13 +251,27 @@ } } -/// Return status codes. +/// Return status of compression. #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum TDEFLStatus { + /// Usage error. + /// + /// This indicates that either the [`CompressorOxide`] experienced a previous error, or the + /// stream has already been [`TDEFLFlush::Finish`]'d. BadParam = -2, + + /// Error putting data into output buffer. + /// + /// This usually indicates a too-small buffer. PutBufFailed = -1, + + /// Compression succeeded normally. Okay = 0, + + /// Compression succeeded and the deflate stream was ended. + /// + /// This is the result of calling compression with [`TDEFLFlush::Finish`]. Done = 1, } @@ -415,13 +435,13 @@ } /// Get the adler32 checksum of the currently encoded data. - pub fn adler32(&self) -> u32 { + pub const fn adler32(&self) -> u32 { self.params.adler32 } /// Get the return status of the previous [`compress`](fn.compress.html) /// call with this compressor. - pub fn prev_return_status(&self) -> TDEFLStatus { + pub const fn prev_return_status(&self) -> TDEFLStatus { self.params.prev_return_status } @@ -429,7 +449,7 @@ /// /// # Notes /// This function may be deprecated or changed in the future to use more rust-style flags. - pub fn flags(&self) -> i32 { + pub const fn flags(&self) -> i32 { self.params.flags as i32 } @@ -1779,7 +1799,7 @@ let mut ins_pos = lookahead_pos + lookahead_size as usize - 2; // Start the hash value from the first two bytes let mut hash = update_hash( - u32::from(dictb.dict[(ins_pos & LZ_DICT_SIZE_MASK) as usize]), + u16::from(dictb.dict[(ins_pos & LZ_DICT_SIZE_MASK) as usize]), dictb.dict[((ins_pos + 1) & LZ_DICT_SIZE_MASK) as usize], ); @@ -2012,7 +2032,7 @@ // Trigram was tested, so we can start with "+ 3" displacement. let mut p = cur_pos + 3; let mut q = probe_pos + 3; - cur_match_len = 'find_match: loop { + cur_match_len = (|| { for _ in 0..32 { let p_data: u64 = d.dict.read_unaligned_u64(p); let q_data: u64 = d.dict.read_unaligned_u64(q); @@ -2022,16 +2042,16 @@ q += 8; } else { let trailing = xor_data.trailing_zeros(); - break 'find_match p as u32 - cur_pos as u32 + (trailing >> 3); + return p as u32 - cur_pos as u32 + (trailing >> 3); } } - break 'find_match if cur_match_dist == 0 { + if cur_match_dist == 0 { 0 } else { MAX_MATCH_LEN as u32 - }; - }; + } + })(); if cur_match_len < MIN_MATCH_LEN.into() || (cur_match_len == MIN_MATCH_LEN.into() && cur_match_dist >= 8 * 1024) @@ -2172,7 +2192,7 @@ /// /// The value of `flush` determines if the compressor should attempt to flush all output /// and alternatively try to finish the stream. -/// Should be `TDeflflush::Finish` on the final call. +/// Should be [`TDEFLFlush::Finish`] on the final call. /// /// # Returns /// Returns a tuple containing the current status of the compressor, the current position @@ -2357,8 +2377,7 @@ MZ_DEFAULT_WINDOW_BITS, }; use crate::inflate::decompress_to_vec; - use std::prelude::v1::*; - use std::vec; + use alloc::vec; #[test] fn u16_to_slice() { @@ -2401,5 +2420,33 @@ let decoded = decompress_to_vec(&encoded[..]).unwrap(); assert_eq!(&decoded[..], &slice[..]); + } + + #[test] + /// Check fast compress mode + fn compress_fast() { + let slice = [ + 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 1, 2, 6, 1, 2, 3, 1, 2, 3, 2, 3, 1, 2, 3, + ]; + let mut encoded = vec![]; + let flags = create_comp_flags_from_zip_params(1, 0, 0); + let mut d = CompressorOxide::new(flags); + let (status, in_consumed) = + compress_to_output(&mut d, &slice, TDEFLFlush::Finish, |out: &[u8]| { + encoded.extend_from_slice(out); + true + }); + + assert_eq!(status, TDEFLStatus::Done); + assert_eq!(in_consumed, slice.len()); + + // Needs to be altered if algorithm improves. + assert_eq!( + &encoded[..], + [99, 100, 98, 102, 1, 98, 48, 98, 3, 147, 204, 76, 204, 140, 76, 204, 0] + ); + + let decoded = decompress_to_vec(&encoded[..]).unwrap(); + assert_eq!(&decoded[..], &slice[..]); } } diff -Nru cargo-0.58.0/vendor/miniz_oxide/src/deflate/mod.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/deflate/mod.rs --- cargo-0.58.0/vendor/miniz_oxide/src/deflate/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/deflate/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -160,7 +160,7 @@ mod test { use super::{compress_to_vec, compress_to_vec_inner, CompressionStrategy}; use crate::inflate::decompress_to_vec; - use std::vec; + use alloc::vec; /// Test deflate example. /// diff -Nru cargo-0.58.0/vendor/miniz_oxide/src/deflate/stream.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/deflate/stream.rs --- cargo-0.58.0/vendor/miniz_oxide/src/deflate/stream.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/deflate/stream.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,6 +1,6 @@ //! Extra streaming compression functionality. //! -//! As of now this is mainly inteded for use to build a higher-level wrapper. +//! As of now this is mainly intended for use to build a higher-level wrapper. //! //! There is no DeflateState as the needed state is contained in the compressor struct itself. use core::convert::{AsMut, AsRef}; @@ -8,15 +8,18 @@ use crate::deflate::core::{compress, CompressorOxide, TDEFLFlush, TDEFLStatus}; use crate::{MZError, MZFlush, MZStatus, StreamResult}; -/// Try to compress from input to output with the given Compressor +/// Try to compress from input to output with the given [`CompressorOxide`]. /// /// # Errors /// -/// Returns `MZError::Buf` If the size of the `output` slice is empty or no progress was made due to -/// lack of expected input data or called after the compression was finished without -/// MZFlush::Finish. +/// Returns [`MZError::Buf`] If the size of the `output` slice is empty or no progress was made due +/// to lack of expected input data, or if called without [`MZFlush::Finish`] after the compression +/// was already finished. /// -/// Returns `MZError::Param` if the compressor parameters are set wrong. +/// Returns [`MZError::Param`] if the compressor parameters are set wrong. +/// +/// Returns [`MZError::Stream`] when lower-level decompressor returns a +/// [`TDEFLStatus::PutBufFailed`]; may not actually be possible. pub fn deflate( compressor: &mut CompressorOxide, input: &[u8], @@ -100,8 +103,8 @@ use crate::deflate::CompressorOxide; use crate::inflate::decompress_to_vec_zlib; use crate::{MZFlush, MZStatus}; - use std::prelude::v1::*; - use std::vec; + use alloc::boxed::Box; + use alloc::vec; #[test] fn test_state() { diff -Nru cargo-0.58.0/vendor/miniz_oxide/src/inflate/core.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/inflate/core.rs --- cargo-0.58.0/vendor/miniz_oxide/src/inflate/core.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/inflate/core.rs 2022-04-20 13:48:09.000000000 +0000 @@ -102,15 +102,50 @@ const DIST_TABLE: usize = 1; const HUFFLEN_TABLE: usize = 2; +/// Flags to [`decompress()`] to control how inflation works. +/// +/// These define bits for a bitmask argument. pub mod inflate_flags { /// Should we try to parse a zlib header? + /// + /// If unset, [`decompress()`] will expect an RFC1951 deflate stream. If set, it will expect an + /// RFC1950 zlib wrapper around the deflate stream. pub const TINFL_FLAG_PARSE_ZLIB_HEADER: u32 = 1; - /// There is more input that hasn't been given to the decompressor yet. + + /// There will be more input that hasn't been given to the decompressor yet. + /// + /// This is useful when you want to decompress what you have so far, + /// even if you know there is probably more input that hasn't gotten here yet (_e.g._, over a + /// network connection). When [`decompress()`][super::decompress] reaches the end of the input + /// without finding the end of the compressed stream, it will return + /// [`TINFLStatus::NeedsMoreInput`][super::TINFLStatus::NeedsMoreInput] if this is set, + /// indicating that you should get more data before calling again. If not set, it will return + /// [`TINFLStatus::FailedCannotMakeProgress`][super::TINFLStatus::FailedCannotMakeProgress] + /// suggesting the stream is corrupt, since you claimed it was all there. pub const TINFL_FLAG_HAS_MORE_INPUT: u32 = 2; + /// The output buffer should not wrap around. pub const TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: u32 = 4; - /// Should we calculate the adler32 checksum of the output data? + + /// Calculate the adler32 checksum of the output data even if we're not inflating a zlib stream. + /// + /// If [`TINFL_FLAG_IGNORE_ADLER32`] is specified, it will override this. + /// + /// NOTE: Enabling/disabling this between calls to decompress will result in an incorect + /// checksum. pub const TINFL_FLAG_COMPUTE_ADLER32: u32 = 8; + + /// Ignore adler32 checksum even if we are inflating a zlib stream. + /// + /// Overrides [`TINFL_FLAG_COMPUTE_ADLER32`] if both are enabled. + /// + /// NOTE: This flag does not exist in miniz as it does not support this and is a + /// custom addition for miniz_oxide. + /// + /// NOTE: Should not be changed from enabled to disabled after decompression has started, + /// this will result in checksum failure (outside the unlikely event where the checksum happens + /// to match anyway). + pub const TINFL_FLAG_IGNORE_ADLER32: u32 = 64; } use self::inflate_flags::*; @@ -174,6 +209,7 @@ } /// Returns the adler32 checksum of the currently decompressed data. + /// Note: Will return Some(1) if decompressing zlib but ignoring adler32. #[inline] pub fn adler32(&self) -> Option { if self.state != State::Start && !self.state.is_failure() && self.z_header0 != 0 { @@ -182,6 +218,16 @@ None } } + + /// Returns the adler32 that was read from the zlib header if it exists. + #[inline] + pub fn adler32_header(&self) -> Option { + if self.state != State::Start && self.state != State::BadZlibHeader && self.z_header0 != 0 { + Some(self.z_adler32) + } else { + None + } + } } impl Default for DecompressorOxide { @@ -983,19 +1029,21 @@ } /// Main decompression function. Keeps decompressing data from `in_buf` until the `in_buf` is -/// empty, `out_cur` is full, the end of the deflate stream is hit, or there is an error in the +/// empty, `out` is full, the end of the deflate stream is hit, or there is an error in the /// deflate stream. /// /// # Arguments /// +/// `r` is a [`DecompressorOxide`] struct with the state of this stream. +/// /// `in_buf` is a reference to the compressed data that is to be decompressed. The decompressor will /// start at the first byte of this buffer. /// -/// `out_cur` is a mutable cursor into the buffer that will store the decompressed data, and that +/// `out` is a reference to the buffer that will store the decompressed data, and that /// stores previously decompressed data if any. -/// * The position of the output cursor indicates where in the output buffer slice writing should -/// start. -/// * If TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF is not set, the output buffer is used in a +/// +/// * The offset given by `out_pos` indicates where in the output buffer slice writing should start. +/// * If [`TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF`] is not set, the output buffer is used in a /// wrapping manner, and it's size is required to be a power of 2. /// * The decompression function normally needs access to 32KiB of the previously decompressed data ///(or to the beginning of the decompressed data if less than 32KiB has been decompressed.) @@ -1005,16 +1053,15 @@ /// and thus allows a smaller output buffer. The window size can be specified in the zlib /// header structure, however, the header data should not be relied on to be correct. /// -/// `flags` -/// Flags to indicate settings and status to the decompression function. -/// * The `TINFL_FLAG_HAS_MORE_INPUT` has to be specified if more compressed data is to be provided +/// `flags` indicates settings and status to the decompression function. +/// * The [`TINFL_FLAG_HAS_MORE_INPUT`] has to be specified if more compressed data is to be provided /// in a subsequent call to this function. -/// * See the the [`inflate_flags`](inflate_flags/index.html) module for details on other flags. +/// * See the the [`inflate_flags`] module for details on other flags. /// /// # Returns -/// returns a tuple containing the status of the compressor, the number of input bytes read, and the -/// number of bytes output to `out_cur`. -/// Updates the position of `out_cur` to point to the next free spot in the output buffer. +/// +/// Returns a tuple containing the status of the compressor, the number of input bytes read, and the +/// number of bytes output to `out`. /// /// This function shouldn't panic pending any bugs. pub fn decompress( @@ -1616,7 +1663,12 @@ // If this is a zlib stream, and update the adler32 checksum with the decompressed bytes if // requested. - let need_adler = flags & (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32) != 0; + let need_adler = if (flags & TINFL_FLAG_IGNORE_ADLER32) == 0 { + flags & (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32) != 0 + } else { + // If TINFL_FLAG_IGNORE_ADLER32 is enabled, ignore the checksum. + false + }; if need_adler && status as i32 >= 0 { let out_buf_pos = out_buf.position(); r.check_adler32 = update_adler32(r.check_adler32, &out_buf.get_ref()[out_pos..out_buf_pos]); diff -Nru cargo-0.58.0/vendor/miniz_oxide/src/inflate/mod.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/inflate/mod.rs --- cargo-0.58.0/vendor/miniz_oxide/src/inflate/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/inflate/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -23,20 +23,41 @@ #[repr(i8)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum TINFLStatus { - /// More input data was expected, but the caller indicated that there was more data, so the + /// More input data was expected, but the caller indicated that there was no more data, so the /// input stream is likely truncated. + /// + /// This can't happen if you have provided the + /// [`TINFL_FLAG_HAS_MORE_INPUT`][core::inflate_flags::TINFL_FLAG_HAS_MORE_INPUT] flag to the + /// decompression. By setting that flag, you indicate more input exists but is not provided, + /// and so reaching the end of the input data without finding the end of the compressed stream + /// would instead return a [`NeedsMoreInput`][Self::NeedsMoreInput] status. FailedCannotMakeProgress = TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS as i8, - /// One or more of the input parameters were invalid. + + /// The output buffer is an invalid size; consider the `flags` parameter. BadParam = TINFL_STATUS_BAD_PARAM as i8, + /// The decompression went fine, but the adler32 checksum did not match the one /// provided in the header. Adler32Mismatch = TINFL_STATUS_ADLER32_MISMATCH as i8, + /// Failed to decompress due to invalid data. Failed = TINFL_STATUS_FAILED as i8, - /// Finished decomression without issues. + + /// Finished decompression without issues. + /// + /// This indicates the end of the compressed stream has been reached. Done = TINFL_STATUS_DONE as i8, + /// The decompressor needs more input data to continue decompressing. + /// + /// This occurs when there's no more consumable input, but the end of the stream hasn't been + /// reached, and you have supplied the + /// [`TINFL_FLAG_HAS_MORE_INPUT`][core::inflate_flags::TINFL_FLAG_HAS_MORE_INPUT] flag to the + /// decompressor. Had you not supplied that flag (which would mean you were asserting that you + /// believed all the data was available) you would have gotten a + /// [`FailedCannotMakeProcess`][Self::FailedCannotMakeProgress] instead. NeedsMoreInput = TINFL_STATUS_NEEDS_MORE_INPUT as i8, + /// There is still pending data that didn't fit in the output buffer. HasMoreOutput = TINFL_STATUS_HAS_MORE_OUTPUT as i8, } @@ -59,7 +80,7 @@ /// Decompress the deflate-encoded data in `input` to a vector. /// -/// Returns a status and an integer representing where the decompressor failed on failure. +/// Returns a tuple of the [`Vec`] of decompressed data and the [status result][TINFLStatus]. #[inline] pub fn decompress_to_vec(input: &[u8]) -> Result, TINFLStatus> { decompress_to_vec_inner(input, 0, usize::max_value()) @@ -67,7 +88,7 @@ /// Decompress the deflate-encoded data (with a zlib wrapper) in `input` to a vector. /// -/// Returns a status and an integer representing where the decompressor failed on failure. +/// Returns a tuple of the [`Vec`] of decompressed data and the [status result][TINFLStatus]. #[inline] pub fn decompress_to_vec_zlib(input: &[u8]) -> Result, TINFLStatus> { decompress_to_vec_inner( @@ -79,9 +100,9 @@ /// Decompress the deflate-encoded data in `input` to a vector. /// The vector is grown to at most `max_size` bytes; if the data does not fit in that size, -/// `TINFLStatus::HasMoreOutput` error is returned. +/// [`TINFLStatus::HasMoreOutput`] error is returned. /// -/// Returns a status and an integer representing where the decompressor failed on failure. +/// Returns a tuple of the [`Vec`] of decompressed data and the [status result][TINFLStatus]. #[inline] pub fn decompress_to_vec_with_limit(input: &[u8], max_size: usize) -> Result, TINFLStatus> { decompress_to_vec_inner(input, 0, max_size) @@ -89,9 +110,9 @@ /// Decompress the deflate-encoded data (with a zlib wrapper) in `input` to a vector. /// The vector is grown to at most `max_size` bytes; if the data does not fit in that size, -/// `TINFLStatus::HasMoreOutput` error is returned. +/// [`TINFLStatus::HasMoreOutput`] error is returned. /// -/// Returns a status and an integer representing where the decompressor failed on failure. +/// Returns a tuple of the [`Vec`] of decompressed data and the [status result][TINFLStatus]. #[inline] pub fn decompress_to_vec_zlib_with_limit( input: &[u8], @@ -100,6 +121,9 @@ decompress_to_vec_inner(input, inflate_flags::TINFL_FLAG_PARSE_ZLIB_HEADER, max_size) } +/// Backend of various to-[`Vec`] decompressions. +/// +/// Returns a tuple of the [`Vec`] of decompressed data and the [status result][TINFLStatus]. fn decompress_to_vec_inner( input: &[u8], flags: u32, diff -Nru cargo-0.58.0/vendor/miniz_oxide/src/inflate/output_buffer.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/inflate/output_buffer.rs --- cargo-0.58.0/vendor/miniz_oxide/src/inflate/output_buffer.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/inflate/output_buffer.rs 2022-04-20 13:48:09.000000000 +0000 @@ -44,7 +44,7 @@ } #[inline] - pub fn bytes_left(&self) -> usize { + pub const fn bytes_left(&self) -> usize { self.slice.len() - self.position } diff -Nru cargo-0.58.0/vendor/miniz_oxide/src/inflate/stream.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/inflate/stream.rs --- cargo-0.58.0/vendor/miniz_oxide/src/inflate/stream.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/inflate/stream.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,6 +1,6 @@ //! Extra streaming decompression functionality. //! -//! As of now this is mainly inteded for use to build a higher-level wrapper. +//! As of now this is mainly intended for use to build a higher-level wrapper. use crate::alloc::boxed::Box; use core::{cmp, mem}; @@ -155,15 +155,29 @@ } } -/// Try to decompress from `input` to `output` with the given `InflateState` +/// Try to decompress from `input` to `output` with the given [`InflateState`] +/// +/// # `flush` +/// +/// Generally, the various [`MZFlush`] flags have meaning only on the compression side. They can be +/// supplied here, but the only one that has any semantic meaning is [`MZFlush::Finish`], which is a +/// signal that the stream is expected to finish, and failing to do so is an error. It isn't +/// necessary to specify it when the stream ends; you'll still get returned a +/// [`MZStatus::StreamEnd`] anyway. Other values either have no effect or cause errors. It's +/// likely that you'll almost always just want to use [`MZFlush::None`]. /// /// # Errors /// -/// Returns `MZError::Buf` If the size of the `output` slice is empty or no progress was made due to -/// lack of expected input data or called after the decompression was -/// finished without MZFlush::Finish. +/// Returns [`MZError::Buf`] if the size of the `output` slice is empty or no progress was made due +/// to lack of expected input data, or if called with [`MZFlush::Finish`] and input wasn't all +/// consumed. +/// +/// Returns [`MZError::Data`] if this or a a previous call failed with an error return from +/// [`TINFLStatus`]; probably indicates corrupted data. /// -/// Returns `MZError::Param` if the compressor parameters are set wrong. +/// Returns [`MZError::Stream`] when called with [`MZFlush::Full`] (meaningless on +/// decompression), or when called without [`MZFlush::Finish`] after an earlier call with +/// [`MZFlush::Finish`] has been made. pub fn inflate( state: &mut InflateState, input: &[u8], @@ -179,8 +193,15 @@ return StreamResult::error(MZError::Stream); } - let mut decomp_flags = inflate_flags::TINFL_FLAG_COMPUTE_ADLER32; - if state.data_format == DataFormat::Zlib { + let mut decomp_flags = if state.data_format == DataFormat::Zlib { + inflate_flags::TINFL_FLAG_COMPUTE_ADLER32 + } else { + inflate_flags::TINFL_FLAG_IGNORE_ADLER32 + }; + + if (state.data_format == DataFormat::Zlib) + | (state.data_format == DataFormat::ZLibIgnoreChecksum) + { decomp_flags |= inflate_flags::TINFL_FLAG_PARSE_ZLIB_HEADER; } @@ -344,7 +365,7 @@ mod test { use super::{inflate, InflateState}; use crate::{DataFormat, MZFlush, MZStatus}; - use std::vec; + use alloc::vec; #[test] fn test_state() { @@ -375,5 +396,19 @@ assert_eq!(status, MZStatus::StreamEnd); assert_eq!(out[..res.bytes_written as usize], b"Hello, zlib!"[..]); assert_eq!(res.bytes_consumed, encoded.len()); + assert_eq!(state.decompressor().adler32(), Some(459605011)); + + // Test state when not computing adler. + state = InflateState::new_boxed(DataFormat::ZLibIgnoreChecksum); + out.iter_mut().map(|x| *x = 0).count(); + let res = inflate(&mut state, &encoded, &mut out, MZFlush::Finish); + let status = res.status.expect("Failed to decompress!"); + assert_eq!(status, MZStatus::StreamEnd); + assert_eq!(out[..res.bytes_written as usize], b"Hello, zlib!"[..]); + assert_eq!(res.bytes_consumed, encoded.len()); + // Not computed, so should be Some(1) + assert_eq!(state.decompressor().adler32(), Some(1)); + // Should still have the checksum read from the header file. + assert_eq!(state.decompressor().adler32_header(), Some(459605011)) } } diff -Nru cargo-0.58.0/vendor/miniz_oxide/src/lib.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/lib.rs --- cargo-0.58.0/vendor/miniz_oxide/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -23,16 +23,9 @@ #![allow(warnings)] #![forbid(unsafe_code)] -#![cfg_attr(any(has_alloc, feature = "rustc-dep-of-std"), no_std)] +#![no_std] -// autocfg does not work when building in libstd, so manually enable this for that use case now. -#[cfg(any(has_alloc, feature = "rustc-dep-of-std"))] extern crate alloc; -#[cfg(all(not(has_alloc), not(feature = "rustc-dep-of-std")))] -use std as alloc; - -#[cfg(test)] -extern crate std; pub mod deflate; pub mod inflate; @@ -43,7 +36,7 @@ /// A list of flush types. /// -/// See [http://www.bolet.org/~pornin/deflate-flush.html] for more in-depth info. +/// See for more in-depth info. #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum MZFlush { @@ -51,14 +44,15 @@ /// Used when more input data is expected. None = 0, /// Zlib partial flush. - /// Currently treated as `Sync`. + /// Currently treated as [`Sync`]. Partial = 1, /// Finish compressing the currently buffered data, and output an empty raw block. /// Has no use in decompression. Sync = 2, - /// Same as `Sync`, but resets the compression dictionary so that further compressed + /// Same as [`Sync`], but resets the compression dictionary so that further compressed /// data does not depend on data compressed before the flush. - /// Has no use in decompression. + /// + /// Has no use in decompression, and is an error to supply in that case. Full = 3, /// Attempt to flush the remaining data and end the stream. Finish = 4, @@ -82,32 +76,80 @@ } /// A list of miniz successful status codes. +/// +/// These are emitted as the [`Ok`] side of a [`MZResult`] in the [`StreamResult`] returned from +/// [`deflate::stream::deflate()`] or [`inflate::stream::inflate()`]. #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum MZStatus { + /// Operation succeeded. + /// + /// Some data was decompressed or compressed; see the byte counters in the [`StreamResult`] for + /// details. Ok = 0, + + /// Operation succeeded and end of deflate stream was found. + /// + /// X-ref [`TINFLStatus::Done`][inflate::TINFLStatus::Done] or + /// [`TDEFLStatus::Done`][deflate::core::TDEFLStatus::Done] for `inflate` or `deflate` + /// respectively. StreamEnd = 1, + + /// Unused NeedDict = 2, } /// A list of miniz failed status codes. +/// +/// These are emitted as the [`Err`] side of a [`MZResult`] in the [`StreamResult`] returned from +/// [`deflate::stream::deflate()`] or [`inflate::stream::inflate()`]. #[repr(i32)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum MZError { + /// Unused ErrNo = -1, + + /// General stream error. + /// + /// See [`inflate::stream::inflate()`] docs for details of how it can occur there. + /// + /// See [`deflate::stream::deflate()`] docs for how it can in principle occur there, though it's + /// believed impossible in practice. Stream = -2, + + /// Error in inflation; see [`inflate::stream::inflate()`] for details. + /// + /// Not returned from [`deflate::stream::deflate()`]. Data = -3, + + /// Unused Mem = -4, + + /// Buffer-related error. + /// + /// See the docs of [`deflate::stream::deflate()`] or [`inflate::stream::inflate()`] for details + /// of when it would trigger in the one you're using. Buf = -5, + + /// Unused Version = -6, + + /// Bad parameters. + /// + /// This can be returned from [`deflate::stream::deflate()`] in the case of bad parameters. See + /// [`TDEFLStatus::BadParam`][deflate::core::TDEFLStatus::BadParam]. Param = -10_000, } /// How compressed data is wrapped. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[non_exhaustive] pub enum DataFormat { /// Wrapped using the [zlib](http://www.zlib.org/rfc-zlib.html) format. Zlib, + /// Zlib wrapped but ignore and don't compute the adler32 checksum. + /// Currently only used for inflate, behaves the same as Zlib for compression. + ZLibIgnoreChecksum, /// Raw DEFLATE. Raw, } @@ -123,7 +165,7 @@ pub(crate) fn to_window_bits(self) -> i32 { match self { - DataFormat::Zlib => shared::MZ_DEFAULT_WINDOW_BITS, + DataFormat::Zlib | DataFormat::ZLibIgnoreChecksum => shared::MZ_DEFAULT_WINDOW_BITS, DataFormat::Raw => -shared::MZ_DEFAULT_WINDOW_BITS, } } @@ -145,7 +187,7 @@ impl StreamResult { #[inline] - pub(crate) fn error(error: MZError) -> StreamResult { + pub(crate) const fn error(error: MZError) -> StreamResult { StreamResult { bytes_consumed: 0, bytes_written: 0, diff -Nru cargo-0.58.0/vendor/miniz_oxide/src/shared.rs cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/shared.rs --- cargo-0.58.0/vendor/miniz_oxide/src/shared.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/miniz_oxide/src/shared.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,5 +1,3 @@ -use adler::Adler32; - #[doc(hidden)] pub const MZ_ADLER32_INIT: u32 = 1; @@ -11,8 +9,17 @@ ]; #[doc(hidden)] +#[cfg(not(feature = "simd"))] pub fn update_adler32(adler: u32, data: &[u8]) -> u32 { - let mut hash = Adler32::from_checksum(adler); + let mut hash = adler::Adler32::from_checksum(adler); hash.write_slice(data); hash.checksum() } + +#[doc(hidden)] +#[cfg(feature = "simd")] +pub fn update_adler32(adler: u32, data: &[u8]) -> u32 { + let mut hash = simd_adler32::Adler32::from_checksum(adler); + hash.write(data); + hash.finish() +} diff -Nru cargo-0.58.0/vendor/num_cpus/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/num_cpus/.cargo-checksum.json --- cargo-0.58.0/vendor/num_cpus/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"} \ No newline at end of file +{"files":{},"package":"19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/num_cpus/Cargo.lock cargo-0.60.0ubuntu1/vendor/num_cpus/Cargo.lock --- cargo-0.58.0/vendor/num_cpus/Cargo.lock 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -1,26 +1,26 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "hermit-abi" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "libc" version = "0.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.13.1" dependencies = [ - "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi", + "libc", ] - -[metadata] -"checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" -"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" diff -Nru cargo-0.58.0/vendor/num_cpus/Cargo.toml cargo-0.60.0ubuntu1/vendor/num_cpus/Cargo.toml --- cargo-0.58.0/vendor/num_cpus/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -3,23 +3,24 @@ # 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 = "num_cpus" -version = "1.13.0" +version = "1.13.1" authors = ["Sean McArthur "] description = "Get the number of CPUs on a machine." documentation = "https://docs.rs/num_cpus" readme = "README.md" keywords = ["cpu", "cpus", "cores"] categories = ["hardware-support"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" repository = "https://github.com/seanmonstar/num_cpus" -[dependencies.libc] +[target."cfg(all(any(target_arch = \"x86_64\", target_arch = \"aarch64\"), target_os = \"hermit\"))".dependencies.hermit-abi] +version = "0.1.3" +[target."cfg(not(windows))".dependencies.libc] version = "0.2.26" diff -Nru cargo-0.58.0/vendor/num_cpus/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/num_cpus/CHANGELOG.md --- cargo-0.58.0/vendor/num_cpus/CHANGELOG.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/CHANGELOG.md 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,9 @@ +## v1.13.1 + +### Fixes + +- fix parsing zero or multiple optional fields in cgroup mountinfo. + ## v1.13.0 ### Features diff -Nru cargo-0.58.0/vendor/num_cpus/ci/cgroups/Dockerfile cargo-0.60.0ubuntu1/vendor/num_cpus/ci/cgroups/Dockerfile --- cargo-0.58.0/vendor/num_cpus/ci/cgroups/Dockerfile 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/ci/cgroups/Dockerfile 2022-04-20 13:48:09.000000000 +0000 @@ -1,4 +1,4 @@ -FROM rust:1.40 +FROM rust:latest WORKDIR /usr/num_cpus diff -Nru cargo-0.58.0/vendor/num_cpus/debian/patches/series cargo-0.60.0ubuntu1/vendor/num_cpus/debian/patches/series --- cargo-0.58.0/vendor/num_cpus/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -1 +0,0 @@ -disable-hermit-os.diff diff -Nru cargo-0.58.0/vendor/num_cpus/fixtures/cgroups/proc/cgroups/mountinfo_multi_opt cargo-0.60.0ubuntu1/vendor/num_cpus/fixtures/cgroups/proc/cgroups/mountinfo_multi_opt --- cargo-0.58.0/vendor/num_cpus/fixtures/cgroups/proc/cgroups/mountinfo_multi_opt 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/fixtures/cgroups/proc/cgroups/mountinfo_multi_opt 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,8 @@ +1 0 8:1 / / rw,noatime shared:1 - ext4 /dev/sda1 rw,errors=remount-ro,data=reordered +2 1 0:1 / /dev rw,relatime shared:2 - devtmpfs udev rw,size=10240k,nr_inodes=16487629,mode=755 +3 1 0:2 / /proc rw,nosuid,nodev,noexec,relatime shared:3 - proc proc rw +4 1 0:3 / /sys rw,nosuid,nodev,noexec,relatime shared:4 - sysfs sysfs rw +5 4 0:4 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:5 - tmpfs tmpfs ro,mode=755 +6 5 0:5 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:6 - cgroup cgroup rw,cpuset +7 5 0:6 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:7 shared:8 shared:9 - cgroup cgroup rw,cpu,cpuacct +8 5 0:7 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:8 - cgroup cgroup rw,memory diff -Nru cargo-0.58.0/vendor/num_cpus/fixtures/cgroups/proc/cgroups/mountinfo_zero_opt cargo-0.60.0ubuntu1/vendor/num_cpus/fixtures/cgroups/proc/cgroups/mountinfo_zero_opt --- cargo-0.58.0/vendor/num_cpus/fixtures/cgroups/proc/cgroups/mountinfo_zero_opt 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/fixtures/cgroups/proc/cgroups/mountinfo_zero_opt 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,8 @@ +1 0 8:1 / / rw,noatime shared:1 - ext4 /dev/sda1 rw,errors=remount-ro,data=reordered +2 1 0:1 / /dev rw,relatime shared:2 - devtmpfs udev rw,size=10240k,nr_inodes=16487629,mode=755 +3 1 0:2 / /proc rw,nosuid,nodev,noexec,relatime shared:3 - proc proc rw +4 1 0:3 / /sys rw,nosuid,nodev,noexec,relatime shared:4 - sysfs sysfs rw +5 4 0:4 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:5 - tmpfs tmpfs ro,mode=755 +6 5 0:5 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:6 - cgroup cgroup rw,cpuset +7 5 0:6 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu,cpuacct +8 5 0:7 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:8 - cgroup cgroup rw,memory diff -Nru cargo-0.58.0/vendor/num_cpus/README.md cargo-0.60.0ubuntu1/vendor/num_cpus/README.md --- cargo-0.58.0/vendor/num_cpus/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -1,6 +1,6 @@ # num_cpus -[![crates.io](http://meritbadge.herokuapp.com/num_cpus)](https://crates.io/crates/num_cpus) +[![crates.io](https://img.shields.io/crates/v/num_cpus.svg)](https://crates.io/crates/num_cpus) [![Travis CI Status](https://travis-ci.org/seanmonstar/num_cpus.svg?branch=master)](https://travis-ci.org/seanmonstar/num_cpus) [![AppVeyor status](https://ci.appveyor.com/api/projects/status/qn8t6grhko5jwno6?svg=true)](https://ci.appveyor.com/project/seanmonstar/num-cpus) diff -Nru cargo-0.58.0/vendor/num_cpus/src/lib.rs cargo-0.60.0ubuntu1/vendor/num_cpus/src/lib.rs --- cargo-0.58.0/vendor/num_cpus/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -28,7 +28,6 @@ //! [`rayon::ThreadPool`]: https://docs.rs/rayon/1.*/rayon/struct.ThreadPool.html #![cfg_attr(test, deny(warnings))] #![deny(missing_docs)] -#![doc(html_root_url = "https://docs.rs/num_cpus/1.13.0")] #![allow(non_snake_case)] #[cfg(not(windows))] @@ -47,6 +46,8 @@ /// This function will get the number of logical cores. Sometimes this is different from the number /// of physical cores (See [Simultaneous multithreading on Wikipedia][smt]). /// +/// This will always return at least `1`. +/// /// # Examples /// /// ``` @@ -75,6 +76,8 @@ /// Returns the number of physical cores of the current system. /// +/// This will always return at least `1`. +/// /// # Note /// /// Physical count is supported only on Linux, mac OS and Windows platforms. diff -Nru cargo-0.58.0/vendor/num_cpus/src/linux.rs cargo-0.60.0ubuntu1/vendor/num_cpus/src/linux.rs --- cargo-0.58.0/vendor/num_cpus/src/linux.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/num_cpus/src/linux.rs 2022-04-20 13:48:09.000000000 +0000 @@ -18,7 +18,7 @@ } macro_rules! some { - ($e:expr) => ({ + ($e:expr) => {{ match $e { Some(v) => v, None => { @@ -26,7 +26,7 @@ return None; } } - }) + }}; } pub fn get_num_cpus() -> usize { @@ -126,18 +126,15 @@ // Should only be called once debug_assert!(CGROUPS_CPUS.load(Ordering::SeqCst) == 0); - match load_cgroups("/proc/self/cgroup", "/proc/self/mountinfo") { - Some(quota) => { - if quota == 0 { - return; - } + if let Some(quota) = load_cgroups("/proc/self/cgroup", "/proc/self/mountinfo") { + if quota == 0 { + return; + } - let logical = logical_cpus(); - let count = ::std::cmp::min(quota, logical); + let logical = logical_cpus(); + let count = ::std::cmp::min(quota, logical); - CGROUPS_CPUS.store(count, Ordering::SeqCst); - } - None => return, + CGROUPS_CPUS.store(count, Ordering::SeqCst); } } @@ -167,18 +164,14 @@ impl Cgroup { fn new(dir: PathBuf) -> Cgroup { - Cgroup { - base: dir, - } + Cgroup { base: dir } } fn translate(mntinfo: MountInfo, subsys: Subsys) -> Option { // Translate the subsystem directory via the host paths. debug!( "subsys = {:?}; root = {:?}; mount_point = {:?}", - subsys.base, - mntinfo.root, - mntinfo.mount_point + subsys.base, mntinfo.root, mntinfo.mount_point ); let rel_from_root = some!(Path::new(&subsys.base).strip_prefix(&mntinfo.root).ok()); @@ -238,13 +231,27 @@ fn parse_line(line: String) -> Option { let mut fields = line.split(' '); + // 7 5 0:6 /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:7 - cgroup cgroup rw,cpu,cpuacct let mnt_root = some!(fields.nth(3)); - let mnt_point = some!(fields.nth(0)); + // 7 5 0:6 / rw,nosuid,nodev,noexec,relatime shared:7 - cgroup cgroup rw,cpu,cpuacct + let mnt_point = some!(fields.next()); + + // Ignore all fields until the separator(-). + // Note: there could be zero or more optional fields before hyphen. + // See: https://man7.org/linux/man-pages/man5/proc.5.html + // 7 5 0:6 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:7 <-> cgroup cgroup rw,cpu,cpuacct + // Note: we cannot use `?` here because we need to support Rust 1.13. + match fields.find(|&s| s == "-") { + Some(_) => {} + None => return None, + }; - if fields.nth(3) != Some("cgroup") { + // 7 5 0:6 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:7 - cgroup rw,cpu,cpuacct + if fields.next() != Some("cgroup") { return None; } + // 7 5 0:6 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:7 - cgroup cgroup let super_opts = some!(fields.nth(1)); // We only care about the 'cpu' option @@ -281,16 +288,18 @@ return None; } - fields.next().map(|path| Subsys { base: path.to_owned() }) + fields.next().map(|path| Subsys { + base: path.to_owned(), + }) } } #[cfg(test)] mod tests { - use std::path::{Path, PathBuf}; use super::{Cgroup, MountInfo, Subsys}; + use std::path::{Path, PathBuf}; - + // `static_in_const` feature is not stable in Rust 1.13. static FIXTURES_PROC: &'static str = "fixtures/cgroups/proc/cgroups"; static FIXTURES_CGROUPS: &'static str = "fixtures/cgroups/cgroups"; @@ -304,12 +313,29 @@ #[test] fn test_load_mountinfo() { + // test only one optional fields let path = join!(FIXTURES_PROC, "mountinfo"); let mnt_info = MountInfo::load_cpu(path).unwrap(); assert_eq!(mnt_info.root, "/"); assert_eq!(mnt_info.mount_point, "/sys/fs/cgroup/cpu,cpuacct"); + + // test zero optional field + let path = join!(FIXTURES_PROC, "mountinfo_zero_opt"); + + let mnt_info = MountInfo::load_cpu(path).unwrap(); + + assert_eq!(mnt_info.root, "/"); + assert_eq!(mnt_info.mount_point, "/sys/fs/cgroup/cpu,cpuacct"); + + // test multi optional fields + let path = join!(FIXTURES_PROC, "mountinfo_multi_opt"); + + let mnt_info = MountInfo::load_cpu(path).unwrap(); + + assert_eq!(mnt_info.root, "/"); + assert_eq!(mnt_info.mount_point, "/sys/fs/cgroup/cpu,cpuacct"); } #[test] @@ -324,12 +350,7 @@ #[test] fn test_cgroup_mount() { let cases = &[ - ( - "/", - "/sys/fs/cgroup/cpu", - "/", - Some("/sys/fs/cgroup/cpu"), - ), + ("/", "/sys/fs/cgroup/cpu", "/", Some("/sys/fs/cgroup/cpu")), ( "/docker/01abcd", "/sys/fs/cgroup/cpu", @@ -348,27 +369,10 @@ "/docker/01abcd/large", Some("/sys/fs/cgroup/cpu/large"), ), - // fails - - ( - "/docker/01abcd", - "/sys/fs/cgroup/cpu", - "/", - None, - ), - ( - "/docker/01abcd", - "/sys/fs/cgroup/cpu", - "/docker", - None, - ), - ( - "/docker/01abcd", - "/sys/fs/cgroup/cpu", - "/elsewhere", - None, - ), + ("/docker/01abcd", "/sys/fs/cgroup/cpu", "/", None), + ("/docker/01abcd", "/sys/fs/cgroup/cpu", "/docker", None), + ("/docker/01abcd", "/sys/fs/cgroup/cpu", "/elsewhere", None), ( "/docker/01abcd", "/sys/fs/cgroup/cpu", @@ -387,7 +391,7 @@ }; let actual = Cgroup::translate(mnt_info, subsys).map(|c| c.base); - let expected = expected.map(|s| PathBuf::from(s)); + let expected = expected.map(PathBuf::from); assert_eq!(actual, expected); } } diff -Nru cargo-0.58.0/vendor/once_cell/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/once_cell/.cargo-checksum.json --- cargo-0.58.0/vendor/once_cell/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"} \ No newline at end of file +{"files":{},"package":"87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/once_cell/Cargo.lock cargo-0.60.0ubuntu1/vendor/once_cell/Cargo.lock --- cargo-0.58.0/vendor/once_cell/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -1,357 +1,367 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aho-corasick" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr", ] [[package]] name = "atomic-polyfill" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6adc1648f03fbc1bc1b5cf0f2fdfb5edbc96215b711edcfe6ce2641ef9b347" dependencies = [ - "critical-section 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "riscv-target 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "critical-section", + "riscv-target", ] [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bare-metal" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" dependencies = [ - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version", ] [[package]] name = "bare-metal" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" [[package]] name = "bit_field" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" [[package]] name = "bitfield" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cfg-if" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cortex-m" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ff967e867ca14eba0c34ac25cd71ea98c678e741e3915d923999bb2fe7c826" dependencies = [ - "bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", - "embedded-hal 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "volatile-register 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bare-metal 0.2.5", + "bitfield", + "embedded-hal", + "volatile-register", ] [[package]] name = "critical-section" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01e191a5a6f6edad9b679777ef6b6c0f2bdd4a333f2ecb8f61c3e28109a03d70" dependencies = [ - "bare-metal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cortex-m 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "riscv 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bare-metal 1.0.0", + "cfg-if 1.0.0", + "cortex-m", + "riscv", ] [[package]] name = "crossbeam-utils" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cfg-if 0.1.5", + "lazy_static", ] [[package]] name = "embedded-hal" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" dependencies = [ - "nb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nb 0.1.3", + "void", ] [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.112" +version = "0.2.119" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" [[package]] name = "lock_api" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ - "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard", ] [[package]] name = "memchr" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" [[package]] name = "nb" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" dependencies = [ - "nb 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nb 1.0.0", ] [[package]] name = "nb" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" [[package]] name = "once_cell" -version = "1.9.0" +version = "1.10.0" dependencies = [ - "atomic-polyfill 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atomic-polyfill", + "crossbeam-utils", + "lazy_static", + "parking_lot", + "regex", ] [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" dependencies = [ - "instant 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "lock_api 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lock_api", + "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" dependencies = [ - "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "instant 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.112 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", ] [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" dependencies = [ - "bitflags 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", ] [[package]] name = "regex" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" dependencies = [ - "aho-corasick 0.7.4 (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.9 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", + "utf8-ranges", ] [[package]] name = "regex-syntax" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfaca88e749e19dffb60f77b55e5d87a872fac7e9e48598f7cf93b2d8c047b0a" dependencies = [ - "ucd-util 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util", ] [[package]] name = "riscv" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6907ccdd7a31012b70faf2af85cd9e5ba97657cc3987c4f13f8e4d2c2a088aba" dependencies = [ - "bare-metal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bit_field 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "riscv-target 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bare-metal 1.0.0", + "bit_field", + "riscv-target", ] [[package]] name = "riscv-target" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", + "regex", ] [[package]] name = "rustc_version" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver", ] [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver-parser", ] [[package]] name = "semver-parser" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "smallvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" [[package]] name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", ] [[package]] name = "ucd-util" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3bf5cdf1df6b578c0947a94d4740bbb2b2afd1b898e33df1ff07b555a335e4" [[package]] name = "utf8-ranges" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4" [[package]] name = "vcell" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" [[package]] name = "void" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "volatile-register" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" dependencies = [ - "vcell 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "vcell", ] [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-sys" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" 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.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" -"checksum atomic-polyfill 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e686d748538a32325b28d6411dd8a939e7ad5128e5d0023cc4fd3573db456042" -"checksum autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -"checksum bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" -"checksum bare-metal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" -"checksum bit_field 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" -"checksum bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" -"checksum bitflags 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" -"checksum cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -"checksum cortex-m 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ac919ef424449ec8c08d515590ce15d9262c0ca5f0da5b0c901e971a3b783b3" -"checksum critical-section 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "01e191a5a6f6edad9b679777ef6b6c0f2bdd4a333f2ecb8f61c3e28109a03d70" -"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -"checksum embedded-hal 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e36cfb62ff156596c892272f3015ef952fe1525e85261fa3a7f327bd6b384ab9" -"checksum instant 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.112 (registry+https://github.com/rust-lang/crates.io-index)" = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" -"checksum lock_api 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" -"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" -"checksum nb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" -"checksum nb 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" -"checksum parking_lot 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -"checksum parking_lot_core 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" -"checksum redox_syscall 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" -"checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" -"checksum regex-syntax 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bfaca88e749e19dffb60f77b55e5d87a872fac7e9e48598f7cf93b2d8c047b0a" -"checksum riscv 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6907ccdd7a31012b70faf2af85cd9e5ba97657cc3987c4f13f8e4d2c2a088aba" -"checksum riscv-target 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum smallvec 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum ucd-util 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f3bf5cdf1df6b578c0947a94d4740bbb2b2afd1b898e33df1ff07b555a335e4" -"checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4" -"checksum vcell 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" -"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum volatile-register 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" -"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" + +[[package]] +name = "windows_i686_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" + +[[package]] +name = "windows_i686_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" diff -Nru cargo-0.58.0/vendor/once_cell/Cargo.toml cargo-0.60.0ubuntu1/vendor/once_cell/Cargo.toml --- cargo-0.58.0/vendor/once_cell/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,9 +12,9 @@ [package] edition = "2018" name = "once_cell" -version = "1.9.0" +version = "1.10.0" authors = ["Aleksey Kladov "] -exclude = ["*.png", "*.svg", "/Cargo.lock.msrv", "/.travis.yml", "/run-miri-tests.sh", "rustfmt.toml"] +exclude = ["*.png", "*.svg", "/Cargo.lock.msrv", "rustfmt.toml"] description = "Single assignment cells and lazy values." documentation = "https://docs.rs/once_cell" readme = "README.md" @@ -52,16 +52,16 @@ [[example]] name = "test_synchronization" required-features = ["std"] -[dependencies.atomic-polyfill] -version = "0.1" -optional = true +#[dependencies.atomic-polyfill] +#version = "0.1" +#optional = true [dependencies.parking_lot] -version = "0.10" +version = "0.12" optional = true default_features = false [dev-dependencies.crossbeam-utils] -version = "0.7.2" +version = ">= 0.7.2, < 0.9" [dev-dependencies.lazy_static] version = "1.0.0" diff -Nru cargo-0.58.0/vendor/once_cell/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/once_cell/CHANGELOG.md --- cargo-0.58.0/vendor/once_cell/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/CHANGELOG.md 2022-04-20 13:48:09.000000000 +0000 @@ -1,5 +1,9 @@ # Changelog +## 1.10 + +- upgrade `parking_lot` to `0.12.0` (note that this bumps MSRV with `parking_lot` feature enabled to `1.49.0`). + ## 1.9 - Added an `atomic-polyfill` optional dependency to compile `race` on platforms without atomics diff -Nru cargo-0.58.0/vendor/once_cell/debian/patches/disable-atomic-pollyfill.diff cargo-0.60.0ubuntu1/vendor/once_cell/debian/patches/disable-atomic-pollyfill.diff --- cargo-0.58.0/vendor/once_cell/debian/patches/disable-atomic-pollyfill.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/debian/patches/disable-atomic-pollyfill.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,17 @@ +Index: once-cell/Cargo.toml +=================================================================== +--- once-cell.orig/Cargo.toml ++++ once-cell/Cargo.toml +@@ -52,9 +52,9 @@ required-features = ["std"] + [[example]] + name = "test_synchronization" + required-features = ["std"] +-[dependencies.atomic-polyfill] +-version = "0.1" +-optional = true ++#[dependencies.atomic-polyfill] ++#version = "0.1" ++#optional = true + + [dependencies.parking_lot] + version = "0.11" diff -Nru cargo-0.58.0/vendor/once_cell/debian/patches/relax-dep.diff cargo-0.60.0ubuntu1/vendor/once_cell/debian/patches/relax-dep.diff --- cargo-0.58.0/vendor/once_cell/debian/patches/relax-dep.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/debian/patches/relax-dep.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,13 @@ +Index: once-cell/Cargo.toml +=================================================================== +--- once-cell.orig/Cargo.toml ++++ once-cell/Cargo.toml +@@ -61,7 +61,7 @@ version = "0.11" + optional = true + default_features = false + [dev-dependencies.crossbeam-utils] +-version = "0.7.2" ++version = ">= 0.7.2, < 0.9" + + [dev-dependencies.lazy_static] + version = "1.0.0" diff -Nru cargo-0.58.0/vendor/once_cell/debian/patches/relax-test.diff cargo-0.60.0ubuntu1/vendor/once_cell/debian/patches/relax-test.diff --- cargo-0.58.0/vendor/once_cell/debian/patches/relax-test.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/debian/patches/relax-test.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,22 @@ +Index: once-cell/tests/it.rs +=================================================================== +--- once-cell.orig/tests/it.rs ++++ once-cell/tests/it.rs +@@ -346,7 +346,7 @@ mod sync { + ); + } + +- #[test] ++ /*#[test] + #[cfg_attr(miri, ignore)] // miri doesn't support processes + fn reentrant_init() { + let examples_dir = { +@@ -373,7 +373,7 @@ mod sync { + let _ = self.child.kill(); + } + } +- } ++ }*/ + + #[test] + fn lazy_new() { diff -Nru cargo-0.58.0/vendor/once_cell/debian/patches/series cargo-0.60.0ubuntu1/vendor/once_cell/debian/patches/series --- cargo-0.58.0/vendor/once_cell/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1,3 @@ -update-parking-lot.patch +relax-dep.diff +relax-test.diff +disable-atomic-pollyfill.diff diff -Nru cargo-0.58.0/vendor/once_cell/debian/patches/update-parking-lot.patch cargo-0.60.0ubuntu1/vendor/once_cell/debian/patches/update-parking-lot.patch --- cargo-0.58.0/vendor/once_cell/debian/patches/update-parking-lot.patch 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/debian/patches/update-parking-lot.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -Index: once-cell/Cargo.toml -=================================================================== ---- once-cell.orig/Cargo.toml -+++ once-cell/Cargo.toml -@@ -54,7 +54,7 @@ required-features = ["std"] - name = "test_synchronization" - required-features = ["std"] - [dependencies.parking_lot] --version = "0.11" -+version = "0.10" - optional = true - default_features = false - [dev-dependencies.crossbeam-utils] diff -Nru cargo-0.58.0/vendor/once_cell/README.md cargo-0.60.0ubuntu1/vendor/once_cell/README.md --- cargo-0.58.0/vendor/once_cell/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -1,7 +1,7 @@

once_cell

-[![Build Status](https://travis-ci.org/matklad/once_cell.svg?branch=master)](https://travis-ci.org/matklad/once_cell) +[![Build Status](https://github.com/matklad/once_cell/actions/workflows/ci.yaml/badge.svg)](https://github.com/matklad/once_cell/actions) [![Crates.io](https://img.shields.io/crates/v/once_cell.svg)](https://crates.io/crates/once_cell) [![API reference](https://docs.rs/once_cell/badge.svg)](https://docs.rs/once_cell/) diff -Nru cargo-0.58.0/vendor/once_cell/src/lib.rs cargo-0.60.0ubuntu1/vendor/once_cell/src/lib.rs --- cargo-0.58.0/vendor/once_cell/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -482,7 +482,7 @@ } } - /// Like [`set`](Self::set), but also returns a referce to the final cell value. + /// Like [`set`](Self::set), but also returns a reference to the final cell value. /// /// # Example /// ``` @@ -1116,7 +1116,7 @@ } // We never create a `&F` from a `&Lazy` so it is fine to not impl - // `Sync` for `F`. we do create a `&mut Option` in `force`, but this is + // `Sync` for `F`. We do create a `&mut Option` in `force`, but this is // properly synchronized, so it only happens once so it also does not // contribute to this impl. unsafe impl Sync for Lazy where OnceCell: Sync {} diff -Nru cargo-0.58.0/vendor/once_cell/tests/it.rs cargo-0.60.0ubuntu1/vendor/once_cell/tests/it.rs --- cargo-0.58.0/vendor/once_cell/tests/it.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/once_cell/tests/it.rs 2022-04-20 13:48:09.000000000 +0000 @@ -346,7 +346,7 @@ ); } - #[test] + /*#[test] #[cfg_attr(miri, ignore)] // miri doesn't support processes fn reentrant_init() { let examples_dir = { @@ -373,7 +373,7 @@ let _ = self.child.kill(); } } - } + }*/ #[test] fn lazy_new() { diff -Nru cargo-0.58.0/vendor/openssl-sys/Cargo.toml.rej cargo-0.60.0ubuntu1/vendor/openssl-sys/Cargo.toml.rej --- cargo-0.58.0/vendor/openssl-sys/Cargo.toml.rej 2022-01-21 03:07:38.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/openssl-sys/Cargo.toml.rej 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ ---- Cargo.toml -+++ Cargo.toml -@@ -30,14 +30,11 @@ - [build-dependencies.cc] - version = "1.0" - --[build-dependencies.openssl-src] --version = "111.0.1" --optional = true -- - [build-dependencies.pkg-config] - version = "0.3.9" - - [features] - vendored = ["openssl-src"] -+openssl-src = [] - [target."cfg(target_env = \"msvc\")".build-dependencies.vcpkg] - version = "0.2.8" diff -Nru cargo-0.58.0/vendor/openssl-sys/debian/patches/disable-vendor.patch cargo-0.60.0ubuntu1/vendor/openssl-sys/debian/patches/disable-vendor.patch --- cargo-0.58.0/vendor/openssl-sys/debian/patches/disable-vendor.patch 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/openssl-sys/debian/patches/disable-vendor.patch 2022-04-20 13:48:09.000000000 +0000 @@ -35,8 +35,8 @@ +#[cfg(feature = "vendored_debian_disabled")] mod find_vendored; - #[derive(PartialEq)] -@@ -46,7 +46,7 @@ + enum Version { +@@ -44,7 +44,7 @@ } fn find_openssl(target: &str) -> (PathBuf, PathBuf) { diff -Nru cargo-0.58.0/vendor/openssl-sys/debian/patches/disable-vendor.patch.orig cargo-0.60.0ubuntu1/vendor/openssl-sys/debian/patches/disable-vendor.patch.orig --- cargo-0.58.0/vendor/openssl-sys/debian/patches/disable-vendor.patch.orig 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/openssl-sys/debian/patches/disable-vendor.patch.orig 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,47 @@ +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -30,14 +30,11 @@ + [build-dependencies.cc] + version = "1.0" + +-[build-dependencies.openssl-src] +-version = "111.0.1" +-optional = true +- + [build-dependencies.pkg-config] + version = "0.3.9" + + [features] + vendored = ["openssl-src"] ++openssl-src = [] + [target."cfg(target_env = \"msvc\")".build-dependencies.vcpkg] + version = "0.2.8" +--- a/build/main.rs ++++ b/build/main.rs +@@ -2,7 +2,7 @@ + + extern crate autocfg; + extern crate cc; +-#[cfg(feature = "vendored")] ++#[cfg(feature = "vendored_debian_disabled")] + extern crate openssl_src; + extern crate pkg_config; + #[cfg(target_env = "msvc")] +@@ -16,7 +16,7 @@ + mod cfgs; + + mod find_normal; +-#[cfg(feature = "vendored")] ++#[cfg(feature = "vendored_debian_disabled")] + mod find_vendored; + + enum Version { +@@ -44,7 +44,7 @@ + } + + fn find_openssl(target: &str) -> (PathBuf, PathBuf) { +- #[cfg(feature = "vendored")] ++ #[cfg(feature = "vendored_debian_disabled")] + { + // vendor if the feature is present, unless + // OPENSSL_NO_VENDOR exists and isn't `0` diff -Nru cargo-0.58.0/vendor/os_info/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/os_info/.cargo-checksum.json --- cargo-0.58.0/vendor/os_info/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/os_info/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"198e392be7e882f0c2836f425e430f81d9a0e99651e4646311347417cddbfd43"} \ No newline at end of file +{"files":{},"package":"023df84d545ef479cf67fd2f4459a613585c9db4852c2fad12ab70587859d340"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/os_info/Cargo.lock cargo-0.60.0ubuntu1/vendor/os_info/Cargo.lock --- cargo-0.58.0/vendor/os_info/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/os_info/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -50,7 +50,7 @@ [[package]] name = "os_info" -version = "3.1.0" +version = "3.2.0" dependencies = [ "doc-comment", "log", @@ -70,9 +70,9 @@ [[package]] name = "pretty_assertions" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0cfe1b2403f172ba0f234e500906ee0a3e493fb81092dac23ebefe129301cc" +checksum = "76d5b548b725018ab5496482b45cb8bef21e9fed1858a6d674e3a8a0f0bb5d50" dependencies = [ "ansi_term", "ctor", @@ -91,27 +91,27 @@ [[package]] name = "quote" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" dependencies = [ "proc-macro2", ] [[package]] name = "serde" -version = "1.0.133" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.133" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -120,9 +120,9 @@ [[package]] name = "syn" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" dependencies = [ "proc-macro2", "quote", diff -Nru cargo-0.58.0/vendor/os_info/Cargo.toml cargo-0.60.0ubuntu1/vendor/os_info/Cargo.toml --- cargo-0.58.0/vendor/os_info/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/os_info/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "os_info" -version = "3.1.0" +version = "3.2.0" authors = ["Jan Schulte ", "Stanislav Tkach "] description = "Detect the operating system type and version." homepage = "https://github.com/stanislav-tkach/os_info" @@ -26,14 +26,14 @@ version = "0.4.5" [dependencies.serde] -version = "1.0.0" +version = "1" features = ["derive"] optional = true [dev-dependencies.doc-comment] version = "0.3.1" [dev-dependencies.pretty_assertions] -version = "1.0.0" +version = "1" [features] default = ["serde"] diff -Nru cargo-0.58.0/vendor/os_info/README.md cargo-0.60.0ubuntu1/vendor/os_info/README.md --- cargo-0.58.0/vendor/os_info/README.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/os_info/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -93,6 +93,7 @@ - Linux Mint - macOS (Mac OS X or OS X) - Manjaro +- MidnightBSD - NetBSD - NixOS - OpenBSD diff -Nru cargo-0.58.0/vendor/os_info/src/bitness.rs cargo-0.60.0ubuntu1/vendor/os_info/src/bitness.rs --- cargo-0.58.0/vendor/os_info/src/bitness.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/os_info/src/bitness.rs 2022-04-20 13:48:09.000000000 +0000 @@ -60,6 +60,7 @@ Ok(Output { stdout, .. }) if stdout == b"i386\n" => Bitness::X32, Ok(Output { stdout, .. }) if stdout == b"aarch64\n" => Bitness::X64, Ok(Output { stdout, .. }) if stdout == b"earmv7hf\n" => Bitness::X32, + Ok(Output { stdout, .. }) if stdout == b"sparc64\n" => Bitness::X64, _ => Bitness::Unknown, } } @@ -72,6 +73,7 @@ Ok(Output { stdout, .. }) if stdout == b"i386\n" => Bitness::X32, Ok(Output { stdout, .. }) if stdout == b"aarch64\n" => Bitness::X64, Ok(Output { stdout, .. }) if stdout == b"earmv7hf\n" => Bitness::X32, + Ok(Output { stdout, .. }) if stdout == b"sparc64\n" => Bitness::X64, _ => Bitness::Unknown, } } diff -Nru cargo-0.58.0/vendor/os_info/src/freebsd/mod.rs cargo-0.60.0ubuntu1/vendor/os_info/src/freebsd/mod.rs --- cargo-0.58.0/vendor/os_info/src/freebsd/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/os_info/src/freebsd/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,4 +1,5 @@ use std::process::Command; +use std::str; use log::{error, trace}; @@ -12,7 +13,7 @@ .unwrap_or_else(|| Version::Unknown); let info = Info { - os_type: Type::FreeBSD, + os_type: get_os(), version, bitness: bitness::get(), ..Default::default() @@ -22,6 +23,19 @@ info } +fn get_os() -> Type { + let os = Command::new("uname") + .arg("-s") + .output() + .expect("Failed to get OS"); + + match str::from_utf8(&os.stdout).unwrap() { + "FreeBSD\n" => Type::FreeBSD, + "MidnightBSD\n" => Type::MidnightBSD, + _ => Type::Unknown, + } +} + #[cfg(test)] mod tests { use super::*; diff -Nru cargo-0.58.0/vendor/os_info/src/os_type.rs cargo-0.60.0ubuntu1/vendor/os_info/src/os_type.rs --- cargo-0.58.0/vendor/os_info/src/os_type.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/os_info/src/os_type.rs 2022-04-20 13:48:09.000000000 +0000 @@ -35,6 +35,8 @@ /// Manjaro (). Manjaro, /// Mint (). + MidnightBSD, + /// MidnightBSD(). Mint, /// NetBSD (). NetBSD, @@ -82,6 +84,7 @@ Type::Arch => write!(f, "Arch Linux"), Type::DragonFly => write!(f, "DragonFly BSD"), Type::Macos => write!(f, "Mac OS"), + Type::MidnightBSD => write!(f, "Midnight BSD"), Type::Mint => write!(f, "Linux Mint"), Type::Pop => write!(f, "Pop!_OS"), Type::Raspbian => write!(f, "Raspberry Pi OS"), diff -Nru cargo-0.58.0/vendor/pkg-config/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/pkg-config/.cargo-checksum.json --- cargo-0.58.0/vendor/pkg-config/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/pkg-config/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"} \ No newline at end of file +{"files":{},"package":"1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/pkg-config/Cargo.toml cargo-0.60.0ubuntu1/vendor/pkg-config/Cargo.toml --- cargo-0.58.0/vendor/pkg-config/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/pkg-config/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -11,15 +11,13 @@ [package] name = "pkg-config" -version = "0.3.24" +version = "0.3.25" authors = ["Alex Crichton "] description = "A library to run the pkg-config system tool at build time in order to be used in\nCargo build scripts.\n" documentation = "https://docs.rs/pkg-config" readme = "README.md" keywords = ["build-dependencies"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/pkg-config-rs" [dev-dependencies.lazy_static] version = "1" -[badges.travis-ci] -repository = "rust-lang/pkg-config-rs" diff -Nru cargo-0.58.0/vendor/pkg-config/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/pkg-config/CHANGELOG.md --- cargo-0.58.0/vendor/pkg-config/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/pkg-config/CHANGELOG.md 2022-04-20 13:48:09.000000000 +0000 @@ -5,6 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.25] - 2022-03-31 + +### Added + +- Support for parsing `-Wl` linker arguments from the `Libs` lines and + passing them to the linker as well as making them available via + `Library::ld_args` (#131). + +### Changed + +- Use SPDX license format and remove obsolete badge info (#129). + ## [0.3.24] - 2021-12-11 ### Fixed diff -Nru cargo-0.58.0/vendor/pkg-config/src/lib.rs cargo-0.60.0ubuntu1/vendor/pkg-config/src/lib.rs --- cargo-0.58.0/vendor/pkg-config/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/pkg-config/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -91,6 +91,7 @@ pub frameworks: Vec, pub framework_paths: Vec, pub include_paths: Vec, + pub ld_args: Vec>, pub defines: HashMap>, pub version: String, _priv: (), @@ -545,6 +546,7 @@ libs: Vec::new(), link_paths: Vec::new(), include_paths: Vec::new(), + ld_args: Vec::new(), frameworks: Vec::new(), framework_paths: Vec::new(), defines: HashMap::new(), @@ -658,6 +660,31 @@ _ => (), } } + + let mut linker_options = words.iter().filter(|arg| arg.starts_with("-Wl,")); + while let Some(option) = linker_options.next() { + let mut pop = false; + let mut ld_option = vec![]; + for subopt in option[4..].split(',') { + if pop { + pop = false; + continue; + } + + if subopt == "-framework" { + pop = true; + continue; + } + + ld_option.push(subopt); + } + + let meta = format!("rustc-link-arg=-Wl,{}", ld_option.join(",")); + config.print_metadata(&meta); + + self.ld_args + .push(ld_option.into_iter().map(String::from).collect()); + } } fn parse_modversion(&mut self, output: &str) { diff -Nru cargo-0.58.0/vendor/pkg-config/tests/rpath.pc cargo-0.60.0ubuntu1/vendor/pkg-config/tests/rpath.pc --- cargo-0.58.0/vendor/pkg-config/tests/rpath.pc 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/pkg-config/tests/rpath.pc 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,7 @@ +prefix=/usr/local + +Name: rpath +Version: 4.2.0 +Description: RPath example library +Libs: -L${prefix}/lib -Wl,-rpath,${prefix}/lib -lrpath +Cflags: -I${prefix}/include diff -Nru cargo-0.58.0/vendor/pkg-config/tests/test.rs cargo-0.60.0ubuntu1/vendor/pkg-config/tests/test.rs --- cargo-0.58.0/vendor/pkg-config/tests/test.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/pkg-config/tests/test.rs 2022-04-20 13:48:09.000000000 +0000 @@ -308,3 +308,13 @@ .probe("escape") .unwrap(); } + +#[test] +fn rpath() { + let _g = LOCK.lock(); + reset(); + let lib = find("rpath").unwrap(); + assert!(lib + .ld_args + .contains(&vec!["-rpath".to_string(), "/usr/local/lib".to_string(),])); +} diff -Nru cargo-0.58.0/vendor/ppv-lite86/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/ppv-lite86/.cargo-checksum.json --- cargo-0.58.0/vendor/ppv-lite86/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -{"files":{},"package":"eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/ppv-lite86/Cargo.toml cargo-0.60.0ubuntu1/vendor/ppv-lite86/Cargo.toml --- cargo-0.58.0/vendor/ppv-lite86/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2018" -name = "ppv-lite86" -version = "0.2.16" -authors = ["The CryptoCorrosion Contributors"] -description = "Implementation of the crypto-simd API for x86" -keywords = ["crypto", "simd", "x86"] -categories = ["cryptography", "no-std"] -license = "MIT/Apache-2.0" -repository = "https://github.com/cryptocorrosion/cryptocorrosion" - -[dependencies] - -[features] -default = ["std"] -no_simd = [] -simd = [] -std = [] -[badges.travis-ci] -repository = "cryptocorrosion/cryptocorrosion" diff -Nru cargo-0.58.0/vendor/ppv-lite86/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/ppv-lite86/CHANGELOG.md --- cargo-0.58.0/vendor/ppv-lite86/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [0.2.16] -### Added -- add [u64; 4] conversion for generic vec256, to support BLAKE on non-x86. -- impl `From` (rather than just `Into`) for conversions between `*_storage` types and arrays. diff -Nru cargo-0.58.0/vendor/ppv-lite86/debian/patches/fix_build_on_s390x.diff cargo-0.60.0ubuntu1/vendor/ppv-lite86/debian/patches/fix_build_on_s390x.diff --- cargo-0.58.0/vendor/ppv-lite86/debian/patches/fix_build_on_s390x.diff 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/debian/patches/fix_build_on_s390x.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -Index: ppv-lite86/src/generic.rs -=================================================================== ---- ppv-lite86.orig/src/generic.rs -+++ ppv-lite86/src/generic.rs -@@ -326,7 +326,8 @@ fn rotate_u128_right(x: u128, i: u32) -> - #[test] - fn test_rotate_u128() { - const X: u128 = 0x0001_0203_0405_0607_0809_0a0b_0c0d_0e0f; -- assert_eq!(rotate_u128_right(X, 17), X.rotate_right(17)); -+ const R: u128 = X.rotate_right(17); -+ assert_eq!(rotate_u128_right(X, 17), R); - } - - impl RotateEachWord32 for u128x1_generic { diff -Nru cargo-0.58.0/vendor/ppv-lite86/debian/patches/series cargo-0.60.0ubuntu1/vendor/ppv-lite86/debian/patches/series --- cargo-0.58.0/vendor/ppv-lite86/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -fix_build_on_s390x.diff diff -Nru cargo-0.58.0/vendor/ppv-lite86/LICENSE-APACHE cargo-0.60.0ubuntu1/vendor/ppv-lite86/LICENSE-APACHE --- cargo-0.58.0/vendor/ppv-lite86/LICENSE-APACHE 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright 2019 The CryptoCorrosion Contributors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff -Nru cargo-0.58.0/vendor/ppv-lite86/LICENSE-MIT cargo-0.60.0ubuntu1/vendor/ppv-lite86/LICENSE-MIT --- cargo-0.58.0/vendor/ppv-lite86/LICENSE-MIT 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -Copyright (c) 2019 The CryptoCorrosion Contributors - -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.58.0/vendor/ppv-lite86/src/generic.rs cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/generic.rs --- cargo-0.58.0/vendor/ppv-lite86/src/generic.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/generic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,866 +0,0 @@ -#![allow(non_camel_case_types)] - -use crate::soft::{x2, x4}; -use crate::types::*; -use core::ops::*; - -#[repr(C)] -#[derive(Clone, Copy)] -pub union vec128_storage { - d: [u32; 4], - q: [u64; 2], -} -impl From<[u32; 4]> for vec128_storage { - #[inline(always)] - fn from(d: [u32; 4]) -> Self { - Self { d } - } -} -impl From for [u32; 4] { - #[inline(always)] - fn from(d: vec128_storage) -> Self { - unsafe { d.d } - } -} -impl From<[u64; 2]> for vec128_storage { - #[inline(always)] - fn from(q: [u64; 2]) -> Self { - Self { q } - } -} -impl From for [u64; 2] { - #[inline(always)] - fn from(q: vec128_storage) -> Self { - unsafe { q.q } - } -} -impl Default for vec128_storage { - #[inline(always)] - fn default() -> Self { - Self { q: [0, 0] } - } -} -impl Eq for vec128_storage {} -impl PartialEq for vec128_storage { - #[inline(always)] - fn eq(&self, rhs: &Self) -> bool { - unsafe { self.q == rhs.q } - } -} -#[derive(Clone, Copy, PartialEq, Eq, Default)] -pub struct vec256_storage { - v128: [vec128_storage; 2], -} -impl vec256_storage { - #[inline(always)] - pub fn new128(v128: [vec128_storage; 2]) -> Self { - Self { v128 } - } - #[inline(always)] - pub fn split128(self) -> [vec128_storage; 2] { - self.v128 - } -} -impl From for [u64; 4] { - #[inline(always)] - fn from(q: vec256_storage) -> Self { - let [a, b]: [u64; 2] = q.v128[0].into(); - let [c, d]: [u64; 2] = q.v128[1].into(); - [a, b, c, d] - } -} -impl From<[u64; 4]> for vec256_storage { - #[inline(always)] - fn from([a, b, c, d]: [u64; 4]) -> Self { - Self { - v128: [[a, b].into(), [c, d].into()], - } - } -} -#[derive(Clone, Copy, PartialEq, Eq, Default)] -pub struct vec512_storage { - v128: [vec128_storage; 4], -} -impl vec512_storage { - #[inline(always)] - pub fn new128(v128: [vec128_storage; 4]) -> Self { - Self { v128 } - } - #[inline(always)] - pub fn split128(self) -> [vec128_storage; 4] { - self.v128 - } -} - -#[inline(always)] -fn dmap(t: T, f: F) -> T -where - T: Store + Into, - F: Fn(u32) -> u32, -{ - let t: vec128_storage = t.into(); - let d = unsafe { t.d }; - let d = vec128_storage { - d: [f(d[0]), f(d[1]), f(d[2]), f(d[3])], - }; - unsafe { T::unpack(d) } -} - -fn dmap2(a: T, b: T, f: F) -> T -where - T: Store + Into, - F: Fn(u32, u32) -> u32, -{ - let a: vec128_storage = a.into(); - let b: vec128_storage = b.into(); - let ao = unsafe { a.d }; - let bo = unsafe { b.d }; - let d = vec128_storage { - d: [ - f(ao[0], bo[0]), - f(ao[1], bo[1]), - f(ao[2], bo[2]), - f(ao[3], bo[3]), - ], - }; - unsafe { T::unpack(d) } -} - -#[inline(always)] -fn qmap(t: T, f: F) -> T -where - T: Store + Into, - F: Fn(u64) -> u64, -{ - let t: vec128_storage = t.into(); - let q = unsafe { t.q }; - let q = vec128_storage { - q: [f(q[0]), f(q[1])], - }; - unsafe { T::unpack(q) } -} - -#[inline(always)] -fn qmap2(a: T, b: T, f: F) -> T -where - T: Store + Into, - F: Fn(u64, u64) -> u64, -{ - let a: vec128_storage = a.into(); - let b: vec128_storage = b.into(); - let ao = unsafe { a.q }; - let bo = unsafe { b.q }; - let q = vec128_storage { - q: [f(ao[0], bo[0]), f(ao[1], bo[1])], - }; - unsafe { T::unpack(q) } -} - -#[inline(always)] -fn o_of_q(q: [u64; 2]) -> u128 { - u128::from(q[0]) | (u128::from(q[1]) << 64) -} - -#[inline(always)] -fn q_of_o(o: u128) -> [u64; 2] { - [o as u64, (o >> 64) as u64] -} - -#[inline(always)] -fn omap(a: T, f: F) -> T -where - T: Store + Into, - F: Fn(u128) -> u128, -{ - let a: vec128_storage = a.into(); - let ao = o_of_q(unsafe { a.q }); - let o = vec128_storage { q: q_of_o(f(ao)) }; - unsafe { T::unpack(o) } -} - -#[inline(always)] -fn omap2(a: T, b: T, f: F) -> T -where - T: Store + Into, - F: Fn(u128, u128) -> u128, -{ - let a: vec128_storage = a.into(); - let b: vec128_storage = b.into(); - let ao = o_of_q(unsafe { a.q }); - let bo = o_of_q(unsafe { b.q }); - let o = vec128_storage { - q: q_of_o(f(ao, bo)), - }; - unsafe { T::unpack(o) } -} - -impl RotateEachWord128 for u128x1_generic {} -impl BitOps128 for u128x1_generic {} -impl BitOps64 for u128x1_generic {} -impl BitOps64 for u64x2_generic {} -impl BitOps32 for u128x1_generic {} -impl BitOps32 for u64x2_generic {} -impl BitOps32 for u32x4_generic {} -impl BitOps0 for u128x1_generic {} -impl BitOps0 for u64x2_generic {} -impl BitOps0 for u32x4_generic {} - -macro_rules! impl_bitops { - ($vec:ident) => { - impl Not for $vec { - type Output = Self; - #[inline(always)] - fn not(self) -> Self::Output { - omap(self, |x| !x) - } - } - impl BitAnd for $vec { - type Output = Self; - #[inline(always)] - fn bitand(self, rhs: Self) -> Self::Output { - omap2(self, rhs, |x, y| x & y) - } - } - impl BitOr for $vec { - type Output = Self; - #[inline(always)] - fn bitor(self, rhs: Self) -> Self::Output { - omap2(self, rhs, |x, y| x | y) - } - } - impl BitXor for $vec { - type Output = Self; - #[inline(always)] - fn bitxor(self, rhs: Self) -> Self::Output { - omap2(self, rhs, |x, y| x ^ y) - } - } - impl AndNot for $vec { - type Output = Self; - #[inline(always)] - fn andnot(self, rhs: Self) -> Self::Output { - omap2(self, rhs, |x, y| !x & y) - } - } - impl BitAndAssign for $vec { - #[inline(always)] - fn bitand_assign(&mut self, rhs: Self) { - *self = *self & rhs - } - } - impl BitOrAssign for $vec { - #[inline(always)] - fn bitor_assign(&mut self, rhs: Self) { - *self = *self | rhs - } - } - impl BitXorAssign for $vec { - #[inline(always)] - fn bitxor_assign(&mut self, rhs: Self) { - *self = *self ^ rhs - } - } - - impl Swap64 for $vec { - #[inline(always)] - fn swap1(self) -> Self { - qmap(self, |x| { - ((x & 0x5555555555555555) << 1) | ((x & 0xaaaaaaaaaaaaaaaa) >> 1) - }) - } - #[inline(always)] - fn swap2(self) -> Self { - qmap(self, |x| { - ((x & 0x3333333333333333) << 2) | ((x & 0xcccccccccccccccc) >> 2) - }) - } - #[inline(always)] - fn swap4(self) -> Self { - qmap(self, |x| { - ((x & 0x0f0f0f0f0f0f0f0f) << 4) | ((x & 0xf0f0f0f0f0f0f0f0) >> 4) - }) - } - #[inline(always)] - fn swap8(self) -> Self { - qmap(self, |x| { - ((x & 0x00ff00ff00ff00ff) << 8) | ((x & 0xff00ff00ff00ff00) >> 8) - }) - } - #[inline(always)] - fn swap16(self) -> Self { - dmap(self, |x| x.rotate_left(16)) - } - #[inline(always)] - fn swap32(self) -> Self { - qmap(self, |x| x.rotate_left(32)) - } - #[inline(always)] - fn swap64(self) -> Self { - omap(self, |x| (x << 64) | (x >> 64)) - } - } - }; -} -impl_bitops!(u32x4_generic); -impl_bitops!(u64x2_generic); -impl_bitops!(u128x1_generic); - -impl RotateEachWord32 for u32x4_generic { - #[inline(always)] - fn rotate_each_word_right7(self) -> Self { - dmap(self, |x| x.rotate_right(7)) - } - #[inline(always)] - fn rotate_each_word_right8(self) -> Self { - dmap(self, |x| x.rotate_right(8)) - } - #[inline(always)] - fn rotate_each_word_right11(self) -> Self { - dmap(self, |x| x.rotate_right(11)) - } - #[inline(always)] - fn rotate_each_word_right12(self) -> Self { - dmap(self, |x| x.rotate_right(12)) - } - #[inline(always)] - fn rotate_each_word_right16(self) -> Self { - dmap(self, |x| x.rotate_right(16)) - } - #[inline(always)] - fn rotate_each_word_right20(self) -> Self { - dmap(self, |x| x.rotate_right(20)) - } - #[inline(always)] - fn rotate_each_word_right24(self) -> Self { - dmap(self, |x| x.rotate_right(24)) - } - #[inline(always)] - fn rotate_each_word_right25(self) -> Self { - dmap(self, |x| x.rotate_right(25)) - } -} - -impl RotateEachWord32 for u64x2_generic { - #[inline(always)] - fn rotate_each_word_right7(self) -> Self { - qmap(self, |x| x.rotate_right(7)) - } - #[inline(always)] - fn rotate_each_word_right8(self) -> Self { - qmap(self, |x| x.rotate_right(8)) - } - #[inline(always)] - fn rotate_each_word_right11(self) -> Self { - qmap(self, |x| x.rotate_right(11)) - } - #[inline(always)] - fn rotate_each_word_right12(self) -> Self { - qmap(self, |x| x.rotate_right(12)) - } - #[inline(always)] - fn rotate_each_word_right16(self) -> Self { - qmap(self, |x| x.rotate_right(16)) - } - #[inline(always)] - fn rotate_each_word_right20(self) -> Self { - qmap(self, |x| x.rotate_right(20)) - } - #[inline(always)] - fn rotate_each_word_right24(self) -> Self { - qmap(self, |x| x.rotate_right(24)) - } - #[inline(always)] - fn rotate_each_word_right25(self) -> Self { - qmap(self, |x| x.rotate_right(25)) - } -} -impl RotateEachWord64 for u64x2_generic { - #[inline(always)] - fn rotate_each_word_right32(self) -> Self { - qmap(self, |x| x.rotate_right(32)) - } -} - -// workaround for koute/cargo-web#52 (u128::rotate_* broken with cargo web) -#[inline(always)] -fn rotate_u128_right(x: u128, i: u32) -> u128 { - (x >> i) | (x << (128 - i)) -} -#[test] -fn test_rotate_u128() { - const X: u128 = 0x0001_0203_0405_0607_0809_0a0b_0c0d_0e0f; - const R: u128 = X.rotate_right(17); - assert_eq!(rotate_u128_right(X, 17), R); -} - -impl RotateEachWord32 for u128x1_generic { - #[inline(always)] - fn rotate_each_word_right7(self) -> Self { - Self([rotate_u128_right(self.0[0], 7)]) - } - #[inline(always)] - fn rotate_each_word_right8(self) -> Self { - Self([rotate_u128_right(self.0[0], 8)]) - } - #[inline(always)] - fn rotate_each_word_right11(self) -> Self { - Self([rotate_u128_right(self.0[0], 11)]) - } - #[inline(always)] - fn rotate_each_word_right12(self) -> Self { - Self([rotate_u128_right(self.0[0], 12)]) - } - #[inline(always)] - fn rotate_each_word_right16(self) -> Self { - Self([rotate_u128_right(self.0[0], 16)]) - } - #[inline(always)] - fn rotate_each_word_right20(self) -> Self { - Self([rotate_u128_right(self.0[0], 20)]) - } - #[inline(always)] - fn rotate_each_word_right24(self) -> Self { - Self([rotate_u128_right(self.0[0], 24)]) - } - #[inline(always)] - fn rotate_each_word_right25(self) -> Self { - Self([rotate_u128_right(self.0[0], 25)]) - } -} -impl RotateEachWord64 for u128x1_generic { - #[inline(always)] - fn rotate_each_word_right32(self) -> Self { - Self([rotate_u128_right(self.0[0], 32)]) - } -} - -#[derive(Copy, Clone)] -pub struct GenericMachine; -impl Machine for GenericMachine { - type u32x4 = u32x4_generic; - type u64x2 = u64x2_generic; - type u128x1 = u128x1_generic; - type u32x4x2 = u32x4x2_generic; - type u64x2x2 = u64x2x2_generic; - type u64x4 = u64x4_generic; - type u128x2 = u128x2_generic; - type u32x4x4 = u32x4x4_generic; - type u64x2x4 = u64x2x4_generic; - type u128x4 = u128x4_generic; - #[inline(always)] - unsafe fn instance() -> Self { - Self - } -} - -#[derive(Copy, Clone, Debug, PartialEq)] -pub struct u32x4_generic([u32; 4]); -#[derive(Copy, Clone, Debug, PartialEq)] -pub struct u64x2_generic([u64; 2]); -#[derive(Copy, Clone, Debug, PartialEq)] -pub struct u128x1_generic([u128; 1]); - -impl From for vec128_storage { - #[inline(always)] - fn from(d: u32x4_generic) -> Self { - Self { d: d.0 } - } -} -impl From for vec128_storage { - #[inline(always)] - fn from(q: u64x2_generic) -> Self { - Self { q: q.0 } - } -} -impl From for vec128_storage { - #[inline(always)] - fn from(o: u128x1_generic) -> Self { - Self { q: q_of_o(o.0[0]) } - } -} - -impl Store for u32x4_generic { - #[inline(always)] - unsafe fn unpack(s: vec128_storage) -> Self { - Self(s.d) - } -} -impl Store for u64x2_generic { - #[inline(always)] - unsafe fn unpack(s: vec128_storage) -> Self { - Self(s.q) - } -} -impl Store for u128x1_generic { - #[inline(always)] - unsafe fn unpack(s: vec128_storage) -> Self { - Self([o_of_q(s.q); 1]) - } -} - -impl ArithOps for u32x4_generic {} -impl ArithOps for u64x2_generic {} -impl ArithOps for u128x1_generic {} - -impl Add for u32x4_generic { - type Output = Self; - #[inline(always)] - fn add(self, rhs: Self) -> Self::Output { - dmap2(self, rhs, |x, y| x.wrapping_add(y)) - } -} -impl Add for u64x2_generic { - type Output = Self; - #[inline(always)] - fn add(self, rhs: Self) -> Self::Output { - qmap2(self, rhs, |x, y| x.wrapping_add(y)) - } -} -impl Add for u128x1_generic { - type Output = Self; - #[inline(always)] - fn add(self, rhs: Self) -> Self::Output { - omap2(self, rhs, |x, y| x.wrapping_add(y)) - } -} -impl AddAssign for u32x4_generic { - #[inline(always)] - fn add_assign(&mut self, rhs: Self) { - *self = *self + rhs - } -} -impl AddAssign for u64x2_generic { - #[inline(always)] - fn add_assign(&mut self, rhs: Self) { - *self = *self + rhs - } -} -impl AddAssign for u128x1_generic { - #[inline(always)] - fn add_assign(&mut self, rhs: Self) { - *self = *self + rhs - } -} -impl BSwap for u32x4_generic { - #[inline(always)] - fn bswap(self) -> Self { - dmap(self, |x| x.swap_bytes()) - } -} -impl BSwap for u64x2_generic { - #[inline(always)] - fn bswap(self) -> Self { - qmap(self, |x| x.swap_bytes()) - } -} -impl BSwap for u128x1_generic { - #[inline(always)] - fn bswap(self) -> Self { - omap(self, |x| x.swap_bytes()) - } -} -impl StoreBytes for u32x4_generic { - #[inline(always)] - unsafe fn unsafe_read_le(input: &[u8]) -> Self { - assert_eq!(input.len(), 16); - let x = core::mem::transmute(core::ptr::read(input as *const _ as *const [u8; 16])); - dmap(x, |x| x.to_le()) - } - #[inline(always)] - unsafe fn unsafe_read_be(input: &[u8]) -> Self { - assert_eq!(input.len(), 16); - let x = core::mem::transmute(core::ptr::read(input as *const _ as *const [u8; 16])); - dmap(x, |x| x.to_be()) - } - #[inline(always)] - fn write_le(self, out: &mut [u8]) { - assert_eq!(out.len(), 16); - let x = dmap(self, |x| x.to_le()); - unsafe { core::ptr::write(out as *mut _ as *mut [u8; 16], core::mem::transmute(x)) } - } - #[inline(always)] - fn write_be(self, out: &mut [u8]) { - assert_eq!(out.len(), 16); - let x = dmap(self, |x| x.to_be()); - unsafe { core::ptr::write(out as *mut _ as *mut [u8; 16], core::mem::transmute(x)) } - } -} -impl StoreBytes for u64x2_generic { - #[inline(always)] - unsafe fn unsafe_read_le(input: &[u8]) -> Self { - assert_eq!(input.len(), 16); - let x = core::mem::transmute(core::ptr::read(input as *const _ as *const [u8; 16])); - qmap(x, |x| x.to_le()) - } - #[inline(always)] - unsafe fn unsafe_read_be(input: &[u8]) -> Self { - assert_eq!(input.len(), 16); - let x = core::mem::transmute(core::ptr::read(input as *const _ as *const [u8; 16])); - qmap(x, |x| x.to_be()) - } - #[inline(always)] - fn write_le(self, out: &mut [u8]) { - assert_eq!(out.len(), 16); - let x = qmap(self, |x| x.to_le()); - unsafe { core::ptr::write(out as *mut _ as *mut [u8; 16], core::mem::transmute(x)) } - } - #[inline(always)] - fn write_be(self, out: &mut [u8]) { - assert_eq!(out.len(), 16); - let x = qmap(self, |x| x.to_be()); - unsafe { core::ptr::write(out as *mut _ as *mut [u8; 16], core::mem::transmute(x)) } - } -} - -#[derive(Copy, Clone)] -pub struct G0; -#[derive(Copy, Clone)] -pub struct G1; -pub type u32x4x2_generic = x2; -pub type u64x2x2_generic = x2; -pub type u64x4_generic = x2; -pub type u128x2_generic = x2; -pub type u32x4x4_generic = x4; -pub type u64x2x4_generic = x4; -pub type u128x4_generic = x4; - -impl Vector<[u32; 16]> for u32x4x4_generic { - fn to_scalars(self) -> [u32; 16] { - let [a, b, c, d] = self.0; - let a = a.0; - let b = b.0; - let c = c.0; - let d = d.0; - [ - a[0], a[1], a[2], a[3], // - b[0], b[1], b[2], b[3], // - c[0], c[1], c[2], c[3], // - d[0], d[1], d[2], d[3], // - ] - } -} - -impl MultiLane<[u32; 4]> for u32x4_generic { - #[inline(always)] - fn to_lanes(self) -> [u32; 4] { - self.0 - } - #[inline(always)] - fn from_lanes(xs: [u32; 4]) -> Self { - Self(xs) - } -} -impl MultiLane<[u64; 2]> for u64x2_generic { - #[inline(always)] - fn to_lanes(self) -> [u64; 2] { - self.0 - } - #[inline(always)] - fn from_lanes(xs: [u64; 2]) -> Self { - Self(xs) - } -} -impl MultiLane<[u64; 4]> for u64x4_generic { - #[inline(always)] - fn to_lanes(self) -> [u64; 4] { - let (a, b) = (self.0[0].to_lanes(), self.0[1].to_lanes()); - [a[0], a[1], b[0], b[1]] - } - #[inline(always)] - fn from_lanes(xs: [u64; 4]) -> Self { - let (a, b) = ( - u64x2_generic::from_lanes([xs[0], xs[1]]), - u64x2_generic::from_lanes([xs[2], xs[3]]), - ); - x2::new([a, b]) - } -} -impl MultiLane<[u128; 1]> for u128x1_generic { - #[inline(always)] - fn to_lanes(self) -> [u128; 1] { - self.0 - } - #[inline(always)] - fn from_lanes(xs: [u128; 1]) -> Self { - Self(xs) - } -} -impl Vec4 for u32x4_generic { - #[inline(always)] - fn extract(self, i: u32) -> u32 { - self.0[i as usize] - } - #[inline(always)] - fn insert(mut self, v: u32, i: u32) -> Self { - self.0[i as usize] = v; - self - } -} -impl Vec4 for u64x4_generic { - #[inline(always)] - fn extract(self, i: u32) -> u64 { - let d: [u64; 4] = self.to_lanes(); - d[i as usize] - } - #[inline(always)] - fn insert(self, v: u64, i: u32) -> Self { - self.0[(i / 2) as usize].insert(v, i % 2); - self - } -} -impl Vec2 for u64x2_generic { - #[inline(always)] - fn extract(self, i: u32) -> u64 { - self.0[i as usize] - } - #[inline(always)] - fn insert(mut self, v: u64, i: u32) -> Self { - self.0[i as usize] = v; - self - } -} - -impl Words4 for u32x4_generic { - #[inline(always)] - fn shuffle2301(self) -> Self { - self.swap64() - } - #[inline(always)] - fn shuffle1230(self) -> Self { - let x = self.0; - Self([x[3], x[0], x[1], x[2]]) - } - #[inline(always)] - fn shuffle3012(self) -> Self { - let x = self.0; - Self([x[1], x[2], x[3], x[0]]) - } -} -impl LaneWords4 for u32x4_generic { - #[inline(always)] - fn shuffle_lane_words2301(self) -> Self { - self.shuffle2301() - } - #[inline(always)] - fn shuffle_lane_words1230(self) -> Self { - self.shuffle1230() - } - #[inline(always)] - fn shuffle_lane_words3012(self) -> Self { - self.shuffle3012() - } -} - -impl Words4 for u64x4_generic { - #[inline(always)] - fn shuffle2301(self) -> Self { - x2::new([self.0[1], self.0[0]]) - } - #[inline(always)] - fn shuffle1230(self) -> Self { - unimplemented!() - } - #[inline(always)] - fn shuffle3012(self) -> Self { - unimplemented!() - } -} - -impl u32x4 for u32x4_generic {} -impl u64x2 for u64x2_generic {} -impl u128x1 for u128x1_generic {} -impl u32x4x2 for u32x4x2_generic {} -impl u64x2x2 for u64x2x2_generic {} -impl u64x4 for u64x4_generic {} -impl u128x2 for u128x2_generic {} -impl u32x4x4 for u32x4x4_generic {} -impl u64x2x4 for u64x2x4_generic {} -impl u128x4 for u128x4_generic {} - -#[macro_export] -macro_rules! dispatch { - ($mach:ident, $MTy:ident, { $([$pub:tt$(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty $body:block }) => { - #[inline(always)] - $($pub$(($krate))*)* fn $name($($arg: $argty),*) -> $ret { - let $mach = unsafe { $crate::generic::GenericMachine::instance() }; - #[inline(always)] - fn fn_impl<$MTy: $crate::Machine>($mach: $MTy, $($arg: $argty),*) -> $ret $body - fn_impl($mach, $($arg),*) - } - }; - ($mach:ident, $MTy:ident, { $([$pub:tt $(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) $body:block }) => { - dispatch!($mach, $MTy, { - $([$pub $(($krate))*])* fn $name($($arg: $argty),*) -> () $body - }); - } -} -#[macro_export] -macro_rules! dispatch_light128 { - ($mach:ident, $MTy:ident, { $([$pub:tt$(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty $body:block }) => { - #[inline(always)] - $($pub$(($krate))*)* fn $name($($arg: $argty),*) -> $ret { - let $mach = unsafe { $crate::generic::GenericMachine::instance() }; - #[inline(always)] - fn fn_impl<$MTy: $crate::Machine>($mach: $MTy, $($arg: $argty),*) -> $ret $body - fn_impl($mach, $($arg),*) - } - }; - ($mach:ident, $MTy:ident, { $([$pub:tt $(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) $body:block }) => { - dispatch!($mach, $MTy, { - $([$pub $(($krate))*])* fn $name($($arg: $argty),*) -> () $body - }); - } -} -#[macro_export] -macro_rules! dispatch_light256 { - ($mach:ident, $MTy:ident, { $([$pub:tt$(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty $body:block }) => { - #[inline(always)] - $($pub$(($krate))*)* fn $name($($arg: $argty),*) -> $ret { - let $mach = unsafe { $crate::generic::GenericMachine::instance() }; - #[inline(always)] - fn fn_impl<$MTy: $crate::Machine>($mach: $MTy, $($arg: $argty),*) -> $ret $body - fn_impl($mach, $($arg),*) - } - }; - ($mach:ident, $MTy:ident, { $([$pub:tt $(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) $body:block }) => { - dispatch!($mach, $MTy, { - $([$pub $(($krate))*])* fn $name($($arg: $argty),*) -> () $body - }); - } -} -#[macro_export] -macro_rules! dispatch_light512 { - ($mach:ident, $MTy:ident, { $([$pub:tt$(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty $body:block }) => { - #[inline(always)] - $($pub$(($krate))*)* fn $name($($arg: $argty),*) -> $ret { - let $mach = unsafe { $crate::generic::GenericMachine::instance() }; - #[inline(always)] - fn fn_impl<$MTy: $crate::Machine>($mach: $MTy, $($arg: $argty),*) -> $ret $body - fn_impl($mach, $($arg),*) - } - }; - ($mach:ident, $MTy:ident, { $([$pub:tt $(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) $body:block }) => { - dispatch!($mach, $MTy, { - $([$pub $(($krate))*])* fn $name($($arg: $argty),*) -> () $body - }); - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_bswap32() { - let xs = [0x0f0e_0d0c, 0x0b0a_0908, 0x0706_0504, 0x0302_0100]; - let ys = [0x0c0d_0e0f, 0x0809_0a0b, 0x0405_0607, 0x0001_0203]; - - let m = unsafe { GenericMachine::instance() }; - - let x: ::u32x4 = m.vec(xs); - let x = x.bswap(); - - let y = m.vec(ys); - assert_eq!(x, y); - } -} diff -Nru cargo-0.58.0/vendor/ppv-lite86/src/lib.rs cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/lib.rs --- cargo-0.58.0/vendor/ppv-lite86/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -#![no_std] - -// Design: -// - safety: safe creation of any machine type is done only by instance methods of a -// Machine (which is a ZST + Copy type), which can only by created unsafely or safely -// through feature detection (e.g. fn AVX2::try_get() -> Option). - -mod soft; -mod types; -pub use self::types::*; - -#[cfg(all(target_arch = "x86_64", not(feature = "no_simd"), not(miri)))] -pub mod x86_64; -#[cfg(all(target_arch = "x86_64", not(feature = "no_simd"), not(miri)))] -use self::x86_64 as arch; - -#[cfg(any(feature = "no_simd", miri, not(target_arch = "x86_64")))] -pub mod generic; -#[cfg(any(feature = "no_simd", miri, not(target_arch = "x86_64")))] -use self::generic as arch; - -pub use self::arch::{vec128_storage, vec256_storage, vec512_storage}; diff -Nru cargo-0.58.0/vendor/ppv-lite86/src/soft.rs cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/soft.rs --- cargo-0.58.0/vendor/ppv-lite86/src/soft.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/soft.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,472 +0,0 @@ -//! Implement 256- and 512- bit in terms of 128-bit, for machines without native wide SIMD. - -use crate::types::*; -use crate::{vec128_storage, vec256_storage, vec512_storage}; -use core::marker::PhantomData; -use core::ops::*; - -#[derive(Copy, Clone, Default)] -#[allow(non_camel_case_types)] -pub struct x2(pub [W; 2], PhantomData); -impl x2 { - #[inline(always)] - pub fn new(xs: [W; 2]) -> Self { - x2(xs, PhantomData) - } -} -macro_rules! fwd_binop_x2 { - ($trait:ident, $fn:ident) => { - impl $trait for x2 { - type Output = x2; - #[inline(always)] - fn $fn(self, rhs: Self) -> Self::Output { - x2::new([self.0[0].$fn(rhs.0[0]), self.0[1].$fn(rhs.0[1])]) - } - } - }; -} -macro_rules! fwd_binop_assign_x2 { - ($trait:ident, $fn_assign:ident) => { - impl $trait for x2 { - #[inline(always)] - fn $fn_assign(&mut self, rhs: Self) { - (self.0[0]).$fn_assign(rhs.0[0]); - (self.0[1]).$fn_assign(rhs.0[1]); - } - } - }; -} -macro_rules! fwd_unop_x2 { - ($fn:ident) => { - #[inline(always)] - fn $fn(self) -> Self { - x2::new([self.0[0].$fn(), self.0[1].$fn()]) - } - }; -} -impl RotateEachWord32 for x2 -where - W: Copy + RotateEachWord32, -{ - fwd_unop_x2!(rotate_each_word_right7); - fwd_unop_x2!(rotate_each_word_right8); - fwd_unop_x2!(rotate_each_word_right11); - fwd_unop_x2!(rotate_each_word_right12); - fwd_unop_x2!(rotate_each_word_right16); - fwd_unop_x2!(rotate_each_word_right20); - fwd_unop_x2!(rotate_each_word_right24); - fwd_unop_x2!(rotate_each_word_right25); -} -impl RotateEachWord64 for x2 -where - W: Copy + RotateEachWord64, -{ - fwd_unop_x2!(rotate_each_word_right32); -} -impl RotateEachWord128 for x2 where W: RotateEachWord128 {} -impl BitOps0 for x2 -where - W: BitOps0, - G: Copy, -{ -} -impl BitOps32 for x2 -where - W: BitOps32 + BitOps0, - G: Copy, -{ -} -impl BitOps64 for x2 -where - W: BitOps64 + BitOps0, - G: Copy, -{ -} -impl BitOps128 for x2 -where - W: BitOps128 + BitOps0, - G: Copy, -{ -} -fwd_binop_x2!(BitAnd, bitand); -fwd_binop_x2!(BitOr, bitor); -fwd_binop_x2!(BitXor, bitxor); -fwd_binop_x2!(AndNot, andnot); -fwd_binop_assign_x2!(BitAndAssign, bitand_assign); -fwd_binop_assign_x2!(BitOrAssign, bitor_assign); -fwd_binop_assign_x2!(BitXorAssign, bitxor_assign); -impl ArithOps for x2 -where - W: ArithOps, - G: Copy, -{ -} -fwd_binop_x2!(Add, add); -fwd_binop_assign_x2!(AddAssign, add_assign); -impl Not for x2 { - type Output = x2; - #[inline(always)] - fn not(self) -> Self::Output { - x2::new([self.0[0].not(), self.0[1].not()]) - } -} -impl UnsafeFrom<[W; 2]> for x2 { - #[inline(always)] - unsafe fn unsafe_from(xs: [W; 2]) -> Self { - x2::new(xs) - } -} -impl Vec2 for x2 { - #[inline(always)] - fn extract(self, i: u32) -> W { - self.0[i as usize] - } - #[inline(always)] - fn insert(mut self, w: W, i: u32) -> Self { - self.0[i as usize] = w; - self - } -} -impl, G> Store for x2 { - #[inline(always)] - unsafe fn unpack(p: vec256_storage) -> Self { - let p = p.split128(); - x2::new([W::unpack(p[0]), W::unpack(p[1])]) - } -} -impl From> for vec256_storage -where - W: Copy, - vec128_storage: From, -{ - #[inline(always)] - fn from(x: x2) -> Self { - vec256_storage::new128([x.0[0].into(), x.0[1].into()]) - } -} -impl Swap64 for x2 -where - W: Swap64 + Copy, -{ - fwd_unop_x2!(swap1); - fwd_unop_x2!(swap2); - fwd_unop_x2!(swap4); - fwd_unop_x2!(swap8); - fwd_unop_x2!(swap16); - fwd_unop_x2!(swap32); - fwd_unop_x2!(swap64); -} -impl MultiLane<[W; 2]> for x2 { - #[inline(always)] - fn to_lanes(self) -> [W; 2] { - self.0 - } - #[inline(always)] - fn from_lanes(lanes: [W; 2]) -> Self { - x2::new(lanes) - } -} -impl BSwap for x2 { - #[inline(always)] - fn bswap(self) -> Self { - x2::new([self.0[0].bswap(), self.0[1].bswap()]) - } -} -impl StoreBytes for x2 { - #[inline(always)] - unsafe fn unsafe_read_le(input: &[u8]) -> Self { - let input = input.split_at(input.len() / 2); - x2::new([W::unsafe_read_le(input.0), W::unsafe_read_le(input.1)]) - } - #[inline(always)] - unsafe fn unsafe_read_be(input: &[u8]) -> Self { - let input = input.split_at(input.len() / 2); - x2::new([W::unsafe_read_be(input.0), W::unsafe_read_be(input.1)]) - } - #[inline(always)] - fn write_le(self, out: &mut [u8]) { - let out = out.split_at_mut(out.len() / 2); - self.0[0].write_le(out.0); - self.0[1].write_le(out.1); - } - #[inline(always)] - fn write_be(self, out: &mut [u8]) { - let out = out.split_at_mut(out.len() / 2); - self.0[0].write_be(out.0); - self.0[1].write_be(out.1); - } -} -impl LaneWords4 for x2 { - #[inline(always)] - fn shuffle_lane_words2301(self) -> Self { - Self::new([ - self.0[0].shuffle_lane_words2301(), - self.0[1].shuffle_lane_words2301(), - ]) - } - #[inline(always)] - fn shuffle_lane_words1230(self) -> Self { - Self::new([ - self.0[0].shuffle_lane_words1230(), - self.0[1].shuffle_lane_words1230(), - ]) - } - #[inline(always)] - fn shuffle_lane_words3012(self) -> Self { - Self::new([ - self.0[0].shuffle_lane_words3012(), - self.0[1].shuffle_lane_words3012(), - ]) - } -} - -#[derive(Copy, Clone, Default)] -#[allow(non_camel_case_types)] -pub struct x4(pub [W; 4]); -impl x4 { - #[inline(always)] - pub fn new(xs: [W; 4]) -> Self { - x4(xs) - } -} -macro_rules! fwd_binop_x4 { - ($trait:ident, $fn:ident) => { - impl $trait for x4 { - type Output = x4; - #[inline(always)] - fn $fn(self, rhs: Self) -> Self::Output { - x4([ - self.0[0].$fn(rhs.0[0]), - self.0[1].$fn(rhs.0[1]), - self.0[2].$fn(rhs.0[2]), - self.0[3].$fn(rhs.0[3]), - ]) - } - } - }; -} -macro_rules! fwd_binop_assign_x4 { - ($trait:ident, $fn_assign:ident) => { - impl $trait for x4 { - #[inline(always)] - fn $fn_assign(&mut self, rhs: Self) { - self.0[0].$fn_assign(rhs.0[0]); - self.0[1].$fn_assign(rhs.0[1]); - self.0[2].$fn_assign(rhs.0[2]); - self.0[3].$fn_assign(rhs.0[3]); - } - } - }; -} -macro_rules! fwd_unop_x4 { - ($fn:ident) => { - #[inline(always)] - fn $fn(self) -> Self { - x4([ - self.0[0].$fn(), - self.0[1].$fn(), - self.0[2].$fn(), - self.0[3].$fn(), - ]) - } - }; -} -impl RotateEachWord32 for x4 -where - W: Copy + RotateEachWord32, -{ - fwd_unop_x4!(rotate_each_word_right7); - fwd_unop_x4!(rotate_each_word_right8); - fwd_unop_x4!(rotate_each_word_right11); - fwd_unop_x4!(rotate_each_word_right12); - fwd_unop_x4!(rotate_each_word_right16); - fwd_unop_x4!(rotate_each_word_right20); - fwd_unop_x4!(rotate_each_word_right24); - fwd_unop_x4!(rotate_each_word_right25); -} -impl RotateEachWord64 for x4 -where - W: Copy + RotateEachWord64, -{ - fwd_unop_x4!(rotate_each_word_right32); -} -impl RotateEachWord128 for x4 where W: RotateEachWord128 {} -impl BitOps0 for x4 where W: BitOps0 {} -impl BitOps32 for x4 where W: BitOps32 + BitOps0 {} -impl BitOps64 for x4 where W: BitOps64 + BitOps0 {} -impl BitOps128 for x4 where W: BitOps128 + BitOps0 {} -fwd_binop_x4!(BitAnd, bitand); -fwd_binop_x4!(BitOr, bitor); -fwd_binop_x4!(BitXor, bitxor); -fwd_binop_x4!(AndNot, andnot); -fwd_binop_assign_x4!(BitAndAssign, bitand_assign); -fwd_binop_assign_x4!(BitOrAssign, bitor_assign); -fwd_binop_assign_x4!(BitXorAssign, bitxor_assign); -impl ArithOps for x4 where W: ArithOps {} -fwd_binop_x4!(Add, add); -fwd_binop_assign_x4!(AddAssign, add_assign); -impl Not for x4 { - type Output = x4; - #[inline(always)] - fn not(self) -> Self::Output { - x4([ - self.0[0].not(), - self.0[1].not(), - self.0[2].not(), - self.0[3].not(), - ]) - } -} -impl UnsafeFrom<[W; 4]> for x4 { - #[inline(always)] - unsafe fn unsafe_from(xs: [W; 4]) -> Self { - x4(xs) - } -} -impl Vec4 for x4 { - #[inline(always)] - fn extract(self, i: u32) -> W { - self.0[i as usize] - } - #[inline(always)] - fn insert(mut self, w: W, i: u32) -> Self { - self.0[i as usize] = w; - self - } -} -impl Vec4Ext for x4 { - #[inline(always)] - fn transpose4(a: Self, b: Self, c: Self, d: Self) -> (Self, Self, Self, Self) - where - Self: Sized, - { - ( - x4([a.0[0], b.0[0], c.0[0], d.0[0]]), - x4([a.0[1], b.0[1], c.0[1], d.0[1]]), - x4([a.0[2], b.0[2], c.0[2], d.0[2]]), - x4([a.0[3], b.0[3], c.0[3], d.0[3]]), - ) - } -} -impl> Store for x4 { - #[inline(always)] - unsafe fn unpack(p: vec512_storage) -> Self { - let p = p.split128(); - x4([ - W::unpack(p[0]), - W::unpack(p[1]), - W::unpack(p[2]), - W::unpack(p[3]), - ]) - } -} -impl From> for vec512_storage -where - W: Copy, - vec128_storage: From, -{ - #[inline(always)] - fn from(x: x4) -> Self { - vec512_storage::new128([x.0[0].into(), x.0[1].into(), x.0[2].into(), x.0[3].into()]) - } -} -impl Swap64 for x4 -where - W: Swap64 + Copy, -{ - fwd_unop_x4!(swap1); - fwd_unop_x4!(swap2); - fwd_unop_x4!(swap4); - fwd_unop_x4!(swap8); - fwd_unop_x4!(swap16); - fwd_unop_x4!(swap32); - fwd_unop_x4!(swap64); -} -impl MultiLane<[W; 4]> for x4 { - #[inline(always)] - fn to_lanes(self) -> [W; 4] { - self.0 - } - #[inline(always)] - fn from_lanes(lanes: [W; 4]) -> Self { - x4(lanes) - } -} -impl BSwap for x4 { - #[inline(always)] - fn bswap(self) -> Self { - x4([ - self.0[0].bswap(), - self.0[1].bswap(), - self.0[2].bswap(), - self.0[3].bswap(), - ]) - } -} -impl StoreBytes for x4 { - #[inline(always)] - unsafe fn unsafe_read_le(input: &[u8]) -> Self { - let n = input.len() / 4; - x4([ - W::unsafe_read_le(&input[..n]), - W::unsafe_read_le(&input[n..n * 2]), - W::unsafe_read_le(&input[n * 2..n * 3]), - W::unsafe_read_le(&input[n * 3..]), - ]) - } - #[inline(always)] - unsafe fn unsafe_read_be(input: &[u8]) -> Self { - let n = input.len() / 4; - x4([ - W::unsafe_read_be(&input[..n]), - W::unsafe_read_be(&input[n..n * 2]), - W::unsafe_read_be(&input[n * 2..n * 3]), - W::unsafe_read_be(&input[n * 3..]), - ]) - } - #[inline(always)] - fn write_le(self, out: &mut [u8]) { - let n = out.len() / 4; - self.0[0].write_le(&mut out[..n]); - self.0[1].write_le(&mut out[n..n * 2]); - self.0[2].write_le(&mut out[n * 2..n * 3]); - self.0[3].write_le(&mut out[n * 3..]); - } - #[inline(always)] - fn write_be(self, out: &mut [u8]) { - let n = out.len() / 4; - self.0[0].write_be(&mut out[..n]); - self.0[1].write_be(&mut out[n..n * 2]); - self.0[2].write_be(&mut out[n * 2..n * 3]); - self.0[3].write_be(&mut out[n * 3..]); - } -} -impl LaneWords4 for x4 { - #[inline(always)] - fn shuffle_lane_words2301(self) -> Self { - x4([ - self.0[0].shuffle_lane_words2301(), - self.0[1].shuffle_lane_words2301(), - self.0[2].shuffle_lane_words2301(), - self.0[3].shuffle_lane_words2301(), - ]) - } - #[inline(always)] - fn shuffle_lane_words1230(self) -> Self { - x4([ - self.0[0].shuffle_lane_words1230(), - self.0[1].shuffle_lane_words1230(), - self.0[2].shuffle_lane_words1230(), - self.0[3].shuffle_lane_words1230(), - ]) - } - #[inline(always)] - fn shuffle_lane_words3012(self) -> Self { - x4([ - self.0[0].shuffle_lane_words3012(), - self.0[1].shuffle_lane_words3012(), - self.0[2].shuffle_lane_words3012(), - self.0[3].shuffle_lane_words3012(), - ]) - } -} diff -Nru cargo-0.58.0/vendor/ppv-lite86/src/types.rs cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/types.rs --- cargo-0.58.0/vendor/ppv-lite86/src/types.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/types.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,298 +0,0 @@ -#![allow(non_camel_case_types)] -use core::ops::{Add, AddAssign, BitAnd, BitOr, BitXor, BitXorAssign, Not}; - -pub trait AndNot { - type Output; - fn andnot(self, rhs: Self) -> Self::Output; -} -pub trait BSwap { - fn bswap(self) -> Self; -} -/// Ops that depend on word size -pub trait ArithOps: Add + AddAssign + Sized + Copy + Clone + BSwap {} -/// Ops that are independent of word size and endian -pub trait BitOps0: - BitAnd - + BitOr - + BitXor - + BitXorAssign - + Not - + AndNot - + Sized - + Copy - + Clone -{ -} - -pub trait BitOps32: BitOps0 + RotateEachWord32 {} -pub trait BitOps64: BitOps32 + RotateEachWord64 {} -pub trait BitOps128: BitOps64 + RotateEachWord128 {} - -pub trait RotateEachWord32 { - fn rotate_each_word_right7(self) -> Self; - fn rotate_each_word_right8(self) -> Self; - fn rotate_each_word_right11(self) -> Self; - fn rotate_each_word_right12(self) -> Self; - fn rotate_each_word_right16(self) -> Self; - fn rotate_each_word_right20(self) -> Self; - fn rotate_each_word_right24(self) -> Self; - fn rotate_each_word_right25(self) -> Self; -} - -pub trait RotateEachWord64 { - fn rotate_each_word_right32(self) -> Self; -} - -pub trait RotateEachWord128 {} - -// Vector type naming scheme: -// uN[xP]xL -// Unsigned; N-bit words * P bits per lane * L lanes -// -// A lane is always 128-bits, chosen because common SIMD architectures treat 128-bit units of -// wide vectors specially (supporting e.g. intra-lane shuffles), and tend to have limited and -// slow inter-lane operations. - -use crate::arch::{vec128_storage, vec256_storage, vec512_storage}; - -#[allow(clippy::missing_safety_doc)] -pub trait UnsafeFrom { - unsafe fn unsafe_from(t: T) -> Self; -} - -/// A vector composed of two elements, which may be words or themselves vectors. -pub trait Vec2 { - fn extract(self, i: u32) -> W; - fn insert(self, w: W, i: u32) -> Self; -} - -/// A vector composed of four elements, which may be words or themselves vectors. -pub trait Vec4 { - fn extract(self, i: u32) -> W; - fn insert(self, w: W, i: u32) -> Self; -} -/// Vec4 functions which may not be implemented yet for all Vec4 types. -/// NOTE: functions in this trait may be moved to Vec4 in any patch release. To avoid breakage, -/// import Vec4Ext only together with Vec4, and don't qualify its methods. -pub trait Vec4Ext { - fn transpose4(a: Self, b: Self, c: Self, d: Self) -> (Self, Self, Self, Self) - where - Self: Sized; -} -pub trait Vector { - fn to_scalars(self) -> T; -} - -// TODO: multiples of 4 should inherit this -/// A vector composed of four words; depending on their size, operations may cross lanes. -pub trait Words4 { - fn shuffle1230(self) -> Self; - fn shuffle2301(self) -> Self; - fn shuffle3012(self) -> Self; -} - -/// A vector composed one or more lanes each composed of four words. -pub trait LaneWords4 { - fn shuffle_lane_words1230(self) -> Self; - fn shuffle_lane_words2301(self) -> Self; - fn shuffle_lane_words3012(self) -> Self; -} - -// TODO: make this a part of BitOps -/// Exchange neigboring ranges of bits of the specified size -pub trait Swap64 { - fn swap1(self) -> Self; - fn swap2(self) -> Self; - fn swap4(self) -> Self; - fn swap8(self) -> Self; - fn swap16(self) -> Self; - fn swap32(self) -> Self; - fn swap64(self) -> Self; -} - -pub trait u32x4: - BitOps32 - + Store - + ArithOps - + Vec4 - + Words4 - + LaneWords4 - + StoreBytes - + MultiLane<[u32; 4]> - + Into -{ -} -pub trait u64x2: - BitOps64 + Store + ArithOps + Vec2 + MultiLane<[u64; 2]> + Into -{ -} -pub trait u128x1: - BitOps128 + Store + Swap64 + MultiLane<[u128; 1]> + Into -{ -} - -pub trait u32x4x2: - BitOps32 - + Store - + Vec2 - + MultiLane<[M::u32x4; 2]> - + ArithOps - + Into - + StoreBytes -{ -} -pub trait u64x2x2: - BitOps64 - + Store - + Vec2 - + MultiLane<[M::u64x2; 2]> - + ArithOps - + StoreBytes - + Into -{ -} -pub trait u64x4: - BitOps64 - + Store - + Vec4 - + MultiLane<[u64; 4]> - + ArithOps - + Words4 - + StoreBytes - + Into -{ -} -pub trait u128x2: - BitOps128 - + Store - + Vec2 - + MultiLane<[M::u128x1; 2]> - + Swap64 - + Into -{ -} - -pub trait u32x4x4: - BitOps32 - + Store - + Vec4 - + Vec4Ext - + Vector<[u32; 16]> - + MultiLane<[M::u32x4; 4]> - + ArithOps - + LaneWords4 - + Into - + StoreBytes -{ -} -pub trait u64x2x4: - BitOps64 - + Store - + Vec4 - + MultiLane<[M::u64x2; 4]> - + ArithOps - + Into -{ -} -// TODO: Words4 -pub trait u128x4: - BitOps128 - + Store - + Vec4 - + MultiLane<[M::u128x1; 4]> - + Swap64 - + Into -{ -} - -/// A vector composed of multiple 128-bit lanes. -pub trait MultiLane { - /// Split a multi-lane vector into single-lane vectors. - fn to_lanes(self) -> Lanes; - /// Build a multi-lane vector from individual lanes. - fn from_lanes(lanes: Lanes) -> Self; -} - -/// Combine single vectors into a multi-lane vector. -pub trait VZip { - fn vzip(self) -> V; -} - -impl VZip for T -where - V: MultiLane, -{ - #[inline(always)] - fn vzip(self) -> V { - V::from_lanes(self) - } -} - -pub trait Machine: Sized + Copy { - type u32x4: u32x4; - type u64x2: u64x2; - type u128x1: u128x1; - - type u32x4x2: u32x4x2; - type u64x2x2: u64x2x2; - type u64x4: u64x4; - type u128x2: u128x2; - - type u32x4x4: u32x4x4; - type u64x2x4: u64x2x4; - type u128x4: u128x4; - - #[inline(always)] - fn unpack>(self, s: S) -> V { - unsafe { V::unpack(s) } - } - - #[inline(always)] - fn vec(self, a: A) -> V - where - V: MultiLane
, - { - V::from_lanes(a) - } - - #[inline(always)] - fn read_le(self, input: &[u8]) -> V - where - V: StoreBytes, - { - unsafe { V::unsafe_read_le(input) } - } - - #[inline(always)] - fn read_be(self, input: &[u8]) -> V - where - V: StoreBytes, - { - unsafe { V::unsafe_read_be(input) } - } - - /// # Safety - /// Caller must ensure the type of Self is appropriate for the hardware of the execution - /// environment. - unsafe fn instance() -> Self; -} - -pub trait Store { - /// # Safety - /// Caller must ensure the type of Self is appropriate for the hardware of the execution - /// environment. - unsafe fn unpack(p: S) -> Self; -} - -pub trait StoreBytes { - /// # Safety - /// Caller must ensure the type of Self is appropriate for the hardware of the execution - /// environment. - unsafe fn unsafe_read_le(input: &[u8]) -> Self; - /// # Safety - /// Caller must ensure the type of Self is appropriate for the hardware of the execution - /// environment. - unsafe fn unsafe_read_be(input: &[u8]) -> Self; - fn write_le(self, out: &mut [u8]); - fn write_be(self, out: &mut [u8]); -} diff -Nru cargo-0.58.0/vendor/ppv-lite86/src/x86_64/mod.rs cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/x86_64/mod.rs --- cargo-0.58.0/vendor/ppv-lite86/src/x86_64/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/x86_64/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,437 +0,0 @@ -// crate minimums: sse2, x86_64 - -use crate::types::*; -use core::arch::x86_64::{__m128i, __m256i}; - -mod sse2; - -#[derive(Copy, Clone)] -pub struct YesS3; -#[derive(Copy, Clone)] -pub struct NoS3; - -#[derive(Copy, Clone)] -pub struct YesS4; -#[derive(Copy, Clone)] -pub struct NoS4; - -#[derive(Copy, Clone)] -pub struct YesA1; -#[derive(Copy, Clone)] -pub struct NoA1; - -#[derive(Copy, Clone)] -pub struct YesA2; -#[derive(Copy, Clone)] -pub struct NoA2; - -#[derive(Copy, Clone)] -pub struct YesNI; -#[derive(Copy, Clone)] -pub struct NoNI; - -use core::marker::PhantomData; - -#[derive(Copy, Clone)] -pub struct SseMachine(PhantomData<(S3, S4, NI)>); -impl Machine for SseMachine -where - sse2::u128x1_sse2: Swap64, - sse2::u64x2_sse2: BSwap + RotateEachWord32 + MultiLane<[u64; 2]> + Vec2, - sse2::u32x4_sse2: BSwap + RotateEachWord32 + MultiLane<[u32; 4]> + Vec4, - sse2::u64x4_sse2: BSwap + Words4, - sse2::u128x1_sse2: BSwap, - sse2::u128x2_sse2: Into>, - sse2::u128x2_sse2: Into>, - sse2::u128x2_sse2: Into>, - sse2::u128x4_sse2: Into>, - sse2::u128x4_sse2: Into>, -{ - type u32x4 = sse2::u32x4_sse2; - type u64x2 = sse2::u64x2_sse2; - type u128x1 = sse2::u128x1_sse2; - - type u32x4x2 = sse2::u32x4x2_sse2; - type u64x2x2 = sse2::u64x2x2_sse2; - type u64x4 = sse2::u64x4_sse2; - type u128x2 = sse2::u128x2_sse2; - - type u32x4x4 = sse2::u32x4x4_sse2; - type u64x2x4 = sse2::u64x2x4_sse2; - type u128x4 = sse2::u128x4_sse2; - - #[inline(always)] - unsafe fn instance() -> Self { - SseMachine(PhantomData) - } -} - -#[derive(Copy, Clone)] -pub struct Avx2Machine(PhantomData); -impl Machine for Avx2Machine -where - sse2::u128x1_sse2: BSwap + Swap64, - sse2::u64x2_sse2: BSwap + RotateEachWord32 + MultiLane<[u64; 2]> + Vec2, - sse2::u32x4_sse2: BSwap + RotateEachWord32 + MultiLane<[u32; 4]> + Vec4, - sse2::u64x4_sse2: BSwap + Words4, -{ - type u32x4 = sse2::u32x4_sse2; - type u64x2 = sse2::u64x2_sse2; - type u128x1 = sse2::u128x1_sse2; - - type u32x4x2 = sse2::avx2::u32x4x2_avx2; - type u64x2x2 = sse2::u64x2x2_sse2; - type u64x4 = sse2::u64x4_sse2; - type u128x2 = sse2::u128x2_sse2; - - type u32x4x4 = sse2::avx2::u32x4x4_avx2; - type u64x2x4 = sse2::u64x2x4_sse2; - type u128x4 = sse2::u128x4_sse2; - - #[inline(always)] - unsafe fn instance() -> Self { - Avx2Machine(PhantomData) - } -} - -pub type SSE2 = SseMachine; -pub type SSSE3 = SseMachine; -pub type SSE41 = SseMachine; -/// AVX but not AVX2: only 128-bit integer operations, but use VEX versions of everything -/// to avoid expensive SSE/VEX conflicts. -pub type AVX = SseMachine; -pub type AVX2 = Avx2Machine; - -/// Generic wrapper for unparameterized storage of any of the possible impls. -/// Converting into and out of this type should be essentially free, although it may be more -/// aligned than a particular impl requires. -#[allow(non_camel_case_types)] -#[derive(Copy, Clone)] -pub union vec128_storage { - u32x4: [u32; 4], - u64x2: [u64; 2], - u128x1: [u128; 1], - sse2: __m128i, -} -impl Store for vec128_storage { - #[inline(always)] - unsafe fn unpack(p: vec128_storage) -> Self { - p - } -} -impl<'a> From<&'a vec128_storage> for &'a [u32; 4] { - #[inline(always)] - fn from(x: &'a vec128_storage) -> Self { - unsafe { &x.u32x4 } - } -} -impl From<[u32; 4]> for vec128_storage { - #[inline(always)] - fn from(u32x4: [u32; 4]) -> Self { - vec128_storage { u32x4 } - } -} -impl Default for vec128_storage { - #[inline(always)] - fn default() -> Self { - vec128_storage { u128x1: [0] } - } -} -impl Eq for vec128_storage {} -impl PartialEq for vec128_storage { - #[inline(always)] - fn eq(&self, rhs: &Self) -> bool { - unsafe { self.u128x1 == rhs.u128x1 } - } -} - -#[allow(non_camel_case_types)] -#[derive(Copy, Clone)] -pub union vec256_storage { - u32x8: [u32; 8], - u64x4: [u64; 4], - u128x2: [u128; 2], - sse2: [vec128_storage; 2], - avx: __m256i, -} -impl From<[u64; 4]> for vec256_storage { - #[inline(always)] - fn from(u64x4: [u64; 4]) -> Self { - vec256_storage { u64x4 } - } -} -impl Default for vec256_storage { - #[inline(always)] - fn default() -> Self { - vec256_storage { u128x2: [0, 0] } - } -} -impl vec256_storage { - #[inline(always)] - pub fn new128(xs: [vec128_storage; 2]) -> Self { - Self { sse2: xs } - } - #[inline(always)] - pub fn split128(self) -> [vec128_storage; 2] { - unsafe { self.sse2 } - } -} -impl Eq for vec256_storage {} -impl PartialEq for vec256_storage { - #[inline(always)] - fn eq(&self, rhs: &Self) -> bool { - unsafe { self.sse2 == rhs.sse2 } - } -} - -#[allow(non_camel_case_types)] -#[derive(Copy, Clone)] -pub union vec512_storage { - u32x16: [u32; 16], - u64x8: [u64; 8], - u128x4: [u128; 4], - sse2: [vec128_storage; 4], - avx: [vec256_storage; 2], -} -impl Default for vec512_storage { - #[inline(always)] - fn default() -> Self { - vec512_storage { - u128x4: [0, 0, 0, 0], - } - } -} -impl vec512_storage { - #[inline(always)] - pub fn new128(xs: [vec128_storage; 4]) -> Self { - Self { sse2: xs } - } - #[inline(always)] - pub fn split128(self) -> [vec128_storage; 4] { - unsafe { self.sse2 } - } -} -impl Eq for vec512_storage {} -impl PartialEq for vec512_storage { - #[inline(always)] - fn eq(&self, rhs: &Self) -> bool { - unsafe { self.avx == rhs.avx } - } -} - -macro_rules! impl_into { - ($storage:ident, $array:ty, $name:ident) => { - impl From<$storage> for $array { - #[inline(always)] - fn from(vec: $storage) -> Self { - unsafe { vec.$name } - } - } - }; -} -impl_into!(vec128_storage, [u32; 4], u32x4); -impl_into!(vec128_storage, [u64; 2], u64x2); -impl_into!(vec128_storage, [u128; 1], u128x1); -impl_into!(vec256_storage, [u32; 8], u32x8); -impl_into!(vec256_storage, [u64; 4], u64x4); -impl_into!(vec256_storage, [u128; 2], u128x2); -impl_into!(vec512_storage, [u32; 16], u32x16); -impl_into!(vec512_storage, [u64; 8], u64x8); -impl_into!(vec512_storage, [u128; 4], u128x4); - -/// Generate the full set of optimized implementations to take advantage of the most important -/// hardware feature sets. -/// -/// This dispatcher is suitable for maximizing throughput. -#[macro_export] -macro_rules! dispatch { - ($mach:ident, $MTy:ident, { $([$pub:tt$(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty $body:block }) => { - #[cfg(feature = "std")] - $($pub$(($krate))*)* fn $name($($arg: $argty),*) -> $ret { - #[inline(always)] - fn fn_impl<$MTy: $crate::Machine>($mach: $MTy, $($arg: $argty),*) -> $ret $body - use std::arch::x86_64::*; - #[target_feature(enable = "avx2")] - unsafe fn impl_avx2($($arg: $argty),*) -> $ret { - let ret = fn_impl($crate::x86_64::AVX2::instance(), $($arg),*); - _mm256_zeroupper(); - ret - } - #[target_feature(enable = "avx")] - #[target_feature(enable = "sse4.1")] - #[target_feature(enable = "ssse3")] - unsafe fn impl_avx($($arg: $argty),*) -> $ret { - let ret = fn_impl($crate::x86_64::AVX::instance(), $($arg),*); - _mm256_zeroupper(); - ret - } - #[target_feature(enable = "sse4.1")] - #[target_feature(enable = "ssse3")] - unsafe fn impl_sse41($($arg: $argty),*) -> $ret { - fn_impl($crate::x86_64::SSE41::instance(), $($arg),*) - } - #[target_feature(enable = "ssse3")] - unsafe fn impl_ssse3($($arg: $argty),*) -> $ret { - fn_impl($crate::x86_64::SSSE3::instance(), $($arg),*) - } - #[target_feature(enable = "sse2")] - unsafe fn impl_sse2($($arg: $argty),*) -> $ret { - fn_impl($crate::x86_64::SSE2::instance(), $($arg),*) - } - unsafe { - if is_x86_feature_detected!("avx2") { - impl_avx2($($arg),*) - } else if is_x86_feature_detected!("avx") { - impl_avx($($arg),*) - } else if is_x86_feature_detected!("sse4.1") { - impl_sse41($($arg),*) - } else if is_x86_feature_detected!("ssse3") { - impl_ssse3($($arg),*) - } else if is_x86_feature_detected!("sse2") { - impl_sse2($($arg),*) - } else { - unimplemented!() - } - } - } - #[cfg(not(feature = "std"))] - #[inline(always)] - $($pub$(($krate))*)* fn $name($($arg: $argty),*) -> $ret { - unsafe fn fn_impl<$MTy: $crate::Machine>($mach: $MTy, $($arg: $argty),*) -> $ret $body - unsafe { - if cfg!(target_feature = "avx2") { - fn_impl($crate::x86_64::AVX2::instance(), $($arg),*) - } else if cfg!(target_feature = "avx") { - fn_impl($crate::x86_64::AVX::instance(), $($arg),*) - } else if cfg!(target_feature = "sse4.1") { - fn_impl($crate::x86_64::SSE41::instance(), $($arg),*) - } else if cfg!(target_feature = "ssse3") { - fn_impl($crate::x86_64::SSSE3::instance(), $($arg),*) - } else { - fn_impl($crate::x86_64::SSE2::instance(), $($arg),*) - } - } - } - }; - ($mach:ident, $MTy:ident, { $([$pub:tt $(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) $body:block }) => { - dispatch!($mach, $MTy, { - $([$pub $(($krate))*])* fn $name($($arg: $argty),*) -> () $body - }); - } -} - -/// Generate only the basic implementations necessary to be able to operate efficiently on 128-bit -/// vectors on this platfrom. For x86-64, that would mean SSE2 and AVX. -/// -/// This dispatcher is suitable for vector operations that do not benefit from advanced hardware -/// features (e.g. because they are done infrequently), so minimizing their contribution to code -/// size is more important. -#[macro_export] -macro_rules! dispatch_light128 { - ($mach:ident, $MTy:ident, { $([$pub:tt$(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty $body:block }) => { - #[cfg(feature = "std")] - $($pub $(($krate))*)* fn $name($($arg: $argty),*) -> $ret { - #[inline(always)] - fn fn_impl<$MTy: $crate::Machine>($mach: $MTy, $($arg: $argty),*) -> $ret $body - use std::arch::x86_64::*; - #[target_feature(enable = "avx")] - unsafe fn impl_avx($($arg: $argty),*) -> $ret { - fn_impl($crate::x86_64::AVX::instance(), $($arg),*) - } - #[target_feature(enable = "sse2")] - unsafe fn impl_sse2($($arg: $argty),*) -> $ret { - fn_impl($crate::x86_64::SSE2::instance(), $($arg),*) - } - unsafe { - if is_x86_feature_detected!("avx") { - impl_avx($($arg),*) - } else if is_x86_feature_detected!("sse2") { - impl_sse2($($arg),*) - } else { - unimplemented!() - } - } - } - #[cfg(not(feature = "std"))] - #[inline(always)] - $($pub$(($krate))*)* fn $name($($arg: $argty),*) -> $ret { - unsafe fn fn_impl<$MTy: $crate::Machine>($mach: $MTy, $($arg: $argty),*) -> $ret $body - unsafe { - if cfg!(target_feature = "avx2") { - fn_impl($crate::x86_64::AVX2::instance(), $($arg),*) - } else if cfg!(target_feature = "avx") { - fn_impl($crate::x86_64::AVX::instance(), $($arg),*) - } else if cfg!(target_feature = "sse4.1") { - fn_impl($crate::x86_64::SSE41::instance(), $($arg),*) - } else if cfg!(target_feature = "ssse3") { - fn_impl($crate::x86_64::SSSE3::instance(), $($arg),*) - } else { - fn_impl($crate::x86_64::SSE2::instance(), $($arg),*) - } - } - } - }; - ($mach:ident, $MTy:ident, { $([$pub:tt$(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) $body:block }) => { - dispatch_light128!($mach, $MTy, { - $([$pub $(($krate))*])* fn $name($($arg: $argty),*) -> () $body - }); - } -} - -/// Generate only the basic implementations necessary to be able to operate efficiently on 256-bit -/// vectors on this platfrom. For x86-64, that would mean SSE2, AVX, and AVX2. -/// -/// This dispatcher is suitable for vector operations that do not benefit from advanced hardware -/// features (e.g. because they are done infrequently), so minimizing their contribution to code -/// size is more important. -#[macro_export] -macro_rules! dispatch_light256 { - ($mach:ident, $MTy:ident, { $([$pub:tt$(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty $body:block }) => { - #[cfg(feature = "std")] - $([$pub $(($krate))*])* fn $name($($arg: $argty),*) -> $ret { - #[inline(always)] - fn fn_impl<$MTy: $crate::Machine>($mach: $MTy, $($arg: $argty),*) -> $ret $body - use std::arch::x86_64::*; - #[target_feature(enable = "avx")] - unsafe fn impl_avx($($arg: $argty),*) -> $ret { - fn_impl($crate::x86_64::AVX::instance(), $($arg),*) - } - #[target_feature(enable = "sse2")] - unsafe fn impl_sse2($($arg: $argty),*) -> $ret { - fn_impl($crate::x86_64::SSE2::instance(), $($arg),*) - } - unsafe { - if is_x86_feature_detected!("avx") { - impl_avx($($arg),*) - } else if is_x86_feature_detected!("sse2") { - impl_sse2($($arg),*) - } else { - unimplemented!() - } - } - } - #[cfg(not(feature = "std"))] - #[inline(always)] - $($pub$(($krate))*)* fn $name($($arg: $argty),*) -> $ret { - unsafe fn fn_impl<$MTy: $crate::Machine>($mach: $MTy, $($arg: $argty),*) -> $ret $body - unsafe { - if cfg!(target_feature = "avx2") { - fn_impl($crate::x86_64::AVX2::instance(), $($arg),*) - } else if cfg!(target_feature = "avx") { - fn_impl($crate::x86_64::AVX::instance(), $($arg),*) - } else if cfg!(target_feature = "sse4.1") { - fn_impl($crate::x86_64::SSE41::instance(), $($arg),*) - } else if cfg!(target_feature = "ssse3") { - fn_impl($crate::x86_64::SSSE3::instance(), $($arg),*) - } else { - fn_impl($crate::x86_64::SSE2::instance(), $($arg),*) - } - } - } - }; - ($mach:ident, $MTy:ident, { $([$pub:tt$(($krate:tt))*])* fn $name:ident($($arg:ident: $argty:ty),* $(,)*) $body:block }) => { - dispatch_light256!($mach, $MTy, { - $([$pub $(($krate))*])* fn $name($($arg: $argty),*) -> () $body - }); - } -} diff -Nru cargo-0.58.0/vendor/ppv-lite86/src/x86_64/sse2.rs cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/x86_64/sse2.rs --- cargo-0.58.0/vendor/ppv-lite86/src/x86_64/sse2.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/ppv-lite86/src/x86_64/sse2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,1703 +0,0 @@ -use crate::soft::{x2, x4}; -use crate::types::*; -use crate::vec128_storage; -use crate::x86_64::Avx2Machine; -use crate::x86_64::SseMachine as Machine86; -use crate::x86_64::{NoS3, NoS4, YesS3, YesS4}; -use core::arch::x86_64::*; -use core::marker::PhantomData; -use core::ops::{ - Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not, -}; - -macro_rules! impl_binop { - ($vec:ident, $trait:ident, $fn:ident, $impl_fn:ident) => { - impl $trait for $vec { - type Output = Self; - #[inline(always)] - fn $fn(self, rhs: Self) -> Self::Output { - Self::new(unsafe { $impl_fn(self.x, rhs.x) }) - } - } - }; -} - -macro_rules! impl_binop_assign { - ($vec:ident, $trait:ident, $fn_assign:ident, $fn:ident) => { - impl $trait for $vec - where - $vec: Copy, - { - #[inline(always)] - fn $fn_assign(&mut self, rhs: Self) { - *self = self.$fn(rhs); - } - } - }; -} - -macro_rules! def_vec { - ($vec:ident, $word:ident) => { - #[allow(non_camel_case_types)] - #[derive(Copy, Clone)] - pub struct $vec { - x: __m128i, - s3: PhantomData, - s4: PhantomData, - ni: PhantomData, - } - - impl Store for $vec { - #[inline(always)] - unsafe fn unpack(x: vec128_storage) -> Self { - Self::new(x.sse2) - } - } - impl From<$vec> for vec128_storage { - #[inline(always)] - fn from(x: $vec) -> Self { - vec128_storage { sse2: x.x } - } - } - impl $vec { - #[inline(always)] - fn new(x: __m128i) -> Self { - $vec { - x, - s3: PhantomData, - s4: PhantomData, - ni: PhantomData, - } - } - } - - impl StoreBytes for $vec - where - Self: BSwap, - { - #[inline(always)] - unsafe fn unsafe_read_le(input: &[u8]) -> Self { - assert_eq!(input.len(), 16); - Self::new(_mm_loadu_si128(input.as_ptr() as *const _)) - } - #[inline(always)] - unsafe fn unsafe_read_be(input: &[u8]) -> Self { - assert_eq!(input.len(), 16); - Self::new(_mm_loadu_si128(input.as_ptr() as *const _)).bswap() - } - #[inline(always)] - fn write_le(self, out: &mut [u8]) { - assert_eq!(out.len(), 16); - unsafe { _mm_storeu_si128(out.as_mut_ptr() as *mut _, self.x) } - } - #[inline(always)] - fn write_be(self, out: &mut [u8]) { - assert_eq!(out.len(), 16); - let x = self.bswap().x; - unsafe { - _mm_storeu_si128(out.as_mut_ptr() as *mut _, x); - } - } - } - - impl Default for $vec { - #[inline(always)] - fn default() -> Self { - Self::new(unsafe { _mm_setzero_si128() }) - } - } - - impl Not for $vec { - type Output = Self; - #[inline(always)] - fn not(self) -> Self::Output { - unsafe { - let ff = _mm_set1_epi64x(-1i64); - self ^ Self::new(ff) - } - } - } - - impl BitOps0 for $vec {} - impl_binop!($vec, BitAnd, bitand, _mm_and_si128); - impl_binop!($vec, BitOr, bitor, _mm_or_si128); - impl_binop!($vec, BitXor, bitxor, _mm_xor_si128); - impl_binop_assign!($vec, BitAndAssign, bitand_assign, bitand); - impl_binop_assign!($vec, BitOrAssign, bitor_assign, bitor); - impl_binop_assign!($vec, BitXorAssign, bitxor_assign, bitxor); - impl AndNot for $vec { - type Output = Self; - #[inline(always)] - fn andnot(self, rhs: Self) -> Self { - Self::new(unsafe { _mm_andnot_si128(self.x, rhs.x) }) - } - } - }; -} - -macro_rules! impl_bitops32 { - ($vec:ident) => { - impl BitOps32 for $vec where - $vec: RotateEachWord32 - { - } - }; -} - -macro_rules! impl_bitops64 { - ($vec:ident) => { - impl_bitops32!($vec); - impl BitOps64 for $vec where - $vec: RotateEachWord64 + RotateEachWord32 - { - } - }; -} - -macro_rules! impl_bitops128 { - ($vec:ident) => { - impl_bitops64!($vec); - impl BitOps128 for $vec where - $vec: RotateEachWord128 - { - } - }; -} - -macro_rules! rotr_32_s3 { - ($name:ident, $k0:expr, $k1:expr) => { - #[inline(always)] - fn $name(self) -> Self { - Self::new(unsafe { _mm_shuffle_epi8(self.x, _mm_set_epi64x($k0, $k1)) }) - } - }; -} -macro_rules! rotr_32 { - ($name:ident, $i:expr) => { - #[inline(always)] - fn $name(self) -> Self { - Self::new(unsafe { - _mm_or_si128( - _mm_srli_epi32(self.x, $i as i32), - _mm_slli_epi32(self.x, 32 - $i as i32), - ) - }) - } - }; -} -impl RotateEachWord32 for u32x4_sse2 { - rotr_32!(rotate_each_word_right7, 7); - rotr_32_s3!( - rotate_each_word_right8, - 0x0c0f_0e0d_080b_0a09, - 0x0407_0605_0003_0201 - ); - rotr_32!(rotate_each_word_right11, 11); - rotr_32!(rotate_each_word_right12, 12); - rotr_32_s3!( - rotate_each_word_right16, - 0x0d0c_0f0e_0908_0b0a, - 0x0504_0706_0100_0302 - ); - rotr_32!(rotate_each_word_right20, 20); - rotr_32_s3!( - rotate_each_word_right24, - 0x0e0d_0c0f_0a09_080b, - 0x0605_0407_0201_0003 - ); - rotr_32!(rotate_each_word_right25, 25); -} -impl RotateEachWord32 for u32x4_sse2 { - rotr_32!(rotate_each_word_right7, 7); - rotr_32!(rotate_each_word_right8, 8); - rotr_32!(rotate_each_word_right11, 11); - rotr_32!(rotate_each_word_right12, 12); - #[inline(always)] - fn rotate_each_word_right16(self) -> Self { - Self::new(swap16_s2(self.x)) - } - rotr_32!(rotate_each_word_right20, 20); - rotr_32!(rotate_each_word_right24, 24); - rotr_32!(rotate_each_word_right25, 25); -} - -macro_rules! rotr_64_s3 { - ($name:ident, $k0:expr, $k1:expr) => { - #[inline(always)] - fn $name(self) -> Self { - Self::new(unsafe { _mm_shuffle_epi8(self.x, _mm_set_epi64x($k0, $k1)) }) - } - }; -} -macro_rules! rotr_64 { - ($name:ident, $i:expr) => { - #[inline(always)] - fn $name(self) -> Self { - Self::new(unsafe { - _mm_or_si128( - _mm_srli_epi64(self.x, $i as i32), - _mm_slli_epi64(self.x, 64 - $i as i32), - ) - }) - } - }; -} -impl RotateEachWord32 for u64x2_sse2 { - rotr_64!(rotate_each_word_right7, 7); - rotr_64_s3!( - rotate_each_word_right8, - 0x080f_0e0d_0c0b_0a09, - 0x0007_0605_0403_0201 - ); - rotr_64!(rotate_each_word_right11, 11); - rotr_64!(rotate_each_word_right12, 12); - rotr_64_s3!( - rotate_each_word_right16, - 0x0908_0f0e_0d0c_0b0a, - 0x0100_0706_0504_0302 - ); - rotr_64!(rotate_each_word_right20, 20); - rotr_64_s3!( - rotate_each_word_right24, - 0x0a09_080f_0e0d_0c0b, - 0x0201_0007_0605_0403 - ); - rotr_64!(rotate_each_word_right25, 25); -} -impl RotateEachWord32 for u64x2_sse2 { - rotr_64!(rotate_each_word_right7, 7); - rotr_64!(rotate_each_word_right8, 8); - rotr_64!(rotate_each_word_right11, 11); - rotr_64!(rotate_each_word_right12, 12); - #[inline(always)] - fn rotate_each_word_right16(self) -> Self { - Self::new(swap16_s2(self.x)) - } - rotr_64!(rotate_each_word_right20, 20); - rotr_64!(rotate_each_word_right24, 24); - rotr_64!(rotate_each_word_right25, 25); -} -impl RotateEachWord64 for u64x2_sse2 { - #[inline(always)] - fn rotate_each_word_right32(self) -> Self { - Self::new(unsafe { _mm_shuffle_epi32(self.x, 0b10110001) }) - } -} - -macro_rules! rotr_128 { - ($name:ident, $i:expr) => { - #[inline(always)] - fn $name(self) -> Self { - Self::new(unsafe { - _mm_or_si128( - _mm_srli_si128(self.x, $i as i32), - _mm_slli_si128(self.x, 128 - $i as i32), - ) - }) - } - }; -} -// TODO: completely unoptimized -impl RotateEachWord32 for u128x1_sse2 { - rotr_128!(rotate_each_word_right7, 7); - rotr_128!(rotate_each_word_right8, 8); - rotr_128!(rotate_each_word_right11, 11); - rotr_128!(rotate_each_word_right12, 12); - rotr_128!(rotate_each_word_right16, 16); - rotr_128!(rotate_each_word_right20, 20); - rotr_128!(rotate_each_word_right24, 24); - rotr_128!(rotate_each_word_right25, 25); -} -// TODO: completely unoptimized -impl RotateEachWord64 for u128x1_sse2 { - rotr_128!(rotate_each_word_right32, 32); -} -impl RotateEachWord128 for u128x1_sse2 {} - -def_vec!(u32x4_sse2, u32); -def_vec!(u64x2_sse2, u64); -def_vec!(u128x1_sse2, u128); - -impl MultiLane<[u32; 4]> for u32x4_sse2 { - #[inline(always)] - fn to_lanes(self) -> [u32; 4] { - unsafe { - let x = _mm_cvtsi128_si64(self.x) as u64; - let y = _mm_extract_epi64(self.x, 1) as u64; - [x as u32, (x >> 32) as u32, y as u32, (y >> 32) as u32] - } - } - #[inline(always)] - fn from_lanes(xs: [u32; 4]) -> Self { - unsafe { - let mut x = _mm_cvtsi64_si128((xs[0] as u64 | ((xs[1] as u64) << 32)) as i64); - x = _mm_insert_epi64(x, (xs[2] as u64 | ((xs[3] as u64) << 32)) as i64, 1); - Self::new(x) - } - } -} -impl MultiLane<[u32; 4]> for u32x4_sse2 { - #[inline(always)] - fn to_lanes(self) -> [u32; 4] { - unsafe { - let x = _mm_cvtsi128_si64(self.x) as u64; - let y = _mm_cvtsi128_si64(_mm_shuffle_epi32(self.x, 0b11101110)) as u64; - [x as u32, (x >> 32) as u32, y as u32, (y >> 32) as u32] - } - } - #[inline(always)] - fn from_lanes(xs: [u32; 4]) -> Self { - unsafe { - let x = (xs[0] as u64 | ((xs[1] as u64) << 32)) as i64; - let y = (xs[2] as u64 | ((xs[3] as u64) << 32)) as i64; - let x = _mm_cvtsi64_si128(x); - let y = _mm_slli_si128(_mm_cvtsi64_si128(y), 8); - Self::new(_mm_or_si128(x, y)) - } - } -} -impl MultiLane<[u64; 2]> for u64x2_sse2 { - #[inline(always)] - fn to_lanes(self) -> [u64; 2] { - unsafe { - [ - _mm_cvtsi128_si64(self.x) as u64, - _mm_extract_epi64(self.x, 1) as u64, - ] - } - } - #[inline(always)] - fn from_lanes(xs: [u64; 2]) -> Self { - unsafe { - let mut x = _mm_cvtsi64_si128(xs[0] as i64); - x = _mm_insert_epi64(x, xs[1] as i64, 1); - Self::new(x) - } - } -} -impl MultiLane<[u64; 2]> for u64x2_sse2 { - #[inline(always)] - fn to_lanes(self) -> [u64; 2] { - unsafe { - [ - _mm_cvtsi128_si64(self.x) as u64, - _mm_cvtsi128_si64(_mm_srli_si128(self.x, 8)) as u64, - ] - } - } - #[inline(always)] - fn from_lanes(xs: [u64; 2]) -> Self { - unsafe { - let x = _mm_cvtsi64_si128(xs[0] as i64); - let y = _mm_slli_si128(_mm_cvtsi64_si128(xs[1] as i64), 8); - Self::new(_mm_or_si128(x, y)) - } - } -} -impl MultiLane<[u128; 1]> for u128x1_sse2 { - #[inline(always)] - fn to_lanes(self) -> [u128; 1] { - unimplemented!() - } - #[inline(always)] - fn from_lanes(xs: [u128; 1]) -> Self { - unimplemented!("{:?}", xs) - } -} - -impl MultiLane<[u64; 4]> for u64x4_sse2 -where - u64x2_sse2: MultiLane<[u64; 2]> + Copy, -{ - #[inline(always)] - fn to_lanes(self) -> [u64; 4] { - let (a, b) = (self.0[0].to_lanes(), self.0[1].to_lanes()); - [a[0], a[1], b[0], b[1]] - } - #[inline(always)] - fn from_lanes(xs: [u64; 4]) -> Self { - let (a, b) = ( - u64x2_sse2::from_lanes([xs[0], xs[1]]), - u64x2_sse2::from_lanes([xs[2], xs[3]]), - ); - x2::new([a, b]) - } -} - -macro_rules! impl_into { - ($from:ident, $to:ident) => { - impl From<$from> for $to { - #[inline(always)] - fn from(x: $from) -> Self { - $to::new(x.x) - } - } - }; -} - -impl_into!(u128x1_sse2, u32x4_sse2); -impl_into!(u128x1_sse2, u64x2_sse2); - -impl_bitops32!(u32x4_sse2); -impl_bitops64!(u64x2_sse2); -impl_bitops128!(u128x1_sse2); - -impl ArithOps for u32x4_sse2 where - u32x4_sse2: BSwap -{ -} -impl ArithOps for u64x2_sse2 where - u64x2_sse2: BSwap -{ -} -impl_binop!(u32x4_sse2, Add, add, _mm_add_epi32); -impl_binop!(u64x2_sse2, Add, add, _mm_add_epi64); -impl_binop_assign!(u32x4_sse2, AddAssign, add_assign, add); -impl_binop_assign!(u64x2_sse2, AddAssign, add_assign, add); - -impl u32x4> for u32x4_sse2 -where - u32x4_sse2: RotateEachWord32 + BSwap + MultiLane<[u32; 4]> + Vec4, - Machine86: Machine, -{ -} -impl u64x2> for u64x2_sse2 -where - u64x2_sse2: - RotateEachWord64 + RotateEachWord32 + BSwap + MultiLane<[u64; 2]> + Vec2, - Machine86: Machine, -{ -} -impl u128x1> for u128x1_sse2 -where - u128x1_sse2: Swap64 + RotateEachWord64 + RotateEachWord32 + BSwap, - Machine86: Machine, - u128x1_sse2: Into< as Machine>::u32x4>, - u128x1_sse2: Into< as Machine>::u64x2>, -{ -} - -impl u32x4> for u32x4_sse2 -where - u32x4_sse2: RotateEachWord32 + BSwap + MultiLane<[u32; 4]> + Vec4, - Machine86: Machine, -{ -} -impl u64x2> for u64x2_sse2 -where - u64x2_sse2: - RotateEachWord64 + RotateEachWord32 + BSwap + MultiLane<[u64; 2]> + Vec2, - Machine86: Machine, -{ -} -impl u128x1> for u128x1_sse2 -where - u128x1_sse2: Swap64 + RotateEachWord64 + RotateEachWord32 + BSwap, - Machine86: Machine, - u128x1_sse2: Into< as Machine>::u32x4>, - u128x1_sse2: Into< as Machine>::u64x2>, -{ -} - -impl UnsafeFrom<[u32; 4]> for u32x4_sse2 { - #[inline(always)] - unsafe fn unsafe_from(xs: [u32; 4]) -> Self { - Self::new(_mm_set_epi32( - xs[3] as i32, - xs[2] as i32, - xs[1] as i32, - xs[0] as i32, - )) - } -} - -impl Vec4 for u32x4_sse2 -where - Self: MultiLane<[u32; 4]>, -{ - #[inline(always)] - fn extract(self, i: u32) -> u32 { - self.to_lanes()[i as usize] - } - #[inline(always)] - fn insert(self, v: u32, i: u32) -> Self { - Self::new(unsafe { - match i { - 0 => _mm_insert_epi32(self.x, v as i32, 0), - 1 => _mm_insert_epi32(self.x, v as i32, 1), - 2 => _mm_insert_epi32(self.x, v as i32, 2), - 3 => _mm_insert_epi32(self.x, v as i32, 3), - _ => unreachable!(), - } - }) - } -} -impl Vec4 for u32x4_sse2 -where - Self: MultiLane<[u32; 4]>, -{ - #[inline(always)] - fn extract(self, i: u32) -> u32 { - self.to_lanes()[i as usize] - } - #[inline(always)] - fn insert(self, v: u32, i: u32) -> Self { - Self::new(unsafe { - match i { - 0 => { - let x = _mm_andnot_si128(_mm_cvtsi32_si128(-1), self.x); - _mm_or_si128(x, _mm_cvtsi32_si128(v as i32)) - } - 1 => { - let mut x = _mm_shuffle_epi32(self.x, 0b0111_1000); - x = _mm_slli_si128(x, 4); - x = _mm_or_si128(x, _mm_cvtsi32_si128(v as i32)); - _mm_shuffle_epi32(x, 0b1110_0001) - } - 2 => { - let mut x = _mm_shuffle_epi32(self.x, 0b1011_0100); - x = _mm_slli_si128(x, 4); - x = _mm_or_si128(x, _mm_cvtsi32_si128(v as i32)); - _mm_shuffle_epi32(x, 0b1100_1001) - } - 3 => { - let mut x = _mm_slli_si128(self.x, 4); - x = _mm_or_si128(x, _mm_cvtsi32_si128(v as i32)); - _mm_shuffle_epi32(x, 0b0011_1001) - } - _ => unreachable!(), - } - }) - } -} - -impl LaneWords4 for u32x4_sse2 { - #[inline(always)] - fn shuffle_lane_words2301(self) -> Self { - self.shuffle2301() - } - #[inline(always)] - fn shuffle_lane_words1230(self) -> Self { - self.shuffle1230() - } - #[inline(always)] - fn shuffle_lane_words3012(self) -> Self { - self.shuffle3012() - } -} - -impl Words4 for u32x4_sse2 { - #[inline(always)] - fn shuffle2301(self) -> Self { - Self::new(unsafe { _mm_shuffle_epi32(self.x, 0b0100_1110) }) - } - #[inline(always)] - fn shuffle1230(self) -> Self { - Self::new(unsafe { _mm_shuffle_epi32(self.x, 0b1001_0011) }) - } - #[inline(always)] - fn shuffle3012(self) -> Self { - Self::new(unsafe { _mm_shuffle_epi32(self.x, 0b0011_1001) }) - } -} - -impl Words4 for u64x4_sse2 { - #[inline(always)] - fn shuffle2301(self) -> Self { - x2::new([u64x2_sse2::new(self.0[1].x), u64x2_sse2::new(self.0[0].x)]) - } - #[inline(always)] - fn shuffle3012(self) -> Self { - unsafe { - x2::new([ - u64x2_sse2::new(_mm_alignr_epi8(self.0[1].x, self.0[0].x, 8)), - u64x2_sse2::new(_mm_alignr_epi8(self.0[0].x, self.0[1].x, 8)), - ]) - } - } - #[inline(always)] - fn shuffle1230(self) -> Self { - unsafe { - x2::new([ - u64x2_sse2::new(_mm_alignr_epi8(self.0[0].x, self.0[1].x, 8)), - u64x2_sse2::new(_mm_alignr_epi8(self.0[1].x, self.0[0].x, 8)), - ]) - } - } -} -impl Words4 for u64x4_sse2 { - #[inline(always)] - fn shuffle2301(self) -> Self { - x2::new([u64x2_sse2::new(self.0[1].x), u64x2_sse2::new(self.0[0].x)]) - } - #[inline(always)] - fn shuffle3012(self) -> Self { - unsafe { - let a = _mm_srli_si128(self.0[0].x, 8); - let b = _mm_slli_si128(self.0[0].x, 8); - let c = _mm_srli_si128(self.0[1].x, 8); - let d = _mm_slli_si128(self.0[1].x, 8); - let da = _mm_or_si128(d, a); - let bc = _mm_or_si128(b, c); - x2::new([u64x2_sse2::new(da), u64x2_sse2::new(bc)]) - } - } - #[inline(always)] - fn shuffle1230(self) -> Self { - unsafe { - let a = _mm_srli_si128(self.0[0].x, 8); - let b = _mm_slli_si128(self.0[0].x, 8); - let c = _mm_srli_si128(self.0[1].x, 8); - let d = _mm_slli_si128(self.0[1].x, 8); - let da = _mm_or_si128(d, a); - let bc = _mm_or_si128(b, c); - x2::new([u64x2_sse2::new(bc), u64x2_sse2::new(da)]) - } - } -} - -impl UnsafeFrom<[u64; 2]> for u64x2_sse2 { - #[inline(always)] - unsafe fn unsafe_from(xs: [u64; 2]) -> Self { - Self::new(_mm_set_epi64x(xs[1] as i64, xs[0] as i64)) - } -} - -impl Vec2 for u64x2_sse2 { - #[inline(always)] - fn extract(self, i: u32) -> u64 { - unsafe { - match i { - 0 => _mm_cvtsi128_si64(self.x) as u64, - 1 => _mm_extract_epi64(self.x, 1) as u64, - _ => unreachable!(), - } - } - } - #[inline(always)] - fn insert(self, x: u64, i: u32) -> Self { - Self::new(unsafe { - match i { - 0 => _mm_insert_epi64(self.x, x as i64, 0), - 1 => _mm_insert_epi64(self.x, x as i64, 1), - _ => unreachable!(), - } - }) - } -} -impl Vec2 for u64x2_sse2 { - #[inline(always)] - fn extract(self, i: u32) -> u64 { - unsafe { - match i { - 0 => _mm_cvtsi128_si64(self.x) as u64, - 1 => _mm_cvtsi128_si64(_mm_shuffle_epi32(self.x, 0b11101110)) as u64, - _ => unreachable!(), - } - } - } - #[inline(always)] - fn insert(self, x: u64, i: u32) -> Self { - Self::new(unsafe { - match i { - 0 => _mm_or_si128( - _mm_andnot_si128(_mm_cvtsi64_si128(-1), self.x), - _mm_cvtsi64_si128(x as i64), - ), - 1 => _mm_or_si128( - _mm_move_epi64(self.x), - _mm_slli_si128(_mm_cvtsi64_si128(x as i64), 8), - ), - _ => unreachable!(), - } - }) - } -} - -impl BSwap for u32x4_sse2 { - #[inline(always)] - fn bswap(self) -> Self { - Self::new(unsafe { - let k = _mm_set_epi64x(0x0c0d_0e0f_0809_0a0b, 0x0405_0607_0001_0203); - _mm_shuffle_epi8(self.x, k) - }) - } -} -#[inline(always)] -fn bswap32_s2(x: __m128i) -> __m128i { - unsafe { - let mut y = _mm_unpacklo_epi8(x, _mm_setzero_si128()); - y = _mm_shufflehi_epi16(y, 0b0001_1011); - y = _mm_shufflelo_epi16(y, 0b0001_1011); - let mut z = _mm_unpackhi_epi8(x, _mm_setzero_si128()); - z = _mm_shufflehi_epi16(z, 0b0001_1011); - z = _mm_shufflelo_epi16(z, 0b0001_1011); - _mm_packus_epi16(y, z) - } -} -impl BSwap for u32x4_sse2 { - #[inline(always)] - fn bswap(self) -> Self { - Self::new(bswap32_s2(self.x)) - } -} - -impl BSwap for u64x2_sse2 { - #[inline(always)] - fn bswap(self) -> Self { - Self::new(unsafe { - let k = _mm_set_epi64x(0x0809_0a0b_0c0d_0e0f, 0x0001_0203_0405_0607); - _mm_shuffle_epi8(self.x, k) - }) - } -} -impl BSwap for u64x2_sse2 { - #[inline(always)] - fn bswap(self) -> Self { - Self::new(unsafe { bswap32_s2(_mm_shuffle_epi32(self.x, 0b1011_0001)) }) - } -} - -impl BSwap for u128x1_sse2 { - #[inline(always)] - fn bswap(self) -> Self { - Self::new(unsafe { - let k = _mm_set_epi64x(0x0f0e_0d0c_0b0a_0908, 0x0706_0504_0302_0100); - _mm_shuffle_epi8(self.x, k) - }) - } -} -impl BSwap for u128x1_sse2 { - #[inline(always)] - fn bswap(self) -> Self { - unimplemented!() - } -} - -macro_rules! swapi { - ($x:expr, $i:expr, $k:expr) => { - unsafe { - const K: u8 = $k; - let k = _mm_set1_epi8(K as i8); - u128x1_sse2::new(_mm_or_si128( - _mm_srli_epi16(_mm_and_si128($x.x, k), $i), - _mm_and_si128(_mm_slli_epi16($x.x, $i), k), - )) - } - }; -} -#[inline(always)] -fn swap16_s2(x: __m128i) -> __m128i { - unsafe { _mm_shufflehi_epi16(_mm_shufflelo_epi16(x, 0b1011_0001), 0b1011_0001) } -} -impl Swap64 for u128x1_sse2 { - #[inline(always)] - fn swap1(self) -> Self { - swapi!(self, 1, 0xaa) - } - #[inline(always)] - fn swap2(self) -> Self { - swapi!(self, 2, 0xcc) - } - #[inline(always)] - fn swap4(self) -> Self { - swapi!(self, 4, 0xf0) - } - #[inline(always)] - fn swap8(self) -> Self { - u128x1_sse2::new(unsafe { - let k = _mm_set_epi64x(0x0e0f_0c0d_0a0b_0809, 0x0607_0405_0203_0001); - _mm_shuffle_epi8(self.x, k) - }) - } - #[inline(always)] - fn swap16(self) -> Self { - u128x1_sse2::new(unsafe { - let k = _mm_set_epi64x(0x0d0c_0f0e_0908_0b0a, 0x0504_0706_0100_0302); - _mm_shuffle_epi8(self.x, k) - }) - } - #[inline(always)] - fn swap32(self) -> Self { - u128x1_sse2::new(unsafe { _mm_shuffle_epi32(self.x, 0b1011_0001) }) - } - #[inline(always)] - fn swap64(self) -> Self { - u128x1_sse2::new(unsafe { _mm_shuffle_epi32(self.x, 0b0100_1110) }) - } -} -impl Swap64 for u128x1_sse2 { - #[inline(always)] - fn swap1(self) -> Self { - swapi!(self, 1, 0xaa) - } - #[inline(always)] - fn swap2(self) -> Self { - swapi!(self, 2, 0xcc) - } - #[inline(always)] - fn swap4(self) -> Self { - swapi!(self, 4, 0xf0) - } - #[inline(always)] - fn swap8(self) -> Self { - u128x1_sse2::new(unsafe { - _mm_or_si128(_mm_slli_epi16(self.x, 8), _mm_srli_epi16(self.x, 8)) - }) - } - #[inline(always)] - fn swap16(self) -> Self { - u128x1_sse2::new(swap16_s2(self.x)) - } - #[inline(always)] - fn swap32(self) -> Self { - u128x1_sse2::new(unsafe { _mm_shuffle_epi32(self.x, 0b1011_0001) }) - } - #[inline(always)] - fn swap64(self) -> Self { - u128x1_sse2::new(unsafe { _mm_shuffle_epi32(self.x, 0b0100_1110) }) - } -} - -#[derive(Copy, Clone)] -pub struct G0; -#[derive(Copy, Clone)] -pub struct G1; - -#[allow(non_camel_case_types)] -pub type u32x4x2_sse2 = x2, G0>; -#[allow(non_camel_case_types)] -pub type u64x2x2_sse2 = x2, G0>; -#[allow(non_camel_case_types)] -pub type u64x4_sse2 = x2, G1>; -#[allow(non_camel_case_types)] -pub type u128x2_sse2 = x2, G0>; - -#[allow(non_camel_case_types)] -pub type u32x4x4_sse2 = x4>; -#[allow(non_camel_case_types)] -pub type u64x2x4_sse2 = x4>; -#[allow(non_camel_case_types)] -pub type u128x4_sse2 = x4>; - -impl Vector<[u32; 16]> for u32x4x4_sse2 { - #[inline(always)] - fn to_scalars(self) -> [u32; 16] { - unsafe { core::mem::transmute(self) } - } -} - -impl u32x4x2> for u32x4x2_sse2 -where - u32x4_sse2: RotateEachWord32 + BSwap, - Machine86: Machine, - u32x4x2_sse2: MultiLane<[ as Machine>::u32x4; 2]>, - u32x4x2_sse2: Vec2< as Machine>::u32x4>, -{ -} -impl u64x2x2> for u64x2x2_sse2 -where - u64x2_sse2: RotateEachWord64 + RotateEachWord32 + BSwap, - Machine86: Machine, - u64x2x2_sse2: MultiLane<[ as Machine>::u64x2; 2]>, - u64x2x2_sse2: Vec2< as Machine>::u64x2>, -{ -} -impl u64x4> for u64x4_sse2 -where - u64x2_sse2: RotateEachWord64 + RotateEachWord32 + BSwap, - Machine86: Machine, - u64x4_sse2: MultiLane<[u64; 4]> + Vec4 + Words4, -{ -} -impl u128x2> for u128x2_sse2 -where - u128x1_sse2: Swap64 + BSwap, - Machine86: Machine, - u128x2_sse2: MultiLane<[ as Machine>::u128x1; 2]>, - u128x2_sse2: Vec2< as Machine>::u128x1>, - u128x2_sse2: Into< as Machine>::u32x4x2>, - u128x2_sse2: Into< as Machine>::u64x2x2>, - u128x2_sse2: Into< as Machine>::u64x4>, -{ -} - -impl u32x4x2> for u32x4x2_sse2 -where - u32x4_sse2: RotateEachWord32 + BSwap, - Avx2Machine: Machine, - u32x4x2_sse2: MultiLane<[ as Machine>::u32x4; 2]>, - u32x4x2_sse2: Vec2< as Machine>::u32x4>, -{ -} -impl u64x2x2> for u64x2x2_sse2 -where - u64x2_sse2: RotateEachWord64 + RotateEachWord32 + BSwap, - Avx2Machine: Machine, - u64x2x2_sse2: MultiLane<[ as Machine>::u64x2; 2]>, - u64x2x2_sse2: Vec2< as Machine>::u64x2>, -{ -} -impl u64x4> for u64x4_sse2 -where - u64x2_sse2: RotateEachWord64 + RotateEachWord32 + BSwap, - Avx2Machine: Machine, - u64x4_sse2: MultiLane<[u64; 4]> + Vec4 + Words4, -{ -} -impl u128x2> for u128x2_sse2 -where - u128x1_sse2: Swap64 + BSwap, - Avx2Machine: Machine, - u128x2_sse2: MultiLane<[ as Machine>::u128x1; 2]>, - u128x2_sse2: Vec2< as Machine>::u128x1>, - u128x2_sse2: Into< as Machine>::u32x4x2>, - u128x2_sse2: Into< as Machine>::u64x2x2>, - u128x2_sse2: Into< as Machine>::u64x4>, -{ -} - -impl Vec4 for u64x4_sse2 -where - u64x2_sse2: Copy + Vec2, -{ - #[inline(always)] - fn extract(self, i: u32) -> u64 { - match i { - 0 => self.0[0].extract(0), - 1 => self.0[0].extract(1), - 2 => self.0[1].extract(0), - 3 => self.0[1].extract(1), - _ => panic!(), - } - } - #[inline(always)] - fn insert(mut self, w: u64, i: u32) -> Self { - match i { - 0 => self.0[0] = self.0[0].insert(w, 0), - 1 => self.0[0] = self.0[0].insert(w, 1), - 2 => self.0[1] = self.0[1].insert(w, 0), - 3 => self.0[1] = self.0[1].insert(w, 1), - _ => panic!(), - }; - self - } -} - -impl u32x4x4> for u32x4x4_sse2 -where - u32x4_sse2: RotateEachWord32 + BSwap, - Machine86: Machine, - u32x4x4_sse2: MultiLane<[ as Machine>::u32x4; 4]>, - u32x4x4_sse2: Vec4< as Machine>::u32x4>, - u32x4x4_sse2: Vec4Ext< as Machine>::u32x4>, - u32x4x4_sse2: Vector<[u32; 16]>, -{ -} -impl u64x2x4> for u64x2x4_sse2 -where - u64x2_sse2: RotateEachWord64 + RotateEachWord32 + BSwap, - Machine86: Machine, - u64x2x4_sse2: MultiLane<[ as Machine>::u64x2; 4]>, - u64x2x4_sse2: Vec4< as Machine>::u64x2>, -{ -} -impl u128x4> for u128x4_sse2 -where - u128x1_sse2: Swap64 + BSwap, - Machine86: Machine, - u128x4_sse2: MultiLane<[ as Machine>::u128x1; 4]>, - u128x4_sse2: Vec4< as Machine>::u128x1>, - u128x4_sse2: Into< as Machine>::u32x4x4>, - u128x4_sse2: Into< as Machine>::u64x2x4>, -{ -} - -impl u64x2x4> for u64x2x4_sse2 -where - u64x2_sse2: RotateEachWord64 + RotateEachWord32 + BSwap, - Avx2Machine: Machine, - u64x2x4_sse2: MultiLane<[ as Machine>::u64x2; 4]>, - u64x2x4_sse2: Vec4< as Machine>::u64x2>, -{ -} -impl u128x4> for u128x4_sse2 -where - u128x1_sse2: Swap64 + BSwap, - Avx2Machine: Machine, - u128x4_sse2: MultiLane<[ as Machine>::u128x1; 4]>, - u128x4_sse2: Vec4< as Machine>::u128x1>, - u128x4_sse2: Into< as Machine>::u32x4x4>, - u128x4_sse2: Into< as Machine>::u64x2x4>, -{ -} - -macro_rules! impl_into_x { - ($from:ident, $to:ident) => { - impl From, Gf>> - for x2<$to, Gt> - { - #[inline(always)] - fn from(x: x2<$from, Gf>) -> Self { - x2::new([$to::from(x.0[0]), $to::from(x.0[1])]) - } - } - impl From>> for x4<$to> { - #[inline(always)] - fn from(x: x4<$from>) -> Self { - x4::new([ - $to::from(x.0[0]), - $to::from(x.0[1]), - $to::from(x.0[2]), - $to::from(x.0[3]), - ]) - } - } - }; -} -impl_into_x!(u128x1_sse2, u64x2_sse2); -impl_into_x!(u128x1_sse2, u32x4_sse2); - -///// Debugging - -use core::fmt::{Debug, Formatter, Result}; - -impl PartialEq for x2 { - #[inline(always)] - fn eq(&self, rhs: &Self) -> bool { - self.0[0] == rhs.0[0] && self.0[1] == rhs.0[1] - } -} - -#[allow(unused)] -#[inline(always)] -unsafe fn eq128_s4(x: __m128i, y: __m128i) -> bool { - let q = _mm_shuffle_epi32(_mm_cmpeq_epi64(x, y), 0b1100_0110); - _mm_cvtsi128_si64(q) == -1 -} - -#[inline(always)] -unsafe fn eq128_s2(x: __m128i, y: __m128i) -> bool { - let q = _mm_cmpeq_epi32(x, y); - let p = _mm_cvtsi128_si64(_mm_srli_si128(q, 8)); - let q = _mm_cvtsi128_si64(q); - (p & q) == -1 -} - -impl PartialEq for u32x4_sse2 { - #[inline(always)] - fn eq(&self, rhs: &Self) -> bool { - unsafe { eq128_s2(self.x, rhs.x) } - } -} -impl Debug for u32x4_sse2 -where - Self: Copy + MultiLane<[u32; 4]>, -{ - #[cold] - fn fmt(&self, fmt: &mut Formatter) -> Result { - fmt.write_fmt(format_args!("{:08x?}", &self.to_lanes())) - } -} - -impl PartialEq for u64x2_sse2 { - #[inline(always)] - fn eq(&self, rhs: &Self) -> bool { - unsafe { eq128_s2(self.x, rhs.x) } - } -} -impl Debug for u64x2_sse2 -where - Self: Copy + MultiLane<[u64; 2]>, -{ - #[cold] - fn fmt(&self, fmt: &mut Formatter) -> Result { - fmt.write_fmt(format_args!("{:016x?}", &self.to_lanes())) - } -} - -impl Debug for u64x4_sse2 -where - u64x2_sse2: Copy + MultiLane<[u64; 2]>, -{ - #[cold] - fn fmt(&self, fmt: &mut Formatter) -> Result { - let (a, b) = (self.0[0].to_lanes(), self.0[1].to_lanes()); - fmt.write_fmt(format_args!("{:016x?}", &[a[0], a[1], b[0], b[1]])) - } -} - -#[cfg(test)] -#[cfg(target_arch = "x86_64")] -mod test { - use super::*; - use crate::x86_64::{SSE2, SSE41, SSSE3}; - use crate::Machine; - - #[test] - #[cfg_attr(not(target_feature = "ssse3"), ignore)] - fn test_bswap32_s2_vs_s3() { - let xs = [0x0f0e_0d0c, 0x0b0a_0908, 0x0706_0504, 0x0302_0100]; - let ys = [0x0c0d_0e0f, 0x0809_0a0b, 0x0405_0607, 0x0001_0203]; - - let s2 = unsafe { SSE2::instance() }; - let s3 = unsafe { SSSE3::instance() }; - - let x_s2 = { - let x_s2: ::u32x4 = s2.vec(xs); - x_s2.bswap() - }; - - let x_s3 = { - let x_s3: ::u32x4 = s3.vec(xs); - x_s3.bswap() - }; - - assert_eq!(x_s2, unsafe { core::mem::transmute(x_s3) }); - assert_eq!(x_s2, s2.vec(ys)); - } - - #[test] - #[cfg_attr(not(target_feature = "ssse3"), ignore)] - fn test_bswap64_s2_vs_s3() { - let xs = [0x0f0e_0d0c_0b0a_0908, 0x0706_0504_0302_0100]; - let ys = [0x0809_0a0b_0c0d_0e0f, 0x0001_0203_0405_0607]; - - let s2 = unsafe { SSE2::instance() }; - let s3 = unsafe { SSSE3::instance() }; - - let x_s2 = { - let x_s2: ::u64x2 = s2.vec(xs); - x_s2.bswap() - }; - - let x_s3 = { - let x_s3: ::u64x2 = s3.vec(xs); - x_s3.bswap() - }; - - assert_eq!(x_s2, s2.vec(ys)); - assert_eq!(x_s3, unsafe { core::mem::transmute(x_s3) }); - } - - #[test] - #[cfg_attr(not(target_feature = "ssse3"), ignore)] - fn test_shuffle32_s2_vs_s3() { - let xs = [0x0, 0x1, 0x2, 0x3]; - let ys = [0x2, 0x3, 0x0, 0x1]; - let zs = [0x1, 0x2, 0x3, 0x0]; - - let s2 = unsafe { SSE2::instance() }; - let s3 = unsafe { SSSE3::instance() }; - - let x_s2 = { - let x_s2: ::u32x4 = s2.vec(xs); - x_s2.shuffle2301() - }; - let x_s3 = { - let x_s3: ::u32x4 = s3.vec(xs); - x_s3.shuffle2301() - }; - assert_eq!(x_s2, s2.vec(ys)); - assert_eq!(x_s3, unsafe { core::mem::transmute(x_s3) }); - - let x_s2 = { - let x_s2: ::u32x4 = s2.vec(xs); - x_s2.shuffle3012() - }; - let x_s3 = { - let x_s3: ::u32x4 = s3.vec(xs); - x_s3.shuffle3012() - }; - assert_eq!(x_s2, s2.vec(zs)); - assert_eq!(x_s3, unsafe { core::mem::transmute(x_s3) }); - - let x_s2 = x_s2.shuffle1230(); - let x_s3 = x_s3.shuffle1230(); - assert_eq!(x_s2, s2.vec(xs)); - assert_eq!(x_s3, unsafe { core::mem::transmute(x_s3) }); - } - - #[test] - #[cfg_attr(not(target_feature = "ssse3"), ignore)] - fn test_shuffle64_s2_vs_s3() { - let xs = [0x0, 0x1, 0x2, 0x3]; - let ys = [0x2, 0x3, 0x0, 0x1]; - let zs = [0x1, 0x2, 0x3, 0x0]; - - let s2 = unsafe { SSE2::instance() }; - let s3 = unsafe { SSSE3::instance() }; - - let x_s2 = { - let x_s2: ::u64x4 = s2.vec(xs); - x_s2.shuffle2301() - }; - let x_s3 = { - let x_s3: ::u64x4 = s3.vec(xs); - x_s3.shuffle2301() - }; - assert_eq!(x_s2, s2.vec(ys)); - assert_eq!(x_s3, unsafe { core::mem::transmute(x_s3) }); - - let x_s2 = { - let x_s2: ::u64x4 = s2.vec(xs); - x_s2.shuffle3012() - }; - let x_s3 = { - let x_s3: ::u64x4 = s3.vec(xs); - x_s3.shuffle3012() - }; - assert_eq!(x_s2, s2.vec(zs)); - assert_eq!(x_s3, unsafe { core::mem::transmute(x_s3) }); - - let x_s2 = x_s2.shuffle1230(); - let x_s3 = x_s3.shuffle1230(); - assert_eq!(x_s2, s2.vec(xs)); - assert_eq!(x_s3, unsafe { core::mem::transmute(x_s3) }); - } - - #[cfg_attr(not(all(target_feature = "ssse3", target_feature = "sse4.1")), ignore)] - #[test] - fn test_lanes_u32x4() { - let xs = [0x1, 0x2, 0x3, 0x4]; - - let s2 = unsafe { SSE2::instance() }; - let s3 = unsafe { SSSE3::instance() }; - let s4 = unsafe { SSE41::instance() }; - - { - let x_s2: ::u32x4 = s2.vec(xs); - let y_s2 = ::u32x4::from_lanes(xs); - assert_eq!(x_s2, y_s2); - assert_eq!(xs, y_s2.to_lanes()); - } - - { - let x_s3: ::u32x4 = s3.vec(xs); - let y_s3 = ::u32x4::from_lanes(xs); - assert_eq!(x_s3, y_s3); - assert_eq!(xs, y_s3.to_lanes()); - } - - { - let x_s4: ::u32x4 = s4.vec(xs); - let y_s4 = ::u32x4::from_lanes(xs); - assert_eq!(x_s4, y_s4); - assert_eq!(xs, y_s4.to_lanes()); - } - } - - #[test] - #[cfg_attr(not(all(target_feature = "ssse3", target_feature = "sse4.1")), ignore)] - fn test_lanes_u64x2() { - let xs = [0x1, 0x2]; - - let s2 = unsafe { SSE2::instance() }; - let s3 = unsafe { SSSE3::instance() }; - let s4 = unsafe { SSE41::instance() }; - - { - let x_s2: ::u64x2 = s2.vec(xs); - let y_s2 = ::u64x2::from_lanes(xs); - assert_eq!(x_s2, y_s2); - assert_eq!(xs, y_s2.to_lanes()); - } - - { - let x_s3: ::u64x2 = s3.vec(xs); - let y_s3 = ::u64x2::from_lanes(xs); - assert_eq!(x_s3, y_s3); - assert_eq!(xs, y_s3.to_lanes()); - } - - { - let x_s4: ::u64x2 = s4.vec(xs); - let y_s4 = ::u64x2::from_lanes(xs); - assert_eq!(x_s4, y_s4); - assert_eq!(xs, y_s4.to_lanes()); - } - } - - #[test] - fn test_vec4_u32x4_s2() { - let xs = [1, 2, 3, 4]; - let s2 = unsafe { SSE2::instance() }; - let x_s2: ::u32x4 = s2.vec(xs); - assert_eq!(x_s2.extract(0), 1); - assert_eq!(x_s2.extract(1), 2); - assert_eq!(x_s2.extract(2), 3); - assert_eq!(x_s2.extract(3), 4); - assert_eq!(x_s2.insert(0xf, 0), s2.vec([0xf, 2, 3, 4])); - assert_eq!(x_s2.insert(0xf, 1), s2.vec([1, 0xf, 3, 4])); - assert_eq!(x_s2.insert(0xf, 2), s2.vec([1, 2, 0xf, 4])); - assert_eq!(x_s2.insert(0xf, 3), s2.vec([1, 2, 3, 0xf])); - } - - #[test] - #[cfg_attr(not(all(target_feature = "ssse3", target_feature = "sse4.1")), ignore)] - fn test_vec4_u32x4_s4() { - let xs = [1, 2, 3, 4]; - let s4 = unsafe { SSE41::instance() }; - let x_s4: ::u32x4 = s4.vec(xs); - assert_eq!(x_s4.extract(0), 1); - assert_eq!(x_s4.extract(1), 2); - assert_eq!(x_s4.extract(2), 3); - assert_eq!(x_s4.extract(3), 4); - assert_eq!(x_s4.insert(0xf, 0), s4.vec([0xf, 2, 3, 4])); - assert_eq!(x_s4.insert(0xf, 1), s4.vec([1, 0xf, 3, 4])); - assert_eq!(x_s4.insert(0xf, 2), s4.vec([1, 2, 0xf, 4])); - assert_eq!(x_s4.insert(0xf, 3), s4.vec([1, 2, 3, 0xf])); - } - - #[test] - fn test_vec2_u64x2_s2() { - let xs = [0x1, 0x2]; - let s2 = unsafe { SSE2::instance() }; - let x_s2: ::u64x2 = s2.vec(xs); - assert_eq!(x_s2.extract(0), 1); - assert_eq!(x_s2.extract(1), 2); - assert_eq!(x_s2.insert(0xf, 0), s2.vec([0xf, 2])); - assert_eq!(x_s2.insert(0xf, 1), s2.vec([1, 0xf])); - } - - #[test] - #[cfg_attr(not(all(target_feature = "ssse3", target_feature = "sse4.1")), ignore)] - fn test_vec4_u64x2_s4() { - let xs = [0x1, 0x2]; - let s4 = unsafe { SSE41::instance() }; - let x_s4: ::u64x2 = s4.vec(xs); - assert_eq!(x_s4.extract(0), 1); - assert_eq!(x_s4.extract(1), 2); - assert_eq!(x_s4.insert(0xf, 0), s4.vec([0xf, 2])); - assert_eq!(x_s4.insert(0xf, 1), s4.vec([1, 0xf])); - } -} - -pub mod avx2 { - #![allow(non_camel_case_types)] - use crate::soft::{x2, x4}; - use crate::types::*; - use crate::x86_64::sse2::{u128x1_sse2, u32x4_sse2, G0}; - use crate::x86_64::{vec256_storage, vec512_storage, Avx2Machine, YesS3, YesS4}; - use core::arch::x86_64::*; - use core::marker::PhantomData; - use core::ops::*; - - #[derive(Copy, Clone)] - pub struct u32x4x2_avx2 { - x: __m256i, - ni: PhantomData, - } - - impl u32x4x2_avx2 { - #[inline(always)] - fn new(x: __m256i) -> Self { - Self { x, ni: PhantomData } - } - } - - impl u32x4x2> for u32x4x2_avx2 where NI: Copy {} - impl Store for u32x4x2_avx2 { - #[inline(always)] - unsafe fn unpack(p: vec256_storage) -> Self { - Self::new(p.avx) - } - } - impl StoreBytes for u32x4x2_avx2 { - #[inline(always)] - unsafe fn unsafe_read_le(input: &[u8]) -> Self { - assert_eq!(input.len(), 32); - Self::new(_mm256_loadu_si256(input.as_ptr() as *const _)) - } - #[inline(always)] - unsafe fn unsafe_read_be(input: &[u8]) -> Self { - Self::unsafe_read_le(input).bswap() - } - #[inline(always)] - fn write_le(self, out: &mut [u8]) { - unsafe { - assert_eq!(out.len(), 32); - _mm256_storeu_si256(out.as_mut_ptr() as *mut _, self.x) - } - } - #[inline(always)] - fn write_be(self, out: &mut [u8]) { - self.bswap().write_le(out) - } - } - impl MultiLane<[u32x4_sse2; 2]> for u32x4x2_avx2 { - #[inline(always)] - fn to_lanes(self) -> [u32x4_sse2; 2] { - unsafe { - [ - u32x4_sse2::new(_mm256_extracti128_si256(self.x, 0)), - u32x4_sse2::new(_mm256_extracti128_si256(self.x, 1)), - ] - } - } - #[inline(always)] - fn from_lanes(x: [u32x4_sse2; 2]) -> Self { - Self::new(unsafe { _mm256_setr_m128i(x[0].x, x[1].x) }) - } - } - impl Vec2> for u32x4x2_avx2 { - #[inline(always)] - fn extract(self, i: u32) -> u32x4_sse2 { - unsafe { - match i { - 0 => u32x4_sse2::new(_mm256_extracti128_si256(self.x, 0)), - 1 => u32x4_sse2::new(_mm256_extracti128_si256(self.x, 1)), - _ => panic!(), - } - } - } - #[inline(always)] - fn insert(self, w: u32x4_sse2, i: u32) -> Self { - Self::new(unsafe { - match i { - 0 => _mm256_inserti128_si256(self.x, w.x, 0), - 1 => _mm256_inserti128_si256(self.x, w.x, 1), - _ => panic!(), - } - }) - } - } - impl BitOps32 for u32x4x2_avx2 where NI: Copy {} - impl ArithOps for u32x4x2_avx2 where NI: Copy {} - macro_rules! shuf_lane_bytes { - ($name:ident, $k0:expr, $k1:expr) => { - #[inline(always)] - fn $name(self) -> Self { - Self::new(unsafe { - _mm256_shuffle_epi8(self.x, _mm256_set_epi64x($k0, $k1, $k0, $k1)) - }) - } - }; - } - macro_rules! rotr_32 { - ($name:ident, $i:expr) => { - #[inline(always)] - fn $name(self) -> Self { - Self::new(unsafe { - _mm256_or_si256( - _mm256_srli_epi32(self.x, $i as i32), - _mm256_slli_epi32(self.x, 32 - $i as i32), - ) - }) - } - }; - } - impl RotateEachWord32 for u32x4x2_avx2 { - rotr_32!(rotate_each_word_right7, 7); - shuf_lane_bytes!( - rotate_each_word_right8, - 0x0c0f_0e0d_080b_0a09, - 0x0407_0605_0003_0201 - ); - rotr_32!(rotate_each_word_right11, 11); - rotr_32!(rotate_each_word_right12, 12); - shuf_lane_bytes!( - rotate_each_word_right16, - 0x0d0c_0f0e_0908_0b0a, - 0x0504_0706_0100_0302 - ); - rotr_32!(rotate_each_word_right20, 20); - shuf_lane_bytes!( - rotate_each_word_right24, - 0x0e0d_0c0f_0a09_080b, - 0x0605_0407_0201_0003 - ); - rotr_32!(rotate_each_word_right25, 25); - } - impl BitOps0 for u32x4x2_avx2 where NI: Copy {} - impl From> for vec256_storage { - #[inline(always)] - fn from(x: u32x4x2_avx2) -> Self { - Self { avx: x.x } - } - } - - macro_rules! impl_assign { - ($vec:ident, $Assign:ident, $assign_fn:ident, $bin_fn:ident) => { - impl $Assign for $vec - where - NI: Copy, - { - #[inline(always)] - fn $assign_fn(&mut self, rhs: Self) { - *self = self.$bin_fn(rhs); - } - } - }; - } - impl_assign!(u32x4x2_avx2, BitXorAssign, bitxor_assign, bitxor); - impl_assign!(u32x4x2_avx2, BitOrAssign, bitor_assign, bitor); - impl_assign!(u32x4x2_avx2, BitAndAssign, bitand_assign, bitand); - impl_assign!(u32x4x2_avx2, AddAssign, add_assign, add); - - macro_rules! impl_bitop { - ($vec:ident, $Op:ident, $op_fn:ident, $impl_fn:ident) => { - impl $Op for $vec { - type Output = Self; - #[inline(always)] - fn $op_fn(self, rhs: Self) -> Self::Output { - Self::new(unsafe { $impl_fn(self.x, rhs.x) }) - } - } - }; - } - impl_bitop!(u32x4x2_avx2, BitXor, bitxor, _mm256_xor_si256); - impl_bitop!(u32x4x2_avx2, BitOr, bitor, _mm256_or_si256); - impl_bitop!(u32x4x2_avx2, BitAnd, bitand, _mm256_and_si256); - impl_bitop!(u32x4x2_avx2, AndNot, andnot, _mm256_andnot_si256); - impl_bitop!(u32x4x2_avx2, Add, add, _mm256_add_epi32); - - impl Not for u32x4x2_avx2 { - type Output = Self; - #[inline(always)] - fn not(self) -> Self::Output { - unsafe { - let f = _mm256_set1_epi8(-0x7f); - Self::new(f) ^ self - } - } - } - - impl BSwap for u32x4x2_avx2 { - shuf_lane_bytes!(bswap, 0x0c0d_0e0f_0809_0a0b, 0x0405_0607_0001_0203); - } - - impl From, G0>> for u32x4x2_avx2 - where - NI: Copy, - { - #[inline(always)] - fn from(x: x2, G0>) -> Self { - Self::new(unsafe { _mm256_setr_m128i(x.0[0].x, x.0[1].x) }) - } - } - - impl LaneWords4 for u32x4x2_avx2 { - #[inline(always)] - fn shuffle_lane_words1230(self) -> Self { - Self::new(unsafe { _mm256_shuffle_epi32(self.x, 0b1001_0011) }) - } - #[inline(always)] - fn shuffle_lane_words2301(self) -> Self { - Self::new(unsafe { _mm256_shuffle_epi32(self.x, 0b0100_1110) }) - } - #[inline(always)] - fn shuffle_lane_words3012(self) -> Self { - Self::new(unsafe { _mm256_shuffle_epi32(self.x, 0b0011_1001) }) - } - } - - /////////////////////////////////////////////////////////////////////////////////////////// - - pub type u32x4x4_avx2 = x2, G0>; - impl u32x4x4> for u32x4x4_avx2 {} - - impl Store for u32x4x4_avx2 { - #[inline(always)] - unsafe fn unpack(p: vec512_storage) -> Self { - Self::new([ - u32x4x2_avx2::unpack(p.avx[0]), - u32x4x2_avx2::unpack(p.avx[1]), - ]) - } - } - impl MultiLane<[u32x4_sse2; 4]> for u32x4x4_avx2 { - #[inline(always)] - fn to_lanes(self) -> [u32x4_sse2; 4] { - let [a, b] = self.0[0].to_lanes(); - let [c, d] = self.0[1].to_lanes(); - [a, b, c, d] - } - #[inline(always)] - fn from_lanes(x: [u32x4_sse2; 4]) -> Self { - let ab = u32x4x2_avx2::from_lanes([x[0], x[1]]); - let cd = u32x4x2_avx2::from_lanes([x[2], x[3]]); - Self::new([ab, cd]) - } - } - impl Vec4> for u32x4x4_avx2 { - #[inline(always)] - fn extract(self, i: u32) -> u32x4_sse2 { - match i { - 0 => self.0[0].extract(0), - 1 => self.0[0].extract(1), - 2 => self.0[1].extract(0), - 3 => self.0[1].extract(1), - _ => panic!(), - } - } - #[inline(always)] - fn insert(self, w: u32x4_sse2, i: u32) -> Self { - Self::new(match i { - 0 | 1 => [self.0[0].insert(w, i), self.0[1]], - 2 | 3 => [self.0[0], self.0[1].insert(w, i - 2)], - _ => panic!(), - }) - } - } - impl Vec4Ext> for u32x4x4_avx2 { - #[inline(always)] - fn transpose4(a: Self, b: Self, c: Self, d: Self) -> (Self, Self, Self, Self) { - /* - * a00:a01 a10:a11 - * b00:b01 b10:b11 - * c00:c01 c10:c11 - * d00:d01 d10:d11 - * => - * a00:b00 c00:d00 - * a01:b01 c01:d01 - * a10:b10 c10:d10 - * a11:b11 c11:d11 - */ - unsafe { - let ab00 = u32x4x2_avx2::new(_mm256_permute2x128_si256(a.0[0].x, b.0[0].x, 0x20)); - let ab01 = u32x4x2_avx2::new(_mm256_permute2x128_si256(a.0[0].x, b.0[0].x, 0x31)); - let ab10 = u32x4x2_avx2::new(_mm256_permute2x128_si256(a.0[1].x, b.0[1].x, 0x20)); - let ab11 = u32x4x2_avx2::new(_mm256_permute2x128_si256(a.0[1].x, b.0[1].x, 0x31)); - let cd00 = u32x4x2_avx2::new(_mm256_permute2x128_si256(c.0[0].x, d.0[0].x, 0x20)); - let cd01 = u32x4x2_avx2::new(_mm256_permute2x128_si256(c.0[0].x, d.0[0].x, 0x31)); - let cd10 = u32x4x2_avx2::new(_mm256_permute2x128_si256(c.0[1].x, d.0[1].x, 0x20)); - let cd11 = u32x4x2_avx2::new(_mm256_permute2x128_si256(c.0[1].x, d.0[1].x, 0x31)); - ( - Self::new([ab00, cd00]), - Self::new([ab01, cd01]), - Self::new([ab10, cd10]), - Self::new([ab11, cd11]), - ) - } - } - } - impl Vector<[u32; 16]> for u32x4x4_avx2 { - #[inline(always)] - fn to_scalars(self) -> [u32; 16] { - unsafe { core::mem::transmute(self) } - } - } - impl From> for vec512_storage { - #[inline(always)] - fn from(x: u32x4x4_avx2) -> Self { - Self { - avx: [ - vec256_storage { avx: x.0[0].x }, - vec256_storage { avx: x.0[1].x }, - ], - } - } - } - impl From>> for u32x4x4_avx2 { - #[inline(always)] - fn from(x: x4>) -> Self { - Self::new(unsafe { - [ - u32x4x2_avx2::new(_mm256_setr_m128i(x.0[0].x, x.0[1].x)), - u32x4x2_avx2::new(_mm256_setr_m128i(x.0[2].x, x.0[3].x)), - ] - }) - } - } -} diff -Nru cargo-0.58.0/vendor/proc-macro2/build.rs cargo-0.60.0ubuntu1/vendor/proc-macro2/build.rs --- cargo-0.58.0/vendor/proc-macro2/build.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/proc-macro2/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -41,7 +41,6 @@ // 1.57+. use std::env; -use std::iter; use std::process::{self, Command}; use std::str; @@ -154,23 +153,13 @@ let flags_var; let flags_var_string; - let mut flags_var_split; - let mut flags_none; - let flags: &mut dyn Iterator = - if let Some(encoded_rustflags) = env::var_os("CARGO_ENCODED_RUSTFLAGS") { - flags_var = encoded_rustflags; - flags_var_string = flags_var.to_string_lossy(); - flags_var_split = flags_var_string.split('\x1f'); - &mut flags_var_split - } else if let Some(rustflags) = env::var_os("RUSTFLAGS") { - flags_var = rustflags; - flags_var_string = flags_var.to_string_lossy(); - flags_var_split = flags_var_string.split(' '); - &mut flags_var_split - } else { - flags_none = iter::empty(); - &mut flags_none - }; + let flags = if let Some(encoded_rustflags) = env::var_os("CARGO_ENCODED_RUSTFLAGS") { + flags_var = encoded_rustflags; + flags_var_string = flags_var.to_string_lossy(); + flags_var_string.split('\x1f') + } else { + return true; + }; for mut flag in flags { if flag.starts_with("-Z") { diff -Nru cargo-0.58.0/vendor/proc-macro2/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/proc-macro2/.cargo-checksum.json --- cargo-0.58.0/vendor/proc-macro2/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/proc-macro2/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"} \ No newline at end of file +{"files":{},"package":"ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/proc-macro2/Cargo.toml cargo-0.60.0ubuntu1/vendor/proc-macro2/Cargo.toml --- cargo-0.58.0/vendor/proc-macro2/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/proc-macro2/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -13,25 +13,42 @@ edition = "2018" rust-version = "1.31" name = "proc-macro2" -version = "1.0.36" -authors = ["David Tolnay ", "Alex Crichton "] +version = "1.0.37" +authors = [ + "David Tolnay ", + "Alex Crichton ", +] autobenches = false -description = "A substitute implementation of the compiler's `proc_macro` API to decouple\ntoken-based libraries from the procedural macro use case.\n" +description = """ +A substitute implementation of the compiler's `proc_macro` API to decouple +token-based libraries from the procedural macro use case. +""" documentation = "https://docs.rs/proc-macro2" readme = "README.md" keywords = ["macros"] categories = ["development-tools::procedural-macro-helpers"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/proc-macro2" + [package.metadata.docs.rs] -rustc-args = ["--cfg", "procmacro2_semver_exempt"] -rustdoc-args = ["--cfg", "procmacro2_semver_exempt", "--cfg", "doc_cfg"] +rustc-args = [ + "--cfg", + "procmacro2_semver_exempt", +] +rustdoc-args = [ + "--cfg", + "procmacro2_semver_exempt", + "--cfg", + "doc_cfg", +] targets = ["x86_64-unknown-linux-gnu"] [package.metadata.playground] features = ["span-locations"] + [dependencies.unicode-xid] -version = "0.2" +version = "0.2.2" + [dev-dependencies.quote] version = "1.0" default_features = false diff -Nru cargo-0.58.0/vendor/proc-macro2/src/fallback.rs cargo-0.60.0ubuntu1/vendor/proc-macro2/src/fallback.rs --- cargo-0.58.0/vendor/proc-macro2/src/fallback.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/proc-macro2/src/fallback.rs 2022-04-20 13:48:09.000000000 +0000 @@ -666,18 +666,11 @@ } pub(crate) fn is_ident_start(c: char) -> bool { - ('a' <= c && c <= 'z') - || ('A' <= c && c <= 'Z') - || c == '_' - || (c > '\x7f' && UnicodeXID::is_xid_start(c)) + c == '_' || UnicodeXID::is_xid_start(c) } pub(crate) fn is_ident_continue(c: char) -> bool { - ('a' <= c && c <= 'z') - || ('A' <= c && c <= 'Z') - || c == '_' - || ('0' <= c && c <= '9') - || (c > '\x7f' && UnicodeXID::is_xid_continue(c)) + UnicodeXID::is_xid_continue(c) } fn validate_ident(string: &str) { diff -Nru cargo-0.58.0/vendor/proc-macro2/src/lib.rs cargo-0.60.0ubuntu1/vendor/proc-macro2/src/lib.rs --- cargo-0.58.0/vendor/proc-macro2/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/proc-macro2/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -86,7 +86,7 @@ //! a different thread. // Proc-macro2 types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.36")] +#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.37")] #![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))] #![cfg_attr(super_unstable, feature(proc_macro_def_site))] #![cfg_attr(doc_cfg, feature(doc_cfg))] diff -Nru cargo-0.58.0/vendor/quote/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/quote/.cargo-checksum.json --- cargo-0.58.0/vendor/quote/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/quote/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"} \ No newline at end of file +{"files":{},"package":"a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/quote/Cargo.toml cargo-0.60.0ubuntu1/vendor/quote/Cargo.toml --- cargo-0.58.0/vendor/quote/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/quote/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -13,7 +13,7 @@ edition = "2018" rust-version = "1.31" name = "quote" -version = "1.0.14" +version = "1.0.18" authors = ["David Tolnay "] autobenches = false description = "Quasi-quoting macro quote!(...)" @@ -23,11 +23,14 @@ categories = ["development-tools::procedural-macro-helpers"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/quote" + [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] + [dependencies.proc-macro2] version = "1.0.36" default-features = false + [dev-dependencies.rustversion] version = "1.0" diff -Nru cargo-0.58.0/vendor/quote/src/lib.rs cargo-0.60.0ubuntu1/vendor/quote/src/lib.rs --- cargo-0.58.0/vendor/quote/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/quote/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -81,7 +81,7 @@ //! ``` // Quote types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/quote/1.0.14")] +#![doc(html_root_url = "https://docs.rs/quote/1.0.18")] #![allow( clippy::doc_markdown, clippy::missing_errors_doc, @@ -389,14 +389,6 @@ /// } /// ``` /// -/// Macro calls in a doc attribute are not valid syntax: -/// -/// ```compile_fail -/// quote! { -/// #[doc = concat!("try to interpolate: ", stringify!(#ident))] -/// } -/// ``` -/// /// Instead the best way to build doc comments that involve variables is by /// formatting the doc string literal outside of quote. /// @@ -476,11 +468,42 @@ /// # } /// # } /// ``` +#[cfg(doc)] +#[macro_export] +macro_rules! quote { + ($($tt:tt)*) => { + ... + }; +} + +#[cfg(not(doc))] #[macro_export] macro_rules! quote { () => { $crate::__private::TokenStream::new() }; + + // Special case rule for a single tt, for performance. + ($tt:tt) => {{ + let mut _s = $crate::__private::TokenStream::new(); + $crate::quote_token!($tt _s); + _s + }}; + + // Special case rules for two tts, for performance. + (# $var:ident) => {{ + let mut _s = $crate::__private::TokenStream::new(); + $crate::ToTokens::to_tokens(&$var, &mut _s); + _s + }}; + ($tt1:tt $tt2:tt) => {{ + let mut _s = $crate::__private::TokenStream::new(); + $crate::quote_token!($tt1 _s); + $crate::quote_token!($tt2 _s); + _s + }}; + + // Rule for any other number of tokens. ($($tt:tt)*) => {{ let mut _s = $crate::__private::TokenStream::new(); $crate::quote_each_token!(_s $($tt)*); @@ -584,12 +607,46 @@ /// In this example it is important for the where-clause to be spanned with the /// line/column information of the user's input type so that error messages are /// placed appropriately by the compiler. +#[cfg(doc)] +#[macro_export] +macro_rules! quote_spanned { + ($span:expr=> $($tt:tt)*) => { + ... + }; +} + +#[cfg(not(doc))] #[macro_export] macro_rules! quote_spanned { ($span:expr=>) => {{ let _: $crate::__private::Span = $span; $crate::__private::TokenStream::new() }}; + + // Special case rule for a single tt, for performance. + ($span:expr=> $tt:tt) => {{ + let mut _s = $crate::__private::TokenStream::new(); + let _span: $crate::__private::Span = $span; + $crate::quote_token_spanned!($tt _s _span); + _s + }}; + + // Special case rules for two tts, for performance. + ($span:expr=> # $var:ident) => {{ + let mut _s = $crate::__private::TokenStream::new(); + let _: $crate::__private::Span = $span; + $crate::ToTokens::to_tokens(&$var, &mut _s); + _s + }}; + ($span:expr=> $tt1:tt $tt2:tt) => {{ + let mut _s = $crate::__private::TokenStream::new(); + let _span: $crate::__private::Span = $span; + $crate::quote_token_spanned!($tt1 _s _span); + $crate::quote_token_spanned!($tt2 _s _span); + _s + }}; + + // Rule for any other number of tokens. ($span:expr=> $($tt:tt)*) => {{ let mut _s = $crate::__private::TokenStream::new(); let _span: $crate::__private::Span = $span; @@ -669,6 +726,74 @@ }; } +// The obvious way to write this macro is as a tt muncher. This implementation +// does something more complex for two reasons. +// +// - With a tt muncher it's easy to hit Rust's built-in recursion_limit, which +// this implementation avoids because it isn't tail recursive. +// +// - Compile times for a tt muncher are quadratic relative to the length of +// the input. This implementation is linear, so it will be faster +// (potentially much faster) for big inputs. However, the constant factors +// of this implementation are higher than that of a tt muncher, so it is +// somewhat slower than a tt muncher if there are many invocations with +// short inputs. +// +// An invocation like this: +// +// quote_each_token!(_s a b c d e f g h i j); +// +// expands to this: +// +// quote_tokens_with_context!(_s +// (@ @ @ @ @ @ a b c d e f g h i j) +// (@ @ @ @ @ a b c d e f g h i j @) +// (@ @ @ @ a b c d e f g h i j @ @) +// (@ @ @ (a) (b) (c) (d) (e) (f) (g) (h) (i) (j) @ @ @) +// (@ @ a b c d e f g h i j @ @ @ @) +// (@ a b c d e f g h i j @ @ @ @ @) +// (a b c d e f g h i j @ @ @ @ @ @) +// ); +// +// which gets transposed and expanded to this: +// +// quote_token_with_context!(_s @ @ @ @ @ @ a); +// quote_token_with_context!(_s @ @ @ @ @ a b); +// quote_token_with_context!(_s @ @ @ @ a b c); +// quote_token_with_context!(_s @ @ @ (a) b c d); +// quote_token_with_context!(_s @ @ a (b) c d e); +// quote_token_with_context!(_s @ a b (c) d e f); +// quote_token_with_context!(_s a b c (d) e f g); +// quote_token_with_context!(_s b c d (e) f g h); +// quote_token_with_context!(_s c d e (f) g h i); +// quote_token_with_context!(_s d e f (g) h i j); +// quote_token_with_context!(_s e f g (h) i j @); +// quote_token_with_context!(_s f g h (i) j @ @); +// quote_token_with_context!(_s g h i (j) @ @ @); +// quote_token_with_context!(_s h i j @ @ @ @); +// quote_token_with_context!(_s i j @ @ @ @ @); +// quote_token_with_context!(_s j @ @ @ @ @ @); +// +// Without having used muncher-style recursion, we get one invocation of +// quote_token_with_context for each original tt, with three tts of context on +// either side. This is enough for the longest possible interpolation form (a +// repetition with separator, as in `# (#var) , *`) to be fully represented with +// the first or last tt in the middle. +// +// The middle tt (surrounded by parentheses) is the tt being processed. +// +// - When it is a `#`, quote_token_with_context can do an interpolation. The +// interpolation kind will depend on the three subsequent tts. +// +// - When it is within a later part of an interpolation, it can be ignored +// because the interpolation has already been done. +// +// - When it is not part of an interpolation it can be pushed as a single +// token into the output. +// +// - When the middle token is an unparenthesized `@`, that call is one of the +// first 3 or last 3 calls of quote_token_with_context and does not +// correspond to one of the original input tokens, so turns into nothing. #[macro_export] #[doc(hidden)] macro_rules! quote_each_token { @@ -685,6 +810,7 @@ }; } +// See the explanation on quote_each_token. #[macro_export] #[doc(hidden)] macro_rules! quote_each_token_spanned { @@ -701,6 +827,7 @@ }; } +// See the explanation on quote_each_token. #[macro_export] #[doc(hidden)] macro_rules! quote_tokens_with_context { @@ -715,6 +842,7 @@ }; } +// See the explanation on quote_each_token. #[macro_export] #[doc(hidden)] macro_rules! quote_tokens_with_context_spanned { @@ -729,11 +857,15 @@ }; } +// See the explanation on quote_each_token. #[macro_export] #[doc(hidden)] macro_rules! quote_token_with_context { + // Unparenthesized `@` indicates this call does not correspond to one of the + // original input tokens. Ignore it. ($tokens:ident $b3:tt $b2:tt $b1:tt @ $a1:tt $a2:tt $a3:tt) => {}; + // A repetition with no separator. ($tokens:ident $b3:tt $b2:tt $b1:tt (#) ( $($inner:tt)* ) * $a3:tt) => {{ use $crate::__private::ext::*; let has_iter = $crate::__private::ThereIsNoIteratorInRepetition; @@ -745,55 +877,60 @@ // warnings on anything below the loop. We use has_iter to detect and // fail to compile when there are no iterators, so here we just work // around the unneeded extra warning. - // - // FIXME: temporariliy working around Clippy regression. - // https://github.com/rust-lang/rust-clippy/issues/7768 - loop { + while true { $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*); $crate::quote_each_token!($tokens $($inner)*); - if false { - break; - } } }}; + // ... and one step later. ($tokens:ident $b3:tt $b2:tt # (( $($inner:tt)* )) * $a2:tt $a3:tt) => {}; + // ... and one step later. ($tokens:ident $b3:tt # ( $($inner:tt)* ) (*) $a1:tt $a2:tt $a3:tt) => {}; + // A repetition with separator. ($tokens:ident $b3:tt $b2:tt $b1:tt (#) ( $($inner:tt)* ) $sep:tt *) => {{ use $crate::__private::ext::*; let mut _i = 0usize; let has_iter = $crate::__private::ThereIsNoIteratorInRepetition; $crate::pounded_var_names!(quote_bind_into_iter!(has_iter) () $($inner)*); let _: $crate::__private::HasIterator = has_iter; - loop { + while true { $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*); if _i > 0 { - $crate::quote_token!($tokens $sep); + $crate::quote_token!($sep $tokens); } _i += 1; $crate::quote_each_token!($tokens $($inner)*); - if false { - break; - } } }}; + // ... and one step later. ($tokens:ident $b3:tt $b2:tt # (( $($inner:tt)* )) $sep:tt * $a3:tt) => {}; + // ... and one step later. ($tokens:ident $b3:tt # ( $($inner:tt)* ) ($sep:tt) * $a2:tt $a3:tt) => {}; + // (A special case for `#(var)**`, where the first `*` is treated as the + // repetition symbol and the second `*` is treated as an ordinary token.) ($tokens:ident # ( $($inner:tt)* ) * (*) $a1:tt $a2:tt $a3:tt) => { // https://github.com/dtolnay/quote/issues/130 - $crate::quote_token!($tokens *); + $crate::quote_token!(* $tokens); }; + // ... and one step later. ($tokens:ident # ( $($inner:tt)* ) $sep:tt (*) $a1:tt $a2:tt $a3:tt) => {}; + // A non-repetition interpolation. ($tokens:ident $b3:tt $b2:tt $b1:tt (#) $var:ident $a2:tt $a3:tt) => { $crate::ToTokens::to_tokens(&$var, &mut $tokens); }; + // ... and one step later. ($tokens:ident $b3:tt $b2:tt # ($var:ident) $a1:tt $a2:tt $a3:tt) => {}; + + // An ordinary token, not part of any interpolation. ($tokens:ident $b3:tt $b2:tt $b1:tt ($curr:tt) $a1:tt $a2:tt $a3:tt) => { - $crate::quote_token!($tokens $curr); + $crate::quote_token!($curr $tokens); }; } +// See the explanation on quote_each_token, and on the individual rules of +// quote_token_with_context. #[macro_export] #[doc(hidden)] macro_rules! quote_token_with_context_spanned { @@ -804,21 +941,9 @@ let has_iter = $crate::__private::ThereIsNoIteratorInRepetition; $crate::pounded_var_names!(quote_bind_into_iter!(has_iter) () $($inner)*); let _: $crate::__private::HasIterator = has_iter; - // This is `while true` instead of `loop` because if there are no - // iterators used inside of this repetition then the body would not - // contain any `break`, so the compiler would emit unreachable code - // warnings on anything below the loop. We use has_iter to detect and - // fail to compile when there are no iterators, so here we just work - // around the unneeded extra warning. - // - // FIXME: temporariliy working around Clippy regression. - // https://github.com/rust-lang/rust-clippy/issues/7768 - loop { + while true { $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*); $crate::quote_each_token_spanned!($tokens $span $($inner)*); - if false { - break; - } } }}; ($tokens:ident $span:ident $b3:tt $b2:tt # (( $($inner:tt)* )) * $a2:tt $a3:tt) => {}; @@ -830,23 +955,20 @@ let has_iter = $crate::__private::ThereIsNoIteratorInRepetition; $crate::pounded_var_names!(quote_bind_into_iter!(has_iter) () $($inner)*); let _: $crate::__private::HasIterator = has_iter; - loop { + while true { $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*); if _i > 0 { - $crate::quote_token_spanned!($tokens $span $sep); + $crate::quote_token_spanned!($sep $tokens $span); } _i += 1; $crate::quote_each_token_spanned!($tokens $span $($inner)*); - if false { - break; - } } }}; ($tokens:ident $span:ident $b3:tt $b2:tt # (( $($inner:tt)* )) $sep:tt * $a3:tt) => {}; ($tokens:ident $span:ident $b3:tt # ( $($inner:tt)* ) ($sep:tt) * $a2:tt $a3:tt) => {}; ($tokens:ident $span:ident # ( $($inner:tt)* ) * (*) $a1:tt $a2:tt $a3:tt) => { // https://github.com/dtolnay/quote/issues/130 - $crate::quote_token_spanned!($tokens $span *); + $crate::quote_token_spanned!(* $tokens $span); }; ($tokens:ident $span:ident # ( $($inner:tt)* ) $sep:tt (*) $a1:tt $a2:tt $a3:tt) => {}; @@ -854,15 +976,31 @@ $crate::ToTokens::to_tokens(&$var, &mut $tokens); }; ($tokens:ident $span:ident $b3:tt $b2:tt # ($var:ident) $a1:tt $a2:tt $a3:tt) => {}; + ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt ($curr:tt) $a1:tt $a2:tt $a3:tt) => { - $crate::quote_token_spanned!($tokens $span $curr); + $crate::quote_token_spanned!($curr $tokens $span); }; } +// These rules are ordered by approximate token frequency, at least for the +// first 10 or so, to improve compile times. Having `ident` first is by far the +// most important because it's typically 2-3x more common than the next most +// common token. +// +// Separately, we put the token being matched in the very front so that failing +// rules may fail to match as quickly as possible. #[macro_export] #[doc(hidden)] macro_rules! quote_token { - ($tokens:ident ( $($inner:tt)* )) => { + ($ident:ident $tokens:ident) => { + $crate::__private::push_ident(&mut $tokens, stringify!($ident)); + }; + + (:: $tokens:ident) => { + $crate::__private::push_colon2(&mut $tokens); + }; + + (( $($inner:tt)* ) $tokens:ident) => { $crate::__private::push_group( &mut $tokens, $crate::__private::Delimiter::Parenthesis, @@ -870,7 +1008,7 @@ ); }; - ($tokens:ident [ $($inner:tt)* ]) => { + ([ $($inner:tt)* ] $tokens:ident) => { $crate::__private::push_group( &mut $tokens, $crate::__private::Delimiter::Bracket, @@ -878,7 +1016,7 @@ ); }; - ($tokens:ident { $($inner:tt)* }) => { + ({ $($inner:tt)* } $tokens:ident) => { $crate::__private::push_group( &mut $tokens, $crate::__private::Delimiter::Brace, @@ -886,203 +1024,204 @@ ); }; - ($tokens:ident +) => { + (# $tokens:ident) => { + $crate::__private::push_pound(&mut $tokens); + }; + + (, $tokens:ident) => { + $crate::__private::push_comma(&mut $tokens); + }; + + (. $tokens:ident) => { + $crate::__private::push_dot(&mut $tokens); + }; + + (; $tokens:ident) => { + $crate::__private::push_semi(&mut $tokens); + }; + + (: $tokens:ident) => { + $crate::__private::push_colon(&mut $tokens); + }; + + (+ $tokens:ident) => { $crate::__private::push_add(&mut $tokens); }; - ($tokens:ident +=) => { + (+= $tokens:ident) => { $crate::__private::push_add_eq(&mut $tokens); }; - ($tokens:ident &) => { + (& $tokens:ident) => { $crate::__private::push_and(&mut $tokens); }; - ($tokens:ident &&) => { + (&& $tokens:ident) => { $crate::__private::push_and_and(&mut $tokens); }; - ($tokens:ident &=) => { + (&= $tokens:ident) => { $crate::__private::push_and_eq(&mut $tokens); }; - ($tokens:ident @) => { + (@ $tokens:ident) => { $crate::__private::push_at(&mut $tokens); }; - ($tokens:ident !) => { + (! $tokens:ident) => { $crate::__private::push_bang(&mut $tokens); }; - ($tokens:ident ^) => { + (^ $tokens:ident) => { $crate::__private::push_caret(&mut $tokens); }; - ($tokens:ident ^=) => { + (^= $tokens:ident) => { $crate::__private::push_caret_eq(&mut $tokens); }; - ($tokens:ident :) => { - $crate::__private::push_colon(&mut $tokens); - }; - - ($tokens:ident ::) => { - $crate::__private::push_colon2(&mut $tokens); - }; - - ($tokens:ident ,) => { - $crate::__private::push_comma(&mut $tokens); - }; - - ($tokens:ident /) => { + (/ $tokens:ident) => { $crate::__private::push_div(&mut $tokens); }; - ($tokens:ident /=) => { + (/= $tokens:ident) => { $crate::__private::push_div_eq(&mut $tokens); }; - ($tokens:ident .) => { - $crate::__private::push_dot(&mut $tokens); - }; - - ($tokens:ident ..) => { + (.. $tokens:ident) => { $crate::__private::push_dot2(&mut $tokens); }; - ($tokens:ident ...) => { + (... $tokens:ident) => { $crate::__private::push_dot3(&mut $tokens); }; - ($tokens:ident ..=) => { + (..= $tokens:ident) => { $crate::__private::push_dot_dot_eq(&mut $tokens); }; - ($tokens:ident =) => { + (= $tokens:ident) => { $crate::__private::push_eq(&mut $tokens); }; - ($tokens:ident ==) => { + (== $tokens:ident) => { $crate::__private::push_eq_eq(&mut $tokens); }; - ($tokens:ident >=) => { + (>= $tokens:ident) => { $crate::__private::push_ge(&mut $tokens); }; - ($tokens:ident >) => { + (> $tokens:ident) => { $crate::__private::push_gt(&mut $tokens); }; - ($tokens:ident <=) => { + (<= $tokens:ident) => { $crate::__private::push_le(&mut $tokens); }; - ($tokens:ident <) => { + (< $tokens:ident) => { $crate::__private::push_lt(&mut $tokens); }; - ($tokens:ident *=) => { + (*= $tokens:ident) => { $crate::__private::push_mul_eq(&mut $tokens); }; - ($tokens:ident !=) => { + (!= $tokens:ident) => { $crate::__private::push_ne(&mut $tokens); }; - ($tokens:ident |) => { + (| $tokens:ident) => { $crate::__private::push_or(&mut $tokens); }; - ($tokens:ident |=) => { + (|= $tokens:ident) => { $crate::__private::push_or_eq(&mut $tokens); }; - ($tokens:ident ||) => { + (|| $tokens:ident) => { $crate::__private::push_or_or(&mut $tokens); }; - ($tokens:ident #) => { - $crate::__private::push_pound(&mut $tokens); - }; - - ($tokens:ident ?) => { + (? $tokens:ident) => { $crate::__private::push_question(&mut $tokens); }; - ($tokens:ident ->) => { + (-> $tokens:ident) => { $crate::__private::push_rarrow(&mut $tokens); }; - ($tokens:ident <-) => { + (<- $tokens:ident) => { $crate::__private::push_larrow(&mut $tokens); }; - ($tokens:ident %) => { + (% $tokens:ident) => { $crate::__private::push_rem(&mut $tokens); }; - ($tokens:ident %=) => { + (%= $tokens:ident) => { $crate::__private::push_rem_eq(&mut $tokens); }; - ($tokens:ident =>) => { + (=> $tokens:ident) => { $crate::__private::push_fat_arrow(&mut $tokens); }; - ($tokens:ident ;) => { - $crate::__private::push_semi(&mut $tokens); - }; - - ($tokens:ident <<) => { + (<< $tokens:ident) => { $crate::__private::push_shl(&mut $tokens); }; - ($tokens:ident <<=) => { + (<<= $tokens:ident) => { $crate::__private::push_shl_eq(&mut $tokens); }; - ($tokens:ident >>) => { + (>> $tokens:ident) => { $crate::__private::push_shr(&mut $tokens); }; - ($tokens:ident >>=) => { + (>>= $tokens:ident) => { $crate::__private::push_shr_eq(&mut $tokens); }; - ($tokens:ident *) => { + (* $tokens:ident) => { $crate::__private::push_star(&mut $tokens); }; - ($tokens:ident -) => { + (- $tokens:ident) => { $crate::__private::push_sub(&mut $tokens); }; - ($tokens:ident -=) => { + (-= $tokens:ident) => { $crate::__private::push_sub_eq(&mut $tokens); }; - ($tokens:ident $ident:ident) => { - $crate::__private::push_ident(&mut $tokens, stringify!($ident)); - }; - - ($tokens:ident $lifetime:lifetime) => { + ($lifetime:lifetime $tokens:ident) => { $crate::__private::push_lifetime(&mut $tokens, stringify!($lifetime)); }; - ($tokens:ident _) => { + (_ $tokens:ident) => { $crate::__private::push_underscore(&mut $tokens); }; - ($tokens:ident $other:tt) => { + ($other:tt $tokens:ident) => { $crate::__private::parse(&mut $tokens, stringify!($other)); }; } +// See the comment above `quote_token!` about the rule ordering. #[macro_export] #[doc(hidden)] macro_rules! quote_token_spanned { - ($tokens:ident $span:ident ( $($inner:tt)* )) => { + ($ident:ident $tokens:ident $span:ident) => { + $crate::__private::push_ident_spanned(&mut $tokens, $span, stringify!($ident)); + }; + + (:: $tokens:ident $span:ident) => { + $crate::__private::push_colon2_spanned(&mut $tokens, $span); + }; + + (( $($inner:tt)* ) $tokens:ident $span:ident) => { $crate::__private::push_group_spanned( &mut $tokens, $span, @@ -1091,7 +1230,7 @@ ); }; - ($tokens:ident $span:ident [ $($inner:tt)* ]) => { + ([ $($inner:tt)* ] $tokens:ident $span:ident) => { $crate::__private::push_group_spanned( &mut $tokens, $span, @@ -1100,7 +1239,7 @@ ); }; - ($tokens:ident $span:ident { $($inner:tt)* }) => { + ({ $($inner:tt)* } $tokens:ident $span:ident) => { $crate::__private::push_group_spanned( &mut $tokens, $span, @@ -1109,195 +1248,187 @@ ); }; - ($tokens:ident $span:ident +) => { + (# $tokens:ident $span:ident) => { + $crate::__private::push_pound_spanned(&mut $tokens, $span); + }; + + (, $tokens:ident $span:ident) => { + $crate::__private::push_comma_spanned(&mut $tokens, $span); + }; + + (. $tokens:ident $span:ident) => { + $crate::__private::push_dot_spanned(&mut $tokens, $span); + }; + + (; $tokens:ident $span:ident) => { + $crate::__private::push_semi_spanned(&mut $tokens, $span); + }; + + (: $tokens:ident $span:ident) => { + $crate::__private::push_colon_spanned(&mut $tokens, $span); + }; + + (+ $tokens:ident $span:ident) => { $crate::__private::push_add_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident +=) => { + (+= $tokens:ident $span:ident) => { $crate::__private::push_add_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident &) => { + (& $tokens:ident $span:ident) => { $crate::__private::push_and_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident &&) => { + (&& $tokens:ident $span:ident) => { $crate::__private::push_and_and_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident &=) => { + (&= $tokens:ident $span:ident) => { $crate::__private::push_and_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident @) => { + (@ $tokens:ident $span:ident) => { $crate::__private::push_at_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident !) => { + (! $tokens:ident $span:ident) => { $crate::__private::push_bang_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident ^) => { + (^ $tokens:ident $span:ident) => { $crate::__private::push_caret_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident ^=) => { + (^= $tokens:ident $span:ident) => { $crate::__private::push_caret_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident :) => { - $crate::__private::push_colon_spanned(&mut $tokens, $span); - }; - - ($tokens:ident $span:ident ::) => { - $crate::__private::push_colon2_spanned(&mut $tokens, $span); - }; - - ($tokens:ident $span:ident ,) => { - $crate::__private::push_comma_spanned(&mut $tokens, $span); - }; - - ($tokens:ident $span:ident /) => { + (/ $tokens:ident $span:ident) => { $crate::__private::push_div_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident /=) => { + (/= $tokens:ident $span:ident) => { $crate::__private::push_div_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident .) => { - $crate::__private::push_dot_spanned(&mut $tokens, $span); - }; - - ($tokens:ident $span:ident ..) => { + (.. $tokens:ident $span:ident) => { $crate::__private::push_dot2_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident ...) => { + (... $tokens:ident $span:ident) => { $crate::__private::push_dot3_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident ..=) => { + (..= $tokens:ident $span:ident) => { $crate::__private::push_dot_dot_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident =) => { + (= $tokens:ident $span:ident) => { $crate::__private::push_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident ==) => { + (== $tokens:ident $span:ident) => { $crate::__private::push_eq_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident >=) => { + (>= $tokens:ident $span:ident) => { $crate::__private::push_ge_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident >) => { + (> $tokens:ident $span:ident) => { $crate::__private::push_gt_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident <=) => { + (<= $tokens:ident $span:ident) => { $crate::__private::push_le_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident <) => { + (< $tokens:ident $span:ident) => { $crate::__private::push_lt_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident *=) => { + (*= $tokens:ident $span:ident) => { $crate::__private::push_mul_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident !=) => { + (!= $tokens:ident $span:ident) => { $crate::__private::push_ne_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident |) => { + (| $tokens:ident $span:ident) => { $crate::__private::push_or_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident |=) => { + (|= $tokens:ident $span:ident) => { $crate::__private::push_or_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident ||) => { + (|| $tokens:ident $span:ident) => { $crate::__private::push_or_or_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident #) => { - $crate::__private::push_pound_spanned(&mut $tokens, $span); - }; - - ($tokens:ident $span:ident ?) => { + (? $tokens:ident $span:ident) => { $crate::__private::push_question_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident ->) => { + (-> $tokens:ident $span:ident) => { $crate::__private::push_rarrow_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident <-) => { + (<- $tokens:ident $span:ident) => { $crate::__private::push_larrow_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident %) => { + (% $tokens:ident $span:ident) => { $crate::__private::push_rem_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident %=) => { + (%= $tokens:ident $span:ident) => { $crate::__private::push_rem_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident =>) => { + (=> $tokens:ident $span:ident) => { $crate::__private::push_fat_arrow_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident ;) => { - $crate::__private::push_semi_spanned(&mut $tokens, $span); - }; - - ($tokens:ident $span:ident <<) => { + (<< $tokens:ident $span:ident) => { $crate::__private::push_shl_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident <<=) => { + (<<= $tokens:ident $span:ident) => { $crate::__private::push_shl_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident >>) => { + (>> $tokens:ident $span:ident) => { $crate::__private::push_shr_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident >>=) => { + (>>= $tokens:ident $span:ident) => { $crate::__private::push_shr_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident *) => { + (* $tokens:ident $span:ident) => { $crate::__private::push_star_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident -) => { + (- $tokens:ident $span:ident) => { $crate::__private::push_sub_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident -=) => { + (-= $tokens:ident $span:ident) => { $crate::__private::push_sub_eq_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident $ident:ident) => { - $crate::__private::push_ident_spanned(&mut $tokens, $span, stringify!($ident)); - }; - - ($tokens:ident $span:ident $lifetime:lifetime) => { + ($lifetime:lifetime $tokens:ident $span:ident) => { $crate::__private::push_lifetime_spanned(&mut $tokens, $span, stringify!($lifetime)); }; - ($tokens:ident $span:ident _) => { + (_ $tokens:ident $span:ident) => { $crate::__private::push_underscore_spanned(&mut $tokens, $span); }; - ($tokens:ident $span:ident $other:tt) => { + ($other:tt $tokens:ident $span:ident) => { $crate::__private::parse_spanned(&mut $tokens, $span, stringify!($other)); }; } diff -Nru cargo-0.58.0/vendor/quote/tests/test.rs cargo-0.60.0ubuntu1/vendor/quote/tests/test.rs --- cargo-0.58.0/vendor/quote/tests/test.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/quote/tests/test.rs 2022-04-20 13:48:09.000000000 +0000 @@ -200,7 +200,7 @@ #[test] fn test_char() { - let zero = '\0'; + let zero = '\u{1}'; let pound = '#'; let quote = '"'; let apost = '\''; @@ -210,23 +210,23 @@ let tokens = quote! { #zero #pound #quote #apost #newline #heart }; - let expected = "'\\u{0}' '#' '\"' '\\'' '\\n' '\u{2764}'"; + let expected = "'\\u{1}' '#' '\"' '\\'' '\\n' '\u{2764}'"; assert_eq!(expected, tokens.to_string()); } #[test] fn test_str() { - let s = "\0 a 'b \" c"; + let s = "\u{1} a 'b \" c"; let tokens = quote!(#s); - let expected = "\"\\u{0} a 'b \\\" c\""; + let expected = "\"\\u{1} a 'b \\\" c\""; assert_eq!(expected, tokens.to_string()); } #[test] fn test_string() { - let s = "\0 a 'b \" c".to_string(); + let s = "\u{1} a 'b \" c".to_string(); let tokens = quote!(#s); - let expected = "\"\\u{0} a 'b \\\" c\""; + let expected = "\"\\u{1} a 'b \\\" c\""; assert_eq!(expected, tokens.to_string()); } diff -Nru cargo-0.58.0/vendor/quote/tests/ui/not-quotable.stderr cargo-0.60.0ubuntu1/vendor/quote/tests/ui/not-quotable.stderr --- cargo-0.58.0/vendor/quote/tests/ui/not-quotable.stderr 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/quote/tests/ui/not-quotable.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -4,4 +4,14 @@ 6 | let _ = quote! { #ip }; | ^^^^^^^^^^^^^^ the trait `ToTokens` is not implemented for `Ipv4Addr` | - = note: this error originates in the macro `$crate::quote_token_with_context` (in Nightly builds, run with -Z macro-backtrace for more info) + = help: the following other types implement trait `ToTokens`: + &'a T + &'a mut T + Box + Cow<'a, T> + Option + Rc + RepInterp + String + and 23 others + = note: this error originates in the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info) diff -Nru cargo-0.58.0/vendor/rand/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/rand/.cargo-checksum.json --- cargo-0.58.0/vendor/rand/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -{"files":{},"package":"2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/rand/Cargo.toml cargo-0.60.0ubuntu1/vendor/rand/Cargo.toml --- cargo-0.58.0/vendor/rand/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - -[package] -edition = "2018" -name = "rand" -version = "0.8.4" -authors = ["The Rand Project Developers", "The Rust Project Developers"] -include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"] -autobenches = true -description = "Random number generators and other randomness functionality.\n" -homepage = "https://rust-random.github.io/book" -documentation = "https://docs.rs/rand" -readme = "README.md" -keywords = ["random", "rng"] -categories = ["algorithms", "no-std"] -license = "MIT OR Apache-2.0" -repository = "https://github.com/rust-random/rand" -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "doc_cfg"] - -[package.metadata.playground] -features = ["small_rng", "serde1"] -[dependencies.log] -version = "0.4.4" -optional = true - -[dependencies.packed_simd] -version = "0.3.5" -features = ["into_bits"] -optional = true -package = "packed_simd_2" - -[dependencies.rand_core] -version = "0.6.0" - -[dependencies.serde] -version = "1.0.103" -features = ["derive"] -optional = true -[dev-dependencies.bincode] -version = "1.2.1" - -[dev-dependencies.rand_hc] -version = "0.3.0" - -[dev-dependencies.rand_pcg] -version = "0.3.0" - -[features] -alloc = ["rand_core/alloc"] -default = ["std", "std_rng"] -getrandom = ["rand_core/getrandom"] -min_const_gen = [] -nightly = [] -serde1 = ["serde", "rand_core/serde1"] -simd_support = ["packed_simd"] -small_rng = [] -std = ["rand_core/std", "rand_chacha/std", "alloc", "getrandom", "libc"] -std_rng = ["rand_chacha", "rand_hc"] -[target."cfg(not(target_os = \"emscripten\"))".dependencies.rand_chacha] -version = "0.3.0" -optional = true -default-features = false -[target."cfg(target_os = \"emscripten\")".dependencies.rand_hc] -version = "0.3.0" -optional = true -[target."cfg(unix)".dependencies.libc] -version = "0.2.22" -optional = true -default-features = false diff -Nru cargo-0.58.0/vendor/rand/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/rand/CHANGELOG.md --- cargo-0.58.0/vendor/rand/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,681 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md). - -You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful. - -## [0.8.4] - 2021-06-15 -### Additions -- Use const-generics to support arrays of all sizes (#1104) -- Implement `Clone` and `Copy` for `Alphanumeric` (#1126) -- Add `Distribution::map` to derive a distribution using a closure (#1129) -- Add `Slice` distribution (#1107) -- Add `DistString` trait with impls for `Standard` and `Alphanumeric` (#1133) - -### Other -- Reorder asserts in `Uniform` float distributions for easier debugging of non-finite arguments - (#1094, #1108) -- Add range overflow check in `Uniform` float distributions (#1108) -- Deprecate `rngs::adapter::ReadRng` (#1130) - -## [0.8.3] - 2021-01-25 -### Fixes -- Fix `no-std` + `alloc` build by gating `choose_multiple_weighted` on `std` (#1088) - -## [0.8.2] - 2021-01-12 -### Fixes -- Fix panic in `UniformInt::sample_single_inclusive` and `Rng::gen_range` when - providing a full integer range (eg `0..=MAX`) (#1087) - -## [0.8.1] - 2020-12-31 -### Other -- Enable all stable features in the playground (#1081) - -## [0.8.0] - 2020-12-18 -### Platform support -- The minimum supported Rust version is now 1.36 (#1011) -- `getrandom` updated to v0.2 (#1041) -- Remove `wasm-bindgen` and `stdweb` feature flags. For details of WASM support, - see the [getrandom documentation](https://docs.rs/getrandom/latest). (#948) -- `ReadRng::next_u32` and `next_u64` now use little-Endian conversion instead - of native-Endian, affecting results on Big-Endian platforms (#1061) -- The `nightly` feature no longer implies the `simd_support` feature (#1048) -- Fix `simd_support` feature to work on current nightlies (#1056) - -### Rngs -- `ThreadRng` is no longer `Copy` to enable safe usage within thread-local destructors (#1035) -- `gen_range(a, b)` was replaced with `gen_range(a..b)`. `gen_range(a..=b)` is - also supported. Note that `a` and `b` can no longer be references or SIMD types. (#744, #1003) -- Replace `AsByteSliceMut` with `Fill` and add support for `[bool], [char], [f32], [f64]` (#940) -- Restrict `rand::rngs::adapter` to `std` (#1027; see also #928) -- `StdRng`: add new `std_rng` feature flag (enabled by default, but might need - to be used if disabling default crate features) (#948) -- `StdRng`: Switch from ChaCha20 to ChaCha12 for better performance (#1028) -- `SmallRng`: Replace PCG algorithm with xoshiro{128,256}++ (#1038) - -### Sequences -- Add `IteratorRandom::choose_stable` as an alternative to `choose` which does - not depend on size hints (#1057) -- Improve accuracy and performance of `IteratorRandom::choose` (#1059) -- Implement `IntoIterator` for `IndexVec`, replacing the `into_iter` method (#1007) -- Add value stability tests for `seq` module (#933) - -### Misc -- Support `PartialEq` and `Eq` for `StdRng`, `SmallRng` and `StepRng` (#979) -- Added a `serde1` feature and added Serialize/Deserialize to `UniformInt` and `WeightedIndex` (#974) -- Drop some unsafe code (#962, #963, #1011) -- Reduce packaged crate size (#983) -- Migrate to GitHub Actions from Travis+AppVeyor (#1073) - -### Distributions -- `Alphanumeric` samples bytes instead of chars (#935) -- `Uniform` now supports `char`, enabling `rng.gen_range('A'..='Z')` (#1068) -- Add `UniformSampler::sample_single_inclusive` (#1003) - -#### Weighted sampling -- Implement weighted sampling without replacement (#976, #1013) -- `rand::distributions::alias_method::WeightedIndex` was moved to `rand_distr::WeightedAliasIndex`. - The simpler alternative `rand::distribution::WeightedIndex` remains. (#945) -- Improve treatment of rounding errors in `WeightedIndex::update_weights` (#956) -- `WeightedIndex`: return error on NaN instead of panic (#1005) - -### Documentation -- Document types supported by `random` (#994) -- Document notes on password generation (#995) -- Note that `SmallRng` may not be the best choice for performance and in some - other cases (#1038) -- Use `doc(cfg)` to annotate feature-gated items (#1019) -- Adjust README (#1065) - -## [0.7.3] - 2020-01-10 -### Fixes -- The `Bernoulli` distribution constructors now reports an error on NaN and on - `denominator == 0`. (#925) -- Use `std::sync::Once` to register fork handler, avoiding possible atomicity violation (#928) -- Fix documentation on the precision of generated floating-point values - -### Changes -- Unix: make libc dependency optional; only use fork protection with std feature (#928) - -### Additions -- Implement `std::error::Error` for `BernoulliError` (#919) - -## [0.7.2] - 2019-09-16 -### Fixes -- Fix dependency on `rand_core` 0.5.1 (#890) - -### Additions -- Unit tests for value stability of distributions added (#888) - -## [0.7.1] - 2019-09-13 -### Yanked -This release was yanked since it depends on `rand_core::OsRng` added in 0.5.1 -but specifies a dependency on version 0.5.0 (#890), causing a broken builds -when updating from `rand 0.7.0` without also updating `rand_core`. - -### Fixes -- Fix `no_std` behaviour, appropriately enable c2-chacha's `std` feature (#844) -- `alloc` feature in `no_std` is available since Rust 1.36 (#856) -- Fix or squelch issues from Clippy lints (#840) - -### Additions -- Add a `no_std` target to CI to continuously evaluate `no_std` status (#844) -- `WeightedIndex`: allow adjusting a sub-set of weights (#866) - -## [0.7.0] - 2019-06-28 - -### Fixes -- Fix incorrect pointer usages revealed by Miri testing (#780, #781) -- Fix (tiny!) bias in `Uniform` for 8- and 16-bit ints (#809) - -### Crate -- Bumped MSRV (min supported Rust version) to 1.32.0 -- Updated to Rust Edition 2018 (#823, #824) -- Removed dependence on `rand_xorshift`, `rand_isaac`, `rand_jitter` crates (#759, #765) -- Remove dependency on `winapi` (#724) -- Removed all `build.rs` files (#824) -- Removed code already deprecated in version 0.6 (#757) -- Removed the serde1 feature (It's still available for backwards compatibility, but it does not do anything. #830) -- Many documentation changes - -### rand_core -- Updated to `rand_core` 0.5.0 -- `Error` type redesigned with new API (#800) -- Move `from_entropy` method to `SeedableRng` and remove `FromEntropy` (#800) -- `SeedableRng::from_rng` is now expected to be value-stable (#815) - -### Standard RNGs -- OS interface moved from `rand_os` to new `getrandom` crate (#765, [getrandom](https://github.com/rust-random/getrandom)) -- Use ChaCha for `StdRng` and `ThreadRng` (#792) -- Feature-gate `SmallRng` (#792) -- `ThreadRng` now supports `Copy` (#758) -- Deprecated `EntropyRng` (#765) -- Enable fork protection of ReseedingRng without `std` (#724) - -### Distributions -- Many distributions have been moved to `rand_distr` (#761) -- `Bernoulli::new` constructor now returns a `Result` (#803) -- `Distribution::sample_iter` adjusted for more flexibility (#758) -- Added `distributions::weighted::alias_method::WeightedIndex` for `O(1)` sampling (#692) -- Support sampling `NonZeroU*` types with the `Standard` distribution (#728) -- Optimised `Binomial` distribution sampling (#735, #740, #752) -- Optimised SIMD float sampling (#739) - -### Sequences -- Make results portable across 32- and 64-bit by using `u32` samples for `usize` where possible (#809) - -## [0.6.5] - 2019-01-28 -### Crates -- Update `rand_core` to 0.4 (#703) -- Move `JitterRng` to its own crate (#685) -- Add a wasm-bindgen test crate (#696) - -### Platforms -- Fuchsia: Replaced fuchsia-zircon with fuchsia-cprng - -### Doc -- Use RFC 1946 for doc links (#691) -- Fix some doc links and notes (#711) - -## [0.6.4] - 2019-01-08 -### Fixes -- Move wasm-bindgen shims to correct crate (#686) -- Make `wasm32-unknown-unknown` compile but fail at run-time if missing bindingsg (#686) - -## [0.6.3] - 2019-01-04 -### Fixes -- Make the `std` feature require the optional `rand_os` dependency (#675) -- Re-export the optional WASM dependencies of `rand_os` from `rand` to avoid breakage (#674) - -## [0.6.2] - 2019-01-04 -### Additions -- Add `Default` for `ThreadRng` (#657) -- Move `rngs::OsRng` to `rand_os` sub-crate; clean up code; use as dependency (#643) ##BLOCKER## -- Add `rand_xoshiro` sub-crate, plus benchmarks (#642, #668) - -### Fixes -- Fix bias in `UniformInt::sample_single` (#662) -- Use `autocfg` instead of `rustc_version` for rustc version detection (#664) -- Disable `i128` and `u128` if the `target_os` is `emscripten` (#671: work-around Emscripten limitation) -- CI fixes (#660, #671) - -### Optimisations -- Optimise memory usage of `UnitCircle` and `UnitSphereSurface` distributions (no PR) - -## [0.6.1] - 2018-11-22 -- Support sampling `Duration` also for `no_std` (only since Rust 1.25) (#649) -- Disable default features of `libc` (#647) - -## [0.6.0] - 2018-11-14 - -### Project organisation -- Rand has moved from [rust-lang-nursery](https://github.com/rust-lang-nursery/rand) - to [rust-random](https://github.com/rust-random/rand)! (#578) -- Created [The Rust Random Book](https://rust-random.github.io/book/) - ([source](https://github.com/rust-random/book)) -- Update copyright and licence notices (#591, #611) -- Migrate policy documentation from the wiki (#544) - -### Platforms -- Add fork protection on Unix (#466) -- Added support for wasm-bindgen. (#541, #559, #562, #600) -- Enable `OsRng` for powerpc64, sparc and sparc64 (#609) -- Use `syscall` from `libc` on Linux instead of redefining it (#629) - -### RNGs -- Switch `SmallRng` to use PCG (#623) -- Implement `Pcg32` and `Pcg64Mcg` generators (#632) -- Move ISAAC RNGs to a dedicated crate (#551) -- Move Xorshift RNG to its own crate (#557) -- Move ChaCha and HC128 RNGs to dedicated crates (#607, #636) -- Remove usage of `Rc` from `ThreadRng` (#615) - -### Sampling and distributions -- Implement `Rng.gen_ratio()` and `Bernoulli::new_ratio()` (#491) -- Make `Uniform` strictly respect `f32` / `f64` high/low bounds (#477) -- Allow `gen_range` and `Uniform` to work on non-`Copy` types (#506) -- `Uniform` supports inclusive ranges: `Uniform::from(a..=b)`. This is - automatically enabled for Rust >= 1.27. (#566) -- Implement `TrustedLen` and `FusedIterator` for `DistIter` (#620) - -#### New distributions -- Add the `Dirichlet` distribution (#485) -- Added sampling from the unit sphere and circle. (#567) -- Implement the triangular distribution (#575) -- Implement the Weibull distribution (#576) -- Implement the Beta distribution (#574) - -#### Optimisations - -- Optimise `Bernoulli::new` (#500) -- Optimise `char` sampling (#519) -- Optimise sampling of `std::time::Duration` (#583) - -### Sequences -- Redesign the `seq` module (#483, #515) -- Add `WeightedIndex` and `choose_weighted` (#518, #547) -- Optimised and changed return type of the `sample_indices` function. (#479) -- Use `Iterator::size_hint()` to speed up `IteratorRandom::choose` (#593) - -### SIMD -- Support for generating SIMD types (#523, #542, #561, #630) - -### Other -- Revise CI scripts (#632, #635) -- Remove functionality already deprecated in 0.5 (#499) -- Support for `i128` and `u128` is automatically enabled for Rust >= 1.26. This - renders the `i128_support` feature obsolete. It still exists for backwards - compatibility but does not have any effect. This breaks programs using Rand - with `i128_support` on nightlies older than Rust 1.26. (#571) - - -## [0.5.5] - 2018-08-07 -### Documentation -- Fix links in documentation (#582) - - -## [0.5.4] - 2018-07-11 -### Platform support -- Make `OsRng` work via WASM/stdweb for WebWorkers - - -## [0.5.3] - 2018-06-26 -### Platform support -- OpenBSD, Bitrig: fix compilation (broken in 0.5.1) (#530) - - -## [0.5.2] - 2018-06-18 -### Platform support -- Hide `OsRng` and `JitterRng` on unsupported platforms (#512; fixes #503). - - -## [0.5.1] - 2018-06-08 - -### New distributions -- Added Cauchy distribution. (#474, #486) -- Added Pareto distribution. (#495) - -### Platform support and `OsRng` -- Remove blanket Unix implementation. (#484) -- Remove Wasm unimplemented stub. (#484) -- Dragonfly BSD: read from `/dev/random`. (#484) -- Bitrig: use `getentropy` like OpenBSD. (#484) -- Solaris: (untested) use `getrandom` if available, otherwise `/dev/random`. (#484) -- Emscripten, `stdweb`: split the read up in chunks. (#484) -- Emscripten, Haiku: don't do an extra blocking read from `/dev/random`. (#484) -- Linux, NetBSD, Solaris: read in blocking mode on first use in `fill_bytes`. (#484) -- Fuchsia, CloudABI: fix compilation (broken in Rand 0.5). (#484) - - -## [0.5.0] - 2018-05-21 - -### Crate features and organisation -- Minimum Rust version update: 1.22.0. (#239) -- Create a separate `rand_core` crate. (#288) -- Deprecate `rand_derive`. (#256) -- Add `prelude` (and module reorganisation). (#435) -- Add `log` feature. Logging is now available in `JitterRng`, `OsRng`, `EntropyRng` and `ReseedingRng`. (#246) -- Add `serde1` feature for some PRNGs. (#189) -- `stdweb` feature for `OsRng` support on WASM via stdweb. (#272, #336) - -### `Rng` trait -- Split `Rng` in `RngCore` and `Rng` extension trait. - `next_u32`, `next_u64` and `fill_bytes` are now part of `RngCore`. (#265) -- Add `Rng::sample`. (#256) -- Deprecate `Rng::gen_weighted_bool`. (#308) -- Add `Rng::gen_bool`. (#308) -- Remove `Rng::next_f32` and `Rng::next_f64`. (#273) -- Add optimized `Rng::fill` and `Rng::try_fill` methods. (#247) -- Deprecate `Rng::gen_iter`. (#286) -- Deprecate `Rng::gen_ascii_chars`. (#279) - -### `rand_core` crate -- `rand` now depends on new `rand_core` crate (#288) -- `RngCore` and `SeedableRng` are now part of `rand_core`. (#288) -- Add modules to help implementing RNGs `impl` and `le`. (#209, #228) -- Add `Error` and `ErrorKind`. (#225) -- Add `CryptoRng` marker trait. (#273) -- Add `BlockRngCore` trait. (#281) -- Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325) -- Revise the `SeedableRng` trait. (#233) -- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288) -- Add `RngCore::try_fill_bytes`. (#225) - -### Other traits and types -- Add `FromEntropy` trait. (#233, #375) -- Add `SmallRng` wrapper. (#296) -- Rewrite `ReseedingRng` to only work with `BlockRngCore` (substantial performance improvement). (#281) -- Deprecate `weak_rng`. Use `SmallRng` instead. (#296) -- Deprecate `AsciiGenerator`. (#279) - -### Random number generators -- Switch `StdRng` and `thread_rng` to HC-128. (#277) -- `StdRng` must now be created with `from_entropy` instead of `new` -- Change `thread_rng` reseeding threshold to 32 MiB. (#277) -- PRNGs no longer implement `Copy`. (#209) -- `Debug` implementations no longer show internals. (#209) -- Implement `Clone` for `ReseedingRng`, `JitterRng`, OsRng`. (#383, #384) -- Implement serialization for `XorShiftRng`, `IsaacRng` and `Isaac64Rng` under the `serde1` feature. (#189) -- Implement `BlockRngCore` for `ChaChaCore` and `Hc128Core`. (#281) -- All PRNGs are now portable across big- and little-endian architectures. (#209) -- `Isaac64Rng::next_u32` no longer throws away half the results. (#209) -- Add `IsaacRng::new_from_u64` and `Isaac64Rng::new_from_u64`. (#209) -- Add the HC-128 CSPRNG `Hc128Rng`. (#210) -- Change ChaCha20 to have 64-bit counter and 64-bit stream. (#349) -- Changes to `JitterRng` to get its size down from 2112 to 24 bytes. (#251) -- Various performance improvements to all PRNGs. - -### Platform support and `OsRng` -- Add support for CloudABI. (#224) -- Remove support for NaCl. (#225) -- WASM support for `OsRng` via stdweb, behind the `stdweb` feature. (#272, #336) -- Use `getrandom` on more platforms for Linux, and on Android. (#338) -- Use the `SecRandomCopyBytes` interface on macOS. (#322) -- On systems that do not have a syscall interface, only keep a single file descriptor open for `OsRng`. (#239) -- On Unix, first try a single read from `/dev/random`, then `/dev/urandom`. (#338) -- Better error handling and reporting in `OsRng` (using new error type). (#225) -- `OsRng` now uses non-blocking when available. (#225) -- Add `EntropyRng`, which provides `OsRng`, but has `JitterRng` as a fallback. (#235) - -### Distributions -- New `Distribution` trait. (#256) -- Add `Distribution::sample_iter` and `Rng::::sample_iter`. (#361) -- Deprecate `Rand`, `Sample` and `IndependentSample` traits. (#256) -- Add a `Standard` distribution (replaces most `Rand` implementations). (#256) -- Add `Binomial` and `Poisson` distributions. (#96) -- Add `Bernoulli` dsitribution. (#411) -- Add `Alphanumeric` distribution. (#279) -- Remove `Closed01` distribution, add `OpenClosed01`. (#274, #420) -- Rework `Range` type, making it possible to implement it for user types. (#274) -- Rename `Range` to `Uniform`. (#395) -- Add `Uniform::new_inclusive` for inclusive ranges. (#274) -- Use widening multiply method for much faster integer range reduction. (#274) -- `Standard` distribution for `char` uses `Uniform` internally. (#274) -- `Standard` distribution for `bool` uses sign test. (#274) -- Implement `Standard` distribution for `Wrapping`. (#436) -- Implement `Uniform` distribution for `Duration`. (#427) - - -## [0.4.3] - 2018-08-16 -### Fixed -- Use correct syscall number for PowerPC (#589) - - -## [0.4.2] - 2018-01-06 -### Changed -- Use `winapi` on Windows -- Update for Fuchsia OS -- Remove dev-dependency on `log` - - -## [0.4.1] - 2017-12-17 -### Added -- `no_std` support - - -## [0.4.0-pre.0] - 2017-12-11 -### Added -- `JitterRng` added as a high-quality alternative entropy source using the - system timer -- new `seq` module with `sample_iter`, `sample_slice`, etc. -- WASM support via dummy implementations (fail at run-time) -- Additional benchmarks, covering generators and new seq code - -### Changed -- `thread_rng` uses `JitterRng` if seeding from system time fails - (slower but more secure than previous method) - -### Deprecated - - `sample` function deprecated (replaced by `sample_iter`) - - -## [0.3.20] - 2018-01-06 -### Changed -- Remove dev-dependency on `log` -- Update `fuchsia-zircon` dependency to 0.3.2 - - -## [0.3.19] - 2017-12-27 -### Changed -- Require `log <= 0.3.8` for dev builds -- Update `fuchsia-zircon` dependency to 0.3 -- Fix broken links in docs (to unblock compiler docs testing CI) - - -## [0.3.18] - 2017-11-06 -### Changed -- `thread_rng` is seeded from the system time if `OsRng` fails -- `weak_rng` now uses `thread_rng` internally - - -## [0.3.17] - 2017-10-07 -### Changed - - Fuchsia: Magenta was renamed Zircon - -## [0.3.16] - 2017-07-27 -### Added -- Implement Debug for mote non-public types -- implement `Rand` for (i|u)i128 -- Support for Fuchsia - -### Changed -- Add inline attribute to SampleRange::construct_range. - This improves the benchmark for sample in 11% and for shuffle in 16%. -- Use `RtlGenRandom` instead of `CryptGenRandom` - - -## [0.3.15] - 2016-11-26 -### Added -- Add `Rng` trait method `choose_mut` -- Redox support - -### Changed -- Use `arc4rand` for `OsRng` on FreeBSD. -- Use `arc4random(3)` for `OsRng` on OpenBSD. - -### Fixed -- Fix filling buffers 4 GiB or larger with `OsRng::fill_bytes` on Windows - - -## [0.3.14] - 2016-02-13 -### Fixed -- Inline definitions from winapi/advapi32, which decreases build times - - -## [0.3.13] - 2016-01-09 -### Fixed -- Compatible with Rust 1.7.0-nightly (needed some extra type annotations) - - -## [0.3.12] - 2015-11-09 -### Changed -- Replaced the methods in `next_f32` and `next_f64` with the technique described - Saito & Matsumoto at MCQMC'08. The new method should exhibit a slightly more - uniform distribution. -- Depend on libc 0.2 - -### Fixed -- Fix iterator protocol issue in `rand::sample` - - -## [0.3.11] - 2015-08-31 -### Added -- Implement `Rand` for arrays with n <= 32 - - -## [0.3.10] - 2015-08-17 -### Added -- Support for NaCl platforms - -### Changed -- Allow `Rng` to be `?Sized`, impl for `&mut R` and `Box` where `R: ?Sized + Rng` - - -## [0.3.9] - 2015-06-18 -### Changed -- Use `winapi` for Windows API things - -### Fixed -- Fixed test on stable/nightly -- Fix `getrandom` syscall number for aarch64-unknown-linux-gnu - - -## [0.3.8] - 2015-04-23 -### Changed -- `log` is a dev dependency - -### Fixed -- Fix race condition of atomics in `is_getrandom_available` - - -## [0.3.7] - 2015-04-03 -### Fixed -- Derive Copy/Clone changes - - -## [0.3.6] - 2015-04-02 -### Changed -- Move to stable Rust! - - -## [0.3.5] - 2015-04-01 -### Fixed -- Compatible with Rust master - - -## [0.3.4] - 2015-03-31 -### Added -- Implement Clone for `Weighted` - -### Fixed -- Compatible with Rust master - - -## [0.3.3] - 2015-03-26 -### Fixed -- Fix compile on Windows - - -## [0.3.2] - 2015-03-26 - - -## [0.3.1] - 2015-03-26 -### Fixed -- Fix compile on Windows - - -## [0.3.0] - 2015-03-25 -### Changed -- Update to use log version 0.3.x - - -## [0.2.1] - 2015-03-22 -### Fixed -- Compatible with Rust master -- Fixed iOS compilation - - -## [0.2.0] - 2015-03-06 -### Fixed -- Compatible with Rust master (move from `old_io` to `std::io`) - - -## [0.1.4] - 2015-03-04 -### Fixed -- Compatible with Rust master (use wrapping ops) - - -## [0.1.3] - 2015-02-20 -### Fixed -- Compatible with Rust master - -### Removed -- Removed Copy implementations from RNGs - - -## [0.1.2] - 2015-02-03 -### Added -- Imported functionality from `std::rand`, including: - - `StdRng`, `SeedableRng`, `TreadRng`, `weak_rng()` - - `ReaderRng`: A wrapper around any Reader to treat it as an RNG. -- Imported documentation from `std::rand` -- Imported tests from `std::rand` - - -## [0.1.1] - 2015-02-03 -### Added -- Migrate to a cargo-compatible directory structure. - -### Fixed -- Do not use entropy during `gen_weighted_bool(1)` - - -## [Rust 0.12.0] - 2014-10-09 -### Added -- Impl Rand for tuples of arity 11 and 12 -- Include ChaCha pseudorandom generator -- Add `next_f64` and `next_f32` to Rng -- Implement Clone for PRNGs - -### Changed -- Rename `TaskRng` to `ThreadRng` and `task_rng` to `thread_rng` (since a - runtime is removed from Rust). - -### Fixed -- Improved performance of ISAAC and ISAAC64 by 30% and 12 % respectively, by - informing the optimiser that indexing is never out-of-bounds. - -### Removed -- Removed the Deprecated `choose_option` - - -## [Rust 0.11.0] - 2014-07-02 -### Added -- document when to use `OSRng` in cryptographic context, and explain why we use `/dev/urandom` instead of `/dev/random` -- `Rng::gen_iter()` which will return an infinite stream of random values -- `Rng::gen_ascii_chars()` which will return an infinite stream of random ascii characters - -### Changed -- Now only depends on libcore! -- Remove `Rng.choose()`, rename `Rng.choose_option()` to `.choose()` -- Rename OSRng to OsRng -- The WeightedChoice structure is no longer built with a `Vec>`, - but rather a `&mut [Weighted]`. This means that the WeightedChoice - structure now has a lifetime associated with it. -- The `sample` method on `Rng` has been moved to a top-level function in the - `rand` module due to its dependence on `Vec`. - -### Removed -- `Rng::gen_vec()` was removed. Previous behavior can be regained with - `rng.gen_iter().take(n).collect()` -- `Rng::gen_ascii_str()` was removed. Previous behavior can be regained with - `rng.gen_ascii_chars().take(n).collect()` -- {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all - relied on being able to use an OSRng for seeding, but this is no longer - available in librand (where these types are defined). To retain the same - functionality, these types now implement the `Rand` trait so they can be - generated with a random seed from another random number generator. This allows - the stdlib to use an OSRng to create seeded instances of these RNGs. -- Rand implementations for `Box` and `@T` were removed. These seemed to be - pretty rare in the codebase, and it allows for librand to not depend on - liballoc. Additionally, other pointer types like Rc and Arc were not - supported. -- Remove a slew of old deprecated functions - - -## [Rust 0.10] - 2014-04-03 -### Changed -- replace `Rng.shuffle's` functionality with `.shuffle_mut` -- bubble up IO errors when creating an OSRng - -### Fixed -- Use `fill()` instead of `read()` -- Rewrite OsRng in Rust for windows - -## [0.10-pre] - 2014-03-02 -### Added -- Seperate `rand` out of the standard library diff -Nru cargo-0.58.0/vendor/rand/COPYRIGHT cargo-0.60.0ubuntu1/vendor/rand/COPYRIGHT --- cargo-0.58.0/vendor/rand/COPYRIGHT 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/COPYRIGHT 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -Copyrights in the Rand project are retained by their contributors. No -copyright assignment is required to contribute to the Rand project. - -For full authorship information, see the version control history. - -Except as otherwise noted (below and/or in individual files), Rand is -licensed under the Apache License, Version 2.0 or - or the MIT license - or , at your option. - -The Rand project includes code from the Rust project -published under these same licenses. diff -Nru cargo-0.58.0/vendor/rand/LICENSE-APACHE cargo-0.60.0ubuntu1/vendor/rand/LICENSE-APACHE --- cargo-0.58.0/vendor/rand/LICENSE-APACHE 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff -Nru cargo-0.58.0/vendor/rand/LICENSE-MIT cargo-0.60.0ubuntu1/vendor/rand/LICENSE-MIT --- cargo-0.58.0/vendor/rand/LICENSE-MIT 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -Copyright 2018 Developers of the Rand project -Copyright (c) 2014 The Rust Project Developers - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff -Nru cargo-0.58.0/vendor/rand/README.md cargo-0.60.0ubuntu1/vendor/rand/README.md --- cargo-0.58.0/vendor/rand/README.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,156 +0,0 @@ -# Rand - -[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rand/actions) -[![Crate](https://img.shields.io/crates/v/rand.svg)](https://crates.io/crates/rand) -[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) -[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand) -[![API](https://docs.rs/rand/badge.svg)](https://docs.rs/rand) -[![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) - -A Rust library for random number generation, featuring: - -- Easy random value generation and usage via the [`Rng`](https://docs.rs/rand/*/rand/trait.Rng.html), - [`SliceRandom`](https://docs.rs/rand/*/rand/seq/trait.SliceRandom.html) and - [`IteratorRandom`](https://docs.rs/rand/*/rand/seq/trait.IteratorRandom.html) traits -- Secure seeding via the [`getrandom` crate](https://crates.io/crates/getrandom) - and fast, convenient generation via [`thread_rng`](https://docs.rs/rand/*/rand/fn.thread_rng.html) -- A modular design built over [`rand_core`](https://crates.io/crates/rand_core) - ([see the book](https://rust-random.github.io/book/crates.html)) -- Fast implementations of the best-in-class [cryptographic](https://rust-random.github.io/book/guide-rngs.html#cryptographically-secure-pseudo-random-number-generators-csprngs) and - [non-cryptographic](https://rust-random.github.io/book/guide-rngs.html#basic-pseudo-random-number-generators-prngs) generators -- A flexible [`distributions`](https://docs.rs/rand/*/rand/distributions/index.html) module -- Samplers for a large number of random number distributions via our own - [`rand_distr`](https://docs.rs/rand_distr) and via - the [`statrs`](https://docs.rs/statrs/0.13.0/statrs/) -- [Portably reproducible output](https://rust-random.github.io/book/portability.html) -- `#[no_std]` compatibility (partial) -- *Many* performance optimisations - -It's also worth pointing out what `rand` *is not*: - -- Small. Most low-level crates are small, but the higher-level `rand` and - `rand_distr` each contain a lot of functionality. -- Simple (implementation). We have a strong focus on correctness, speed and flexibility, but - not simplicity. If you prefer a small-and-simple library, there are - alternatives including [fastrand](https://crates.io/crates/fastrand) - and [oorandom](https://crates.io/crates/oorandom). -- Slow. We take performance seriously, with considerations also for set-up - time of new distributions, commonly-used parameters, and parameters of the - current sampler. - -Documentation: - -- [The Rust Rand Book](https://rust-random.github.io/book) -- [API reference (master branch)](https://rust-random.github.io/rand) -- [API reference (docs.rs)](https://docs.rs/rand) - - -## Usage - -Add this to your `Cargo.toml`: - -```toml -[dependencies] -rand = "0.8.0" -``` - -To get started using Rand, see [The Book](https://rust-random.github.io/book). - - -## Versions - -Rand is *mature* (suitable for general usage, with infrequent breaking releases -which minimise breakage) but not yet at 1.0. We maintain compatibility with -pinned versions of the Rust compiler (see below). - -Current Rand versions are: - -- Version 0.7 was released in June 2019, moving most non-uniform distributions - to an external crate, moving `from_entropy` to `SeedableRng`, and many small - changes and fixes. -- Version 0.8 was released in December 2020 with many small changes. - -A detailed [changelog](CHANGELOG.md) is available for releases. - -When upgrading to the next minor series (especially 0.4 → 0.5), we recommend -reading the [Upgrade Guide](https://rust-random.github.io/book/update.html). - -Rand has not yet reached 1.0 implying some breaking changes may arrive in the -future ([SemVer](https://semver.org/) allows each 0.x.0 release to include -breaking changes), but is considered *mature*: breaking changes are minimised -and breaking releases are infrequent. - -Rand libs have inter-dependencies and make use of the -[semver trick](https://github.com/dtolnay/semver-trick/) in order to make traits -compatible across crate versions. (This is especially important for `RngCore` -and `SeedableRng`.) A few crate releases are thus compatibility shims, -depending on the *next* lib version (e.g. `rand_core` versions `0.2.2` and -`0.3.1`). This means, for example, that `rand_core_0_4_0::SeedableRng` and -`rand_core_0_3_0::SeedableRng` are distinct, incompatible traits, which can -cause build errors. Usually, running `cargo update` is enough to fix any issues. - -### Yanked versions - -Some versions of Rand crates have been yanked ("unreleased"). Where this occurs, -the crate's CHANGELOG *should* be updated with a rationale, and a search on the -issue tracker with the keyword `yank` *should* uncover the motivation. - -### Rust version requirements - -Since version 0.8, Rand requires **Rustc version 1.36 or greater**. -Rand 0.7 requires Rustc 1.32 or greater while versions 0.5 require Rustc 1.22 or -greater, and 0.4 and 0.3 (since approx. June 2017) require Rustc version 1.15 or -greater. Subsets of the Rand code may work with older Rust versions, but this is -not supported. - -Continuous Integration (CI) will always test the minimum supported Rustc version -(the MSRV). The current policy is that this can be updated in any -Rand release if required, but the change must be noted in the changelog. - -## Crate Features - -Rand is built with these features enabled by default: - -- `std` enables functionality dependent on the `std` lib -- `alloc` (implied by `std`) enables functionality requiring an allocator -- `getrandom` (implied by `std`) is an optional dependency providing the code - behind `rngs::OsRng` -- `std_rng` enables inclusion of `StdRng`, `thread_rng` and `random` - (the latter two *also* require that `std` be enabled) - -Optionally, the following dependencies can be enabled: - -- `log` enables logging via the `log` crate` crate - -Additionally, these features configure Rand: - -- `small_rng` enables inclusion of the `SmallRng` PRNG -- `nightly` enables some optimizations requiring nightly Rust -- `simd_support` (experimental) enables sampling of SIMD values - (uniformly random SIMD integers and floats), requiring nightly Rust - -Note that nightly features are not stable and therefore not all library and -compiler versions will be compatible. This is especially true of Rand's -experimental `simd_support` feature. - -Rand supports limited functionality in `no_std` mode (enabled via -`default-features = false`). In this case, `OsRng` and `from_entropy` are -unavailable (unless `getrandom` is enabled), large parts of `seq` are -unavailable (unless `alloc` is enabled), and `thread_rng` and `random` are -unavailable. - -### WASM support - -The WASM target `wasm32-unknown-unknown` is not *automatically* supported by -`rand` or `getrandom`. To solve this, either use a different target such as -`wasm32-wasi` or add a direct dependancy on `getrandom` with the `js` feature -(if the target supports JavaScript). See -[getrandom#WebAssembly support](https://docs.rs/getrandom/latest/getrandom/#webassembly-support). - -# License - -Rand is distributed under the terms of both the MIT license and the -Apache License (Version 2.0). - -See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and -[COPYRIGHT](COPYRIGHT) for details. diff -Nru cargo-0.58.0/vendor/rand/src/distributions/bernoulli.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/bernoulli.rs --- cargo-0.58.0/vendor/rand/src/distributions/bernoulli.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/bernoulli.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,214 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The Bernoulli distribution. - -use crate::distributions::Distribution; -use crate::Rng; -use core::{fmt, u64}; - -#[cfg(feature = "serde1")] -use serde::{Serialize, Deserialize}; -/// The Bernoulli distribution. -/// -/// This is a special case of the Binomial distribution where `n = 1`. -/// -/// # Example -/// -/// ```rust -/// use rand::distributions::{Bernoulli, Distribution}; -/// -/// let d = Bernoulli::new(0.3).unwrap(); -/// let v = d.sample(&mut rand::thread_rng()); -/// println!("{} is from a Bernoulli distribution", v); -/// ``` -/// -/// # Precision -/// -/// This `Bernoulli` distribution uses 64 bits from the RNG (a `u64`), -/// so only probabilities that are multiples of 2-64 can be -/// represented. -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub struct Bernoulli { - /// Probability of success, relative to the maximal integer. - p_int: u64, -} - -// To sample from the Bernoulli distribution we use a method that compares a -// random `u64` value `v < (p * 2^64)`. -// -// If `p == 1.0`, the integer `v` to compare against can not represented as a -// `u64`. We manually set it to `u64::MAX` instead (2^64 - 1 instead of 2^64). -// Note that value of `p < 1.0` can never result in `u64::MAX`, because an -// `f64` only has 53 bits of precision, and the next largest value of `p` will -// result in `2^64 - 2048`. -// -// Also there is a 100% theoretical concern: if someone consistenly wants to -// generate `true` using the Bernoulli distribution (i.e. by using a probability -// of `1.0`), just using `u64::MAX` is not enough. On average it would return -// false once every 2^64 iterations. Some people apparently care about this -// case. -// -// That is why we special-case `u64::MAX` to always return `true`, without using -// the RNG, and pay the performance price for all uses that *are* reasonable. -// Luckily, if `new()` and `sample` are close, the compiler can optimize out the -// extra check. -const ALWAYS_TRUE: u64 = u64::MAX; - -// This is just `2.0.powi(64)`, but written this way because it is not available -// in `no_std` mode. -const SCALE: f64 = 2.0 * (1u64 << 63) as f64; - -/// Error type returned from `Bernoulli::new`. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum BernoulliError { - /// `p < 0` or `p > 1`. - InvalidProbability, -} - -impl fmt::Display for BernoulliError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str(match self { - BernoulliError::InvalidProbability => "p is outside [0, 1] in Bernoulli distribution", - }) - } -} - -#[cfg(feature = "std")] -impl ::std::error::Error for BernoulliError {} - -impl Bernoulli { - /// Construct a new `Bernoulli` with the given probability of success `p`. - /// - /// # Precision - /// - /// For `p = 1.0`, the resulting distribution will always generate true. - /// For `p = 0.0`, the resulting distribution will always generate false. - /// - /// This method is accurate for any input `p` in the range `[0, 1]` which is - /// a multiple of 2-64. (Note that not all multiples of - /// 2-64 in `[0, 1]` can be represented as a `f64`.) - #[inline] - pub fn new(p: f64) -> Result { - if !(0.0..1.0).contains(&p) { - if p == 1.0 { - return Ok(Bernoulli { p_int: ALWAYS_TRUE }); - } - return Err(BernoulliError::InvalidProbability); - } - Ok(Bernoulli { - p_int: (p * SCALE) as u64, - }) - } - - /// Construct a new `Bernoulli` with the probability of success of - /// `numerator`-in-`denominator`. I.e. `new_ratio(2, 3)` will return - /// a `Bernoulli` with a 2-in-3 chance, or about 67%, of returning `true`. - /// - /// return `true`. If `numerator == 0` it will always return `false`. - /// For `numerator > denominator` and `denominator == 0`, this returns an - /// error. Otherwise, for `numerator == denominator`, samples are always - /// true; for `numerator == 0` samples are always false. - #[inline] - pub fn from_ratio(numerator: u32, denominator: u32) -> Result { - if numerator > denominator || denominator == 0 { - return Err(BernoulliError::InvalidProbability); - } - if numerator == denominator { - return Ok(Bernoulli { p_int: ALWAYS_TRUE }); - } - let p_int = ((f64::from(numerator) / f64::from(denominator)) * SCALE) as u64; - Ok(Bernoulli { p_int }) - } -} - -impl Distribution for Bernoulli { - #[inline] - fn sample(&self, rng: &mut R) -> bool { - // Make sure to always return true for p = 1.0. - if self.p_int == ALWAYS_TRUE { - return true; - } - let v: u64 = rng.gen(); - v < self.p_int - } -} - -#[cfg(test)] -mod test { - use super::Bernoulli; - use crate::distributions::Distribution; - use crate::Rng; - - #[test] - #[cfg(feature="serde1")] - fn test_serializing_deserializing_bernoulli() { - let coin_flip = Bernoulli::new(0.5).unwrap(); - let de_coin_flip : Bernoulli = bincode::deserialize(&bincode::serialize(&coin_flip).unwrap()).unwrap(); - - assert_eq!(coin_flip.p_int, de_coin_flip.p_int); - } - - #[test] - fn test_trivial() { - // We prefer to be explicit here. - #![allow(clippy::bool_assert_comparison)] - - let mut r = crate::test::rng(1); - let always_false = Bernoulli::new(0.0).unwrap(); - let always_true = Bernoulli::new(1.0).unwrap(); - for _ in 0..5 { - assert_eq!(r.sample::(&always_false), false); - assert_eq!(r.sample::(&always_true), true); - assert_eq!(Distribution::::sample(&always_false, &mut r), false); - assert_eq!(Distribution::::sample(&always_true, &mut r), true); - } - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_average() { - const P: f64 = 0.3; - const NUM: u32 = 3; - const DENOM: u32 = 10; - let d1 = Bernoulli::new(P).unwrap(); - let d2 = Bernoulli::from_ratio(NUM, DENOM).unwrap(); - const N: u32 = 100_000; - - let mut sum1: u32 = 0; - let mut sum2: u32 = 0; - let mut rng = crate::test::rng(2); - for _ in 0..N { - if d1.sample(&mut rng) { - sum1 += 1; - } - if d2.sample(&mut rng) { - sum2 += 1; - } - } - let avg1 = (sum1 as f64) / (N as f64); - assert!((avg1 - P).abs() < 5e-3); - - let avg2 = (sum2 as f64) / (N as f64); - assert!((avg2 - (NUM as f64) / (DENOM as f64)).abs() < 5e-3); - } - - #[test] - fn value_stability() { - let mut rng = crate::test::rng(3); - let distr = Bernoulli::new(0.4532).unwrap(); - let mut buf = [false; 10]; - for x in &mut buf { - *x = rng.sample(&distr); - } - assert_eq!(buf, [ - true, false, false, true, false, false, true, true, true, true - ]); - } -} diff -Nru cargo-0.58.0/vendor/rand/src/distributions/distribution.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/distribution.rs --- cargo-0.58.0/vendor/rand/src/distributions/distribution.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/distribution.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,272 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013-2017 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Distribution trait and associates - -use crate::Rng; -use core::iter; -#[cfg(feature = "alloc")] -use alloc::string::String; - -/// Types (distributions) that can be used to create a random instance of `T`. -/// -/// It is possible to sample from a distribution through both the -/// `Distribution` and [`Rng`] traits, via `distr.sample(&mut rng)` and -/// `rng.sample(distr)`. They also both offer the [`sample_iter`] method, which -/// produces an iterator that samples from the distribution. -/// -/// All implementations are expected to be immutable; this has the significant -/// advantage of not needing to consider thread safety, and for most -/// distributions efficient state-less sampling algorithms are available. -/// -/// Implementations are typically expected to be portable with reproducible -/// results when used with a PRNG with fixed seed; see the -/// [portability chapter](https://rust-random.github.io/book/portability.html) -/// of The Rust Rand Book. In some cases this does not apply, e.g. the `usize` -/// type requires different sampling on 32-bit and 64-bit machines. -/// -/// [`sample_iter`]: Distribution::sample_iter -pub trait Distribution { - /// Generate a random value of `T`, using `rng` as the source of randomness. - fn sample(&self, rng: &mut R) -> T; - - /// Create an iterator that generates random values of `T`, using `rng` as - /// the source of randomness. - /// - /// Note that this function takes `self` by value. This works since - /// `Distribution` is impl'd for `&D` where `D: Distribution`, - /// however borrowing is not automatic hence `distr.sample_iter(...)` may - /// need to be replaced with `(&distr).sample_iter(...)` to borrow or - /// `(&*distr).sample_iter(...)` to reborrow an existing reference. - /// - /// # Example - /// - /// ``` - /// use rand::thread_rng; - /// use rand::distributions::{Distribution, Alphanumeric, Uniform, Standard}; - /// - /// let mut rng = thread_rng(); - /// - /// // Vec of 16 x f32: - /// let v: Vec = Standard.sample_iter(&mut rng).take(16).collect(); - /// - /// // String: - /// let s: String = Alphanumeric - /// .sample_iter(&mut rng) - /// .take(7) - /// .map(char::from) - /// .collect(); - /// - /// // Dice-rolling: - /// let die_range = Uniform::new_inclusive(1, 6); - /// let mut roll_die = die_range.sample_iter(&mut rng); - /// while roll_die.next().unwrap() != 6 { - /// println!("Not a 6; rolling again!"); - /// } - /// ``` - fn sample_iter(self, rng: R) -> DistIter - where - R: Rng, - Self: Sized, - { - DistIter { - distr: self, - rng, - phantom: ::core::marker::PhantomData, - } - } - - /// Create a distribution of values of 'S' by mapping the output of `Self` - /// through the closure `F` - /// - /// # Example - /// - /// ``` - /// use rand::thread_rng; - /// use rand::distributions::{Distribution, Uniform}; - /// - /// let mut rng = thread_rng(); - /// - /// let die = Uniform::new_inclusive(1, 6); - /// let even_number = die.map(|num| num % 2 == 0); - /// while !even_number.sample(&mut rng) { - /// println!("Still odd; rolling again!"); - /// } - /// ``` - fn map(self, func: F) -> DistMap - where - F: Fn(T) -> S, - Self: Sized, - { - DistMap { - distr: self, - func, - phantom: ::core::marker::PhantomData, - } - } -} - -impl<'a, T, D: Distribution> Distribution for &'a D { - fn sample(&self, rng: &mut R) -> T { - (*self).sample(rng) - } -} - -/// An iterator that generates random values of `T` with distribution `D`, -/// using `R` as the source of randomness. -/// -/// This `struct` is created by the [`sample_iter`] method on [`Distribution`]. -/// See its documentation for more. -/// -/// [`sample_iter`]: Distribution::sample_iter -#[derive(Debug)] -pub struct DistIter { - distr: D, - rng: R, - phantom: ::core::marker::PhantomData, -} - -impl Iterator for DistIter -where - D: Distribution, - R: Rng, -{ - type Item = T; - - #[inline(always)] - fn next(&mut self) -> Option { - // Here, self.rng may be a reference, but we must take &mut anyway. - // Even if sample could take an R: Rng by value, we would need to do this - // since Rng is not copyable and we cannot enforce that this is "reborrowable". - Some(self.distr.sample(&mut self.rng)) - } - - fn size_hint(&self) -> (usize, Option) { - (usize::max_value(), None) - } -} - -impl iter::FusedIterator for DistIter -where - D: Distribution, - R: Rng, -{ -} - -#[cfg(features = "nightly")] -impl iter::TrustedLen for DistIter -where - D: Distribution, - R: Rng, -{ -} - -/// A distribution of values of type `S` derived from the distribution `D` -/// by mapping its output of type `T` through the closure `F`. -/// -/// This `struct` is created by the [`Distribution::map`] method. -/// See its documentation for more. -#[derive(Debug)] -pub struct DistMap { - distr: D, - func: F, - phantom: ::core::marker::PhantomData S>, -} - -impl Distribution for DistMap -where - D: Distribution, - F: Fn(T) -> S, -{ - fn sample(&self, rng: &mut R) -> S { - (self.func)(self.distr.sample(rng)) - } -} - -/// `String` sampler -/// -/// Sampling a `String` of random characters is not quite the same as collecting -/// a sequence of chars. This trait contains some helpers. -#[cfg(feature = "alloc")] -pub trait DistString { - /// Append `len` random chars to `string` - fn append_string(&self, rng: &mut R, string: &mut String, len: usize); - - /// Generate a `String` of `len` random chars - #[inline] - fn sample_string(&self, rng: &mut R, len: usize) -> String { - let mut s = String::new(); - self.append_string(rng, &mut s, len); - s - } -} - -#[cfg(test)] -mod tests { - use crate::distributions::{Alphanumeric, Distribution, Standard, Uniform}; - use crate::Rng; - - #[test] - fn test_distributions_iter() { - use crate::distributions::Open01; - let mut rng = crate::test::rng(210); - let distr = Open01; - let mut iter = Distribution::::sample_iter(distr, &mut rng); - let mut sum: f32 = 0.; - for _ in 0..100 { - sum += iter.next().unwrap(); - } - assert!(0. < sum && sum < 100.); - } - - #[test] - fn test_distributions_map() { - let dist = Uniform::new_inclusive(0, 5).map(|val| val + 15); - - let mut rng = crate::test::rng(212); - let val = dist.sample(&mut rng); - assert!(val >= 15 && val <= 20); - } - - #[test] - fn test_make_an_iter() { - fn ten_dice_rolls_other_than_five( - rng: &mut R, - ) -> impl Iterator + '_ { - Uniform::new_inclusive(1, 6) - .sample_iter(rng) - .filter(|x| *x != 5) - .take(10) - } - - let mut rng = crate::test::rng(211); - let mut count = 0; - for val in ten_dice_rolls_other_than_five(&mut rng) { - assert!((1..=6).contains(&val) && val != 5); - count += 1; - } - assert_eq!(count, 10); - } - - #[test] - #[cfg(feature = "alloc")] - fn test_dist_string() { - use core::str; - use crate::distributions::DistString; - let mut rng = crate::test::rng(213); - - let s1 = Alphanumeric.sample_string(&mut rng, 20); - assert_eq!(s1.len(), 20); - assert_eq!(str::from_utf8(s1.as_bytes()), Ok(s1.as_str())); - - let s2 = Standard.sample_string(&mut rng, 20); - assert_eq!(s2.chars().count(), 20); - assert_eq!(str::from_utf8(s2.as_bytes()), Ok(s2.as_str())); - } -} diff -Nru cargo-0.58.0/vendor/rand/src/distributions/float.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/float.rs --- cargo-0.58.0/vendor/rand/src/distributions/float.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/float.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,312 +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. - -//! Basic floating-point number distributions - -use crate::distributions::utils::FloatSIMDUtils; -use crate::distributions::{Distribution, Standard}; -use crate::Rng; -use core::mem; -#[cfg(feature = "simd_support")] use packed_simd::*; - -#[cfg(feature = "serde1")] -use serde::{Serialize, Deserialize}; - -/// A distribution to sample floating point numbers uniformly in the half-open -/// interval `(0, 1]`, i.e. including 1 but not 0. -/// -/// All values that can be generated are of the form `n * ε/2`. For `f32` -/// the 24 most significant random bits of a `u32` are used and for `f64` the -/// 53 most significant bits of a `u64` are used. The conversion uses the -/// multiplicative method. -/// -/// See also: [`Standard`] which samples from `[0, 1)`, [`Open01`] -/// which samples from `(0, 1)` and [`Uniform`] which samples from arbitrary -/// ranges. -/// -/// # Example -/// ``` -/// use rand::{thread_rng, Rng}; -/// use rand::distributions::OpenClosed01; -/// -/// let val: f32 = thread_rng().sample(OpenClosed01); -/// println!("f32 from (0, 1): {}", val); -/// ``` -/// -/// [`Standard`]: crate::distributions::Standard -/// [`Open01`]: crate::distributions::Open01 -/// [`Uniform`]: crate::distributions::uniform::Uniform -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub struct OpenClosed01; - -/// A distribution to sample floating point numbers uniformly in the open -/// interval `(0, 1)`, i.e. not including either endpoint. -/// -/// All values that can be generated are of the form `n * ε + ε/2`. For `f32` -/// the 23 most significant random bits of an `u32` are used, for `f64` 52 from -/// an `u64`. The conversion uses a transmute-based method. -/// -/// See also: [`Standard`] which samples from `[0, 1)`, [`OpenClosed01`] -/// which samples from `(0, 1]` and [`Uniform`] which samples from arbitrary -/// ranges. -/// -/// # Example -/// ``` -/// use rand::{thread_rng, Rng}; -/// use rand::distributions::Open01; -/// -/// let val: f32 = thread_rng().sample(Open01); -/// println!("f32 from (0, 1): {}", val); -/// ``` -/// -/// [`Standard`]: crate::distributions::Standard -/// [`OpenClosed01`]: crate::distributions::OpenClosed01 -/// [`Uniform`]: crate::distributions::uniform::Uniform -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub struct Open01; - - -// This trait is needed by both this lib and rand_distr hence is a hidden export -#[doc(hidden)] -pub trait IntoFloat { - type F; - - /// Helper method to combine the fraction and a contant exponent into a - /// float. - /// - /// Only the least significant bits of `self` may be set, 23 for `f32` and - /// 52 for `f64`. - /// The resulting value will fall in a range that depends on the exponent. - /// As an example the range with exponent 0 will be - /// [20..21), which is [1..2). - fn into_float_with_exponent(self, exponent: i32) -> Self::F; -} - -macro_rules! float_impls { - ($ty:ident, $uty:ident, $f_scalar:ident, $u_scalar:ty, - $fraction_bits:expr, $exponent_bias:expr) => { - impl IntoFloat for $uty { - type F = $ty; - #[inline(always)] - fn into_float_with_exponent(self, exponent: i32) -> $ty { - // The exponent is encoded using an offset-binary representation - let exponent_bits: $u_scalar = - (($exponent_bias + exponent) as $u_scalar) << $fraction_bits; - $ty::from_bits(self | exponent_bits) - } - } - - impl Distribution<$ty> for Standard { - fn sample(&self, rng: &mut R) -> $ty { - // Multiply-based method; 24/53 random bits; [0, 1) interval. - // We use the most significant bits because for simple RNGs - // those are usually more random. - let float_size = mem::size_of::<$f_scalar>() as u32 * 8; - let precision = $fraction_bits + 1; - let scale = 1.0 / ((1 as $u_scalar << precision) as $f_scalar); - - let value: $uty = rng.gen(); - let value = value >> (float_size - precision); - scale * $ty::cast_from_int(value) - } - } - - impl Distribution<$ty> for OpenClosed01 { - fn sample(&self, rng: &mut R) -> $ty { - // Multiply-based method; 24/53 random bits; (0, 1] interval. - // We use the most significant bits because for simple RNGs - // those are usually more random. - let float_size = mem::size_of::<$f_scalar>() as u32 * 8; - let precision = $fraction_bits + 1; - let scale = 1.0 / ((1 as $u_scalar << precision) as $f_scalar); - - let value: $uty = rng.gen(); - let value = value >> (float_size - precision); - // Add 1 to shift up; will not overflow because of right-shift: - scale * $ty::cast_from_int(value + 1) - } - } - - impl Distribution<$ty> for Open01 { - fn sample(&self, rng: &mut R) -> $ty { - // Transmute-based method; 23/52 random bits; (0, 1) interval. - // We use the most significant bits because for simple RNGs - // those are usually more random. - use core::$f_scalar::EPSILON; - let float_size = mem::size_of::<$f_scalar>() as u32 * 8; - - let value: $uty = rng.gen(); - let fraction = value >> (float_size - $fraction_bits); - fraction.into_float_with_exponent(0) - (1.0 - EPSILON / 2.0) - } - } - } -} - -float_impls! { f32, u32, f32, u32, 23, 127 } -float_impls! { f64, u64, f64, u64, 52, 1023 } - -#[cfg(feature = "simd_support")] -float_impls! { f32x2, u32x2, f32, u32, 23, 127 } -#[cfg(feature = "simd_support")] -float_impls! { f32x4, u32x4, f32, u32, 23, 127 } -#[cfg(feature = "simd_support")] -float_impls! { f32x8, u32x8, f32, u32, 23, 127 } -#[cfg(feature = "simd_support")] -float_impls! { f32x16, u32x16, f32, u32, 23, 127 } - -#[cfg(feature = "simd_support")] -float_impls! { f64x2, u64x2, f64, u64, 52, 1023 } -#[cfg(feature = "simd_support")] -float_impls! { f64x4, u64x4, f64, u64, 52, 1023 } -#[cfg(feature = "simd_support")] -float_impls! { f64x8, u64x8, f64, u64, 52, 1023 } - - -#[cfg(test)] -mod tests { - use super::*; - use crate::rngs::mock::StepRng; - - const EPSILON32: f32 = ::core::f32::EPSILON; - const EPSILON64: f64 = ::core::f64::EPSILON; - - macro_rules! test_f32 { - ($fnn:ident, $ty:ident, $ZERO:expr, $EPSILON:expr) => { - #[test] - fn $fnn() { - // Standard - let mut zeros = StepRng::new(0, 0); - assert_eq!(zeros.gen::<$ty>(), $ZERO); - let mut one = StepRng::new(1 << 8 | 1 << (8 + 32), 0); - assert_eq!(one.gen::<$ty>(), $EPSILON / 2.0); - let mut max = StepRng::new(!0, 0); - assert_eq!(max.gen::<$ty>(), 1.0 - $EPSILON / 2.0); - - // OpenClosed01 - let mut zeros = StepRng::new(0, 0); - assert_eq!(zeros.sample::<$ty, _>(OpenClosed01), 0.0 + $EPSILON / 2.0); - let mut one = StepRng::new(1 << 8 | 1 << (8 + 32), 0); - assert_eq!(one.sample::<$ty, _>(OpenClosed01), $EPSILON); - let mut max = StepRng::new(!0, 0); - assert_eq!(max.sample::<$ty, _>(OpenClosed01), $ZERO + 1.0); - - // Open01 - let mut zeros = StepRng::new(0, 0); - assert_eq!(zeros.sample::<$ty, _>(Open01), 0.0 + $EPSILON / 2.0); - let mut one = StepRng::new(1 << 9 | 1 << (9 + 32), 0); - assert_eq!(one.sample::<$ty, _>(Open01), $EPSILON / 2.0 * 3.0); - let mut max = StepRng::new(!0, 0); - assert_eq!(max.sample::<$ty, _>(Open01), 1.0 - $EPSILON / 2.0); - } - }; - } - test_f32! { f32_edge_cases, f32, 0.0, EPSILON32 } - #[cfg(feature = "simd_support")] - test_f32! { f32x2_edge_cases, f32x2, f32x2::splat(0.0), f32x2::splat(EPSILON32) } - #[cfg(feature = "simd_support")] - test_f32! { f32x4_edge_cases, f32x4, f32x4::splat(0.0), f32x4::splat(EPSILON32) } - #[cfg(feature = "simd_support")] - test_f32! { f32x8_edge_cases, f32x8, f32x8::splat(0.0), f32x8::splat(EPSILON32) } - #[cfg(feature = "simd_support")] - test_f32! { f32x16_edge_cases, f32x16, f32x16::splat(0.0), f32x16::splat(EPSILON32) } - - macro_rules! test_f64 { - ($fnn:ident, $ty:ident, $ZERO:expr, $EPSILON:expr) => { - #[test] - fn $fnn() { - // Standard - let mut zeros = StepRng::new(0, 0); - assert_eq!(zeros.gen::<$ty>(), $ZERO); - let mut one = StepRng::new(1 << 11, 0); - assert_eq!(one.gen::<$ty>(), $EPSILON / 2.0); - let mut max = StepRng::new(!0, 0); - assert_eq!(max.gen::<$ty>(), 1.0 - $EPSILON / 2.0); - - // OpenClosed01 - let mut zeros = StepRng::new(0, 0); - assert_eq!(zeros.sample::<$ty, _>(OpenClosed01), 0.0 + $EPSILON / 2.0); - let mut one = StepRng::new(1 << 11, 0); - assert_eq!(one.sample::<$ty, _>(OpenClosed01), $EPSILON); - let mut max = StepRng::new(!0, 0); - assert_eq!(max.sample::<$ty, _>(OpenClosed01), $ZERO + 1.0); - - // Open01 - let mut zeros = StepRng::new(0, 0); - assert_eq!(zeros.sample::<$ty, _>(Open01), 0.0 + $EPSILON / 2.0); - let mut one = StepRng::new(1 << 12, 0); - assert_eq!(one.sample::<$ty, _>(Open01), $EPSILON / 2.0 * 3.0); - let mut max = StepRng::new(!0, 0); - assert_eq!(max.sample::<$ty, _>(Open01), 1.0 - $EPSILON / 2.0); - } - }; - } - test_f64! { f64_edge_cases, f64, 0.0, EPSILON64 } - #[cfg(feature = "simd_support")] - test_f64! { f64x2_edge_cases, f64x2, f64x2::splat(0.0), f64x2::splat(EPSILON64) } - #[cfg(feature = "simd_support")] - test_f64! { f64x4_edge_cases, f64x4, f64x4::splat(0.0), f64x4::splat(EPSILON64) } - #[cfg(feature = "simd_support")] - test_f64! { f64x8_edge_cases, f64x8, f64x8::splat(0.0), f64x8::splat(EPSILON64) } - - #[test] - fn value_stability() { - fn test_samples>( - distr: &D, zero: T, expected: &[T], - ) { - let mut rng = crate::test::rng(0x6f44f5646c2a7334); - let mut buf = [zero; 3]; - for x in &mut buf { - *x = rng.sample(&distr); - } - assert_eq!(&buf, expected); - } - - test_samples(&Standard, 0f32, &[0.0035963655, 0.7346052, 0.09778172]); - test_samples(&Standard, 0f64, &[ - 0.7346051961657583, - 0.20298547462974248, - 0.8166436635290655, - ]); - - test_samples(&OpenClosed01, 0f32, &[0.003596425, 0.73460525, 0.09778178]); - test_samples(&OpenClosed01, 0f64, &[ - 0.7346051961657584, - 0.2029854746297426, - 0.8166436635290656, - ]); - - test_samples(&Open01, 0f32, &[0.0035963655, 0.73460525, 0.09778172]); - test_samples(&Open01, 0f64, &[ - 0.7346051961657584, - 0.20298547462974248, - 0.8166436635290656, - ]); - - #[cfg(feature = "simd_support")] - { - // We only test a sub-set of types here. Values are identical to - // non-SIMD types; we assume this pattern continues across all - // SIMD types. - - test_samples(&Standard, f32x2::new(0.0, 0.0), &[ - f32x2::new(0.0035963655, 0.7346052), - f32x2::new(0.09778172, 0.20298547), - f32x2::new(0.34296435, 0.81664366), - ]); - - test_samples(&Standard, f64x2::new(0.0, 0.0), &[ - f64x2::new(0.7346051961657583, 0.20298547462974248), - f64x2::new(0.8166436635290655, 0.7423708925400552), - f64x2::new(0.16387782224016323, 0.9087068770169618), - ]); - } - } -} diff -Nru cargo-0.58.0/vendor/rand/src/distributions/integer.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/integer.rs --- cargo-0.58.0/vendor/rand/src/distributions/integer.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/integer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,279 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The implementations of the `Standard` distribution for integer types. - -use crate::distributions::{Distribution, Standard}; -use crate::Rng; -#[cfg(all(target_arch = "x86", feature = "simd_support"))] -use core::arch::x86::{__m128i, __m256i}; -#[cfg(all(target_arch = "x86_64", feature = "simd_support"))] -use core::arch::x86_64::{__m128i, __m256i}; -#[cfg(not(target_os = "emscripten"))] use core::num::NonZeroU128; -use core::num::{NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; -#[cfg(feature = "simd_support")] use packed_simd::*; - -impl Distribution for Standard { - #[inline] - fn sample(&self, rng: &mut R) -> u8 { - rng.next_u32() as u8 - } -} - -impl Distribution for Standard { - #[inline] - fn sample(&self, rng: &mut R) -> u16 { - rng.next_u32() as u16 - } -} - -impl Distribution for Standard { - #[inline] - fn sample(&self, rng: &mut R) -> u32 { - rng.next_u32() - } -} - -impl Distribution for Standard { - #[inline] - fn sample(&self, rng: &mut R) -> u64 { - rng.next_u64() - } -} - -#[cfg(not(target_os = "emscripten"))] -impl Distribution for Standard { - #[inline] - fn sample(&self, rng: &mut R) -> u128 { - // Use LE; we explicitly generate one value before the next. - let x = u128::from(rng.next_u64()); - let y = u128::from(rng.next_u64()); - (y << 64) | x - } -} - -impl Distribution for Standard { - #[inline] - #[cfg(any(target_pointer_width = "32", target_pointer_width = "16"))] - fn sample(&self, rng: &mut R) -> usize { - rng.next_u32() as usize - } - - #[inline] - #[cfg(target_pointer_width = "64")] - fn sample(&self, rng: &mut R) -> usize { - rng.next_u64() as usize - } -} - -macro_rules! impl_int_from_uint { - ($ty:ty, $uty:ty) => { - impl Distribution<$ty> for Standard { - #[inline] - fn sample(&self, rng: &mut R) -> $ty { - rng.gen::<$uty>() as $ty - } - } - }; -} - -impl_int_from_uint! { i8, u8 } -impl_int_from_uint! { i16, u16 } -impl_int_from_uint! { i32, u32 } -impl_int_from_uint! { i64, u64 } -#[cfg(not(target_os = "emscripten"))] -impl_int_from_uint! { i128, u128 } -impl_int_from_uint! { isize, usize } - -macro_rules! impl_nzint { - ($ty:ty, $new:path) => { - impl Distribution<$ty> for Standard { - fn sample(&self, rng: &mut R) -> $ty { - loop { - if let Some(nz) = $new(rng.gen()) { - break nz; - } - } - } - } - }; -} - -impl_nzint!(NonZeroU8, NonZeroU8::new); -impl_nzint!(NonZeroU16, NonZeroU16::new); -impl_nzint!(NonZeroU32, NonZeroU32::new); -impl_nzint!(NonZeroU64, NonZeroU64::new); -#[cfg(not(target_os = "emscripten"))] -impl_nzint!(NonZeroU128, NonZeroU128::new); -impl_nzint!(NonZeroUsize, NonZeroUsize::new); - -#[cfg(feature = "simd_support")] -macro_rules! simd_impl { - ($(($intrinsic:ident, $vec:ty),)+) => {$( - impl Distribution<$intrinsic> for Standard { - #[inline] - fn sample(&self, rng: &mut R) -> $intrinsic { - $intrinsic::from_bits(rng.gen::<$vec>()) - } - } - )+}; - - ($bits:expr,) => {}; - ($bits:expr, $ty:ty, $($ty_more:ty,)*) => { - simd_impl!($bits, $($ty_more,)*); - - impl Distribution<$ty> for Standard { - #[inline] - fn sample(&self, rng: &mut R) -> $ty { - let mut vec: $ty = Default::default(); - unsafe { - let ptr = &mut vec; - let b_ptr = &mut *(ptr as *mut $ty as *mut [u8; $bits/8]); - rng.fill_bytes(b_ptr); - } - vec.to_le() - } - } - }; -} - -#[cfg(feature = "simd_support")] -simd_impl!(16, u8x2, i8x2,); -#[cfg(feature = "simd_support")] -simd_impl!(32, u8x4, i8x4, u16x2, i16x2,); -#[cfg(feature = "simd_support")] -simd_impl!(64, u8x8, i8x8, u16x4, i16x4, u32x2, i32x2,); -#[cfg(feature = "simd_support")] -simd_impl!(128, u8x16, i8x16, u16x8, i16x8, u32x4, i32x4, u64x2, i64x2,); -#[cfg(feature = "simd_support")] -simd_impl!(256, u8x32, i8x32, u16x16, i16x16, u32x8, i32x8, u64x4, i64x4,); -#[cfg(feature = "simd_support")] -simd_impl!(512, u8x64, i8x64, u16x32, i16x32, u32x16, i32x16, u64x8, i64x8,); -#[cfg(all( - feature = "simd_support", - any(target_arch = "x86", target_arch = "x86_64") -))] -simd_impl!((__m128i, u8x16), (__m256i, u8x32),); - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_integers() { - let mut rng = crate::test::rng(806); - - rng.sample::(Standard); - rng.sample::(Standard); - rng.sample::(Standard); - rng.sample::(Standard); - rng.sample::(Standard); - #[cfg(not(target_os = "emscripten"))] - rng.sample::(Standard); - - rng.sample::(Standard); - rng.sample::(Standard); - rng.sample::(Standard); - rng.sample::(Standard); - rng.sample::(Standard); - #[cfg(not(target_os = "emscripten"))] - rng.sample::(Standard); - } - - #[test] - fn value_stability() { - fn test_samples(zero: T, expected: &[T]) - where Standard: Distribution { - let mut rng = crate::test::rng(807); - let mut buf = [zero; 3]; - for x in &mut buf { - *x = rng.sample(Standard); - } - assert_eq!(&buf, expected); - } - - test_samples(0u8, &[9, 247, 111]); - test_samples(0u16, &[32265, 42999, 38255]); - test_samples(0u32, &[2220326409, 2575017975, 2018088303]); - test_samples(0u64, &[ - 11059617991457472009, - 16096616328739788143, - 1487364411147516184, - ]); - test_samples(0u128, &[ - 296930161868957086625409848350820761097, - 145644820879247630242265036535529306392, - 111087889832015897993126088499035356354, - ]); - #[cfg(any(target_pointer_width = "32", target_pointer_width = "16"))] - test_samples(0usize, &[2220326409, 2575017975, 2018088303]); - #[cfg(target_pointer_width = "64")] - test_samples(0usize, &[ - 11059617991457472009, - 16096616328739788143, - 1487364411147516184, - ]); - - test_samples(0i8, &[9, -9, 111]); - // Skip further i* types: they are simple reinterpretation of u* samples - - #[cfg(feature = "simd_support")] - { - // We only test a sub-set of types here and make assumptions about the rest. - - test_samples(u8x2::default(), &[ - u8x2::new(9, 126), - u8x2::new(247, 167), - u8x2::new(111, 149), - ]); - test_samples(u8x4::default(), &[ - u8x4::new(9, 126, 87, 132), - u8x4::new(247, 167, 123, 153), - u8x4::new(111, 149, 73, 120), - ]); - test_samples(u8x8::default(), &[ - u8x8::new(9, 126, 87, 132, 247, 167, 123, 153), - u8x8::new(111, 149, 73, 120, 68, 171, 98, 223), - u8x8::new(24, 121, 1, 50, 13, 46, 164, 20), - ]); - - test_samples(i64x8::default(), &[ - i64x8::new( - -7387126082252079607, - -2350127744969763473, - 1487364411147516184, - 7895421560427121838, - 602190064936008898, - 6022086574635100741, - -5080089175222015595, - -4066367846667249123, - ), - i64x8::new( - 9180885022207963908, - 3095981199532211089, - 6586075293021332726, - 419343203796414657, - 3186951873057035255, - 5287129228749947252, - 444726432079249540, - -1587028029513790706, - ), - i64x8::new( - 6075236523189346388, - 1351763722368165432, - -6192309979959753740, - -7697775502176768592, - -4482022114172078123, - 7522501477800909500, - -1837258847956201231, - -586926753024886735, - ), - ]); - } - } -} diff -Nru cargo-0.58.0/vendor/rand/src/distributions/mod.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/mod.rs --- cargo-0.58.0/vendor/rand/src/distributions/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,218 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013-2017 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Generating random samples from probability distributions -//! -//! This module is the home of the [`Distribution`] trait and several of its -//! implementations. It is the workhorse behind some of the convenient -//! functionality of the [`Rng`] trait, e.g. [`Rng::gen`] and of course -//! [`Rng::sample`]. -//! -//! Abstractly, a [probability distribution] describes the probability of -//! occurrence of each value in its sample space. -//! -//! More concretely, an implementation of `Distribution` for type `X` is an -//! algorithm for choosing values from the sample space (a subset of `T`) -//! according to the distribution `X` represents, using an external source of -//! randomness (an RNG supplied to the `sample` function). -//! -//! A type `X` may implement `Distribution` for multiple types `T`. -//! Any type implementing [`Distribution`] is stateless (i.e. immutable), -//! but it may have internal parameters set at construction time (for example, -//! [`Uniform`] allows specification of its sample space as a range within `T`). -//! -//! -//! # The `Standard` distribution -//! -//! The [`Standard`] distribution is important to mention. This is the -//! distribution used by [`Rng::gen`] and represents the "default" way to -//! produce a random value for many different types, including most primitive -//! types, tuples, arrays, and a few derived types. See the documentation of -//! [`Standard`] for more details. -//! -//! Implementing `Distribution` for [`Standard`] for user types `T` makes it -//! possible to generate type `T` with [`Rng::gen`], and by extension also -//! with the [`random`] function. -//! -//! ## Random characters -//! -//! [`Alphanumeric`] is a simple distribution to sample random letters and -//! numbers of the `char` type; in contrast [`Standard`] may sample any valid -//! `char`. -//! -//! -//! # Uniform numeric ranges -//! -//! The [`Uniform`] distribution is more flexible than [`Standard`], but also -//! more specialised: it supports fewer target types, but allows the sample -//! space to be specified as an arbitrary range within its target type `T`. -//! Both [`Standard`] and [`Uniform`] are in some sense uniform distributions. -//! -//! Values may be sampled from this distribution using [`Rng::sample(Range)`] or -//! by creating a distribution object with [`Uniform::new`], -//! [`Uniform::new_inclusive`] or `From`. When the range limits are not -//! known at compile time it is typically faster to reuse an existing -//! `Uniform` object than to call [`Rng::sample(Range)`]. -//! -//! User types `T` may also implement `Distribution` for [`Uniform`], -//! although this is less straightforward than for [`Standard`] (see the -//! documentation in the [`uniform`] module). Doing so enables generation of -//! values of type `T` with [`Rng::sample(Range)`]. -//! -//! ## Open and half-open ranges -//! -//! There are surprisingly many ways to uniformly generate random floats. A -//! range between 0 and 1 is standard, but the exact bounds (open vs closed) -//! and accuracy differ. In addition to the [`Standard`] distribution Rand offers -//! [`Open01`] and [`OpenClosed01`]. See "Floating point implementation" section of -//! [`Standard`] documentation for more details. -//! -//! # Non-uniform sampling -//! -//! Sampling a simple true/false outcome with a given probability has a name: -//! the [`Bernoulli`] distribution (this is used by [`Rng::gen_bool`]). -//! -//! For weighted sampling from a sequence of discrete values, use the -//! [`WeightedIndex`] distribution. -//! -//! This crate no longer includes other non-uniform distributions; instead -//! it is recommended that you use either [`rand_distr`] or [`statrs`]. -//! -//! -//! [probability distribution]: https://en.wikipedia.org/wiki/Probability_distribution -//! [`rand_distr`]: https://crates.io/crates/rand_distr -//! [`statrs`]: https://crates.io/crates/statrs - -//! [`random`]: crate::random -//! [`rand_distr`]: https://crates.io/crates/rand_distr -//! [`statrs`]: https://crates.io/crates/statrs - -mod bernoulli; -mod distribution; -mod float; -mod integer; -mod other; -mod slice; -mod utils; -#[cfg(feature = "alloc")] -mod weighted_index; - -#[doc(hidden)] -pub mod hidden_export { - pub use super::float::IntoFloat; // used by rand_distr -} -pub mod uniform; -#[deprecated( - since = "0.8.0", - note = "use rand::distributions::{WeightedIndex, WeightedError} instead" -)] -#[cfg(feature = "alloc")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] -pub mod weighted; - -pub use self::bernoulli::{Bernoulli, BernoulliError}; -pub use self::distribution::{Distribution, DistIter, DistMap}; -#[cfg(feature = "alloc")] -pub use self::distribution::DistString; -pub use self::float::{Open01, OpenClosed01}; -pub use self::other::Alphanumeric; -pub use self::slice::Slice; -#[doc(inline)] -pub use self::uniform::Uniform; -#[cfg(feature = "alloc")] -pub use self::weighted_index::{WeightedError, WeightedIndex}; - -#[allow(unused)] -use crate::Rng; - -/// A generic random value distribution, implemented for many primitive types. -/// Usually generates values with a numerically uniform distribution, and with a -/// range appropriate to the type. -/// -/// ## Provided implementations -/// -/// Assuming the provided `Rng` is well-behaved, these implementations -/// generate values with the following ranges and distributions: -/// -/// * Integers (`i32`, `u32`, `isize`, `usize`, etc.): Uniformly distributed -/// over all values of the type. -/// * `char`: Uniformly distributed over all Unicode scalar values, i.e. all -/// code points in the range `0...0x10_FFFF`, except for the range -/// `0xD800...0xDFFF` (the surrogate code points). This includes -/// unassigned/reserved code points. -/// * `bool`: Generates `false` or `true`, each with probability 0.5. -/// * Floating point types (`f32` and `f64`): Uniformly distributed in the -/// half-open range `[0, 1)`. See notes below. -/// * Wrapping integers (`Wrapping`), besides the type identical to their -/// normal integer variants. -/// -/// The `Standard` distribution also supports generation of the following -/// compound types where all component types are supported: -/// -/// * Tuples (up to 12 elements): each element is generated sequentially. -/// * Arrays (up to 32 elements): each element is generated sequentially; -/// see also [`Rng::fill`] which supports arbitrary array length for integer -/// types and tends to be faster for `u32` and smaller types. -/// When using `rustc` ≥ 1.51, enable the `min_const_gen` feature to support -/// arrays larger than 32 elements. -/// Note that [`Rng::fill`] and `Standard`'s array support are *not* equivalent: -/// the former is optimised for integer types (using fewer RNG calls for -/// element types smaller than the RNG word size), while the latter supports -/// any element type supported by `Standard`. -/// * `Option` first generates a `bool`, and if true generates and returns -/// `Some(value)` where `value: T`, otherwise returning `None`. -/// -/// ## Custom implementations -/// -/// The [`Standard`] distribution may be implemented for user types as follows: -/// -/// ``` -/// # #![allow(dead_code)] -/// use rand::Rng; -/// use rand::distributions::{Distribution, Standard}; -/// -/// struct MyF32 { -/// x: f32, -/// } -/// -/// impl Distribution for Standard { -/// fn sample(&self, rng: &mut R) -> MyF32 { -/// MyF32 { x: rng.gen() } -/// } -/// } -/// ``` -/// -/// ## Example usage -/// ``` -/// use rand::prelude::*; -/// use rand::distributions::Standard; -/// -/// let val: f32 = StdRng::from_entropy().sample(Standard); -/// println!("f32 from [0, 1): {}", val); -/// ``` -/// -/// # Floating point implementation -/// The floating point implementations for `Standard` generate a random value in -/// the half-open interval `[0, 1)`, i.e. including 0 but not 1. -/// -/// All values that can be generated are of the form `n * ε/2`. For `f32` -/// the 24 most significant random bits of a `u32` are used and for `f64` the -/// 53 most significant bits of a `u64` are used. The conversion uses the -/// multiplicative method: `(rng.gen::<$uty>() >> N) as $ty * (ε/2)`. -/// -/// See also: [`Open01`] which samples from `(0, 1)`, [`OpenClosed01`] which -/// samples from `(0, 1]` and `Rng::gen_range(0..1)` which also samples from -/// `[0, 1)`. Note that `Open01` uses transmute-based methods which yield 1 bit -/// less precision but may perform faster on some architectures (on modern Intel -/// CPUs all methods have approximately equal performance). -/// -/// [`Uniform`]: uniform::Uniform -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] -pub struct Standard; diff -Nru cargo-0.58.0/vendor/rand/src/distributions/other.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/other.rs --- cargo-0.58.0/vendor/rand/src/distributions/other.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/other.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,361 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The implementations of the `Standard` distribution for other built-in types. - -use core::char; -use core::num::Wrapping; -#[cfg(feature = "alloc")] -use alloc::string::String; - -use crate::distributions::{Distribution, Standard, Uniform}; -#[cfg(feature = "alloc")] -use crate::distributions::DistString; -use crate::Rng; - -#[cfg(feature = "serde1")] -use serde::{Serialize, Deserialize}; -#[cfg(feature = "min_const_gen")] -use std::mem::{self, MaybeUninit}; - - -// ----- Sampling distributions ----- - -/// Sample a `u8`, uniformly distributed over ASCII letters and numbers: -/// a-z, A-Z and 0-9. -/// -/// # Example -/// -/// ``` -/// use std::iter; -/// use rand::{Rng, thread_rng}; -/// use rand::distributions::Alphanumeric; -/// -/// let mut rng = thread_rng(); -/// let chars: String = iter::repeat(()) -/// .map(|()| rng.sample(Alphanumeric)) -/// .map(char::from) -/// .take(7) -/// .collect(); -/// println!("Random chars: {}", chars); -/// ``` -/// -/// # Passwords -/// -/// Users sometimes ask whether it is safe to use a string of random characters -/// as a password. In principle, all RNGs in Rand implementing `CryptoRng` are -/// suitable as a source of randomness for generating passwords (if they are -/// properly seeded), but it is more conservative to only use randomness -/// directly from the operating system via the `getrandom` crate, or the -/// corresponding bindings of a crypto library. -/// -/// When generating passwords or keys, it is important to consider the threat -/// model and in some cases the memorability of the password. This is out of -/// scope of the Rand project, and therefore we defer to the following -/// references: -/// -/// - [Wikipedia article on Password Strength](https://en.wikipedia.org/wiki/Password_strength) -/// - [Diceware for generating memorable passwords](https://en.wikipedia.org/wiki/Diceware) -#[derive(Debug, Clone, Copy)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub struct Alphanumeric; - - -// ----- Implementations of distributions ----- - -impl Distribution for Standard { - #[inline] - fn sample(&self, rng: &mut R) -> char { - // A valid `char` is either in the interval `[0, 0xD800)` or - // `(0xDFFF, 0x11_0000)`. All `char`s must therefore be in - // `[0, 0x11_0000)` but not in the "gap" `[0xD800, 0xDFFF]` which is - // reserved for surrogates. This is the size of that gap. - const GAP_SIZE: u32 = 0xDFFF - 0xD800 + 1; - - // Uniform::new(0, 0x11_0000 - GAP_SIZE) can also be used but it - // seemed slower. - let range = Uniform::new(GAP_SIZE, 0x11_0000); - - let mut n = range.sample(rng); - if n <= 0xDFFF { - n -= GAP_SIZE; - } - unsafe { char::from_u32_unchecked(n) } - } -} - -/// Note: the `String` is potentially left with excess capacity; optionally the -/// user may call `string.shrink_to_fit()` afterwards. -#[cfg(feature = "alloc")] -impl DistString for Standard { - fn append_string(&self, rng: &mut R, s: &mut String, len: usize) { - // A char is encoded with at most four bytes, thus this reservation is - // guaranteed to be sufficient. We do not shrink_to_fit afterwards so - // that repeated usage on the same `String` buffer does not reallocate. - s.reserve(4 * len); - s.extend(Distribution::::sample_iter(self, rng).take(len)); - } -} - -impl Distribution for Alphanumeric { - fn sample(&self, rng: &mut R) -> u8 { - const RANGE: u32 = 26 + 26 + 10; - const GEN_ASCII_STR_CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ - abcdefghijklmnopqrstuvwxyz\ - 0123456789"; - // We can pick from 62 characters. This is so close to a power of 2, 64, - // that we can do better than `Uniform`. Use a simple bitshift and - // rejection sampling. We do not use a bitmask, because for small RNGs - // the most significant bits are usually of higher quality. - loop { - let var = rng.next_u32() >> (32 - 6); - if var < RANGE { - return GEN_ASCII_STR_CHARSET[var as usize]; - } - } - } -} - -#[cfg(feature = "alloc")] -impl DistString for Alphanumeric { - fn append_string(&self, rng: &mut R, string: &mut String, len: usize) { - unsafe { - let v = string.as_mut_vec(); - v.extend(self.sample_iter(rng).take(len)); - } - } -} - -impl Distribution for Standard { - #[inline] - fn sample(&self, rng: &mut R) -> bool { - // We can compare against an arbitrary bit of an u32 to get a bool. - // Because the least significant bits of a lower quality RNG can have - // simple patterns, we compare against the most significant bit. This is - // easiest done using a sign test. - (rng.next_u32() as i32) < 0 - } -} - -macro_rules! tuple_impl { - // use variables to indicate the arity of the tuple - ($($tyvar:ident),* ) => { - // the trailing commas are for the 1 tuple - impl< $( $tyvar ),* > - Distribution<( $( $tyvar ),* , )> - for Standard - where $( Standard: Distribution<$tyvar> ),* - { - #[inline] - fn sample(&self, _rng: &mut R) -> ( $( $tyvar ),* , ) { - ( - // use the $tyvar's to get the appropriate number of - // repeats (they're not actually needed) - $( - _rng.gen::<$tyvar>() - ),* - , - ) - } - } - } -} - -impl Distribution<()> for Standard { - #[allow(clippy::unused_unit)] - #[inline] - fn sample(&self, _: &mut R) -> () { - () - } -} -tuple_impl! {A} -tuple_impl! {A, B} -tuple_impl! {A, B, C} -tuple_impl! {A, B, C, D} -tuple_impl! {A, B, C, D, E} -tuple_impl! {A, B, C, D, E, F} -tuple_impl! {A, B, C, D, E, F, G} -tuple_impl! {A, B, C, D, E, F, G, H} -tuple_impl! {A, B, C, D, E, F, G, H, I} -tuple_impl! {A, B, C, D, E, F, G, H, I, J} -tuple_impl! {A, B, C, D, E, F, G, H, I, J, K} -tuple_impl! {A, B, C, D, E, F, G, H, I, J, K, L} - -#[cfg(feature = "min_const_gen")] -impl Distribution<[T; N]> for Standard -where Standard: Distribution -{ - #[inline] - fn sample(&self, _rng: &mut R) -> [T; N] { - let mut buff: [MaybeUninit; N] = unsafe { MaybeUninit::uninit().assume_init() }; - - for elem in &mut buff { - *elem = MaybeUninit::new(_rng.gen()); - } - - unsafe { mem::transmute_copy::<_, _>(&buff) } - } -} - -#[cfg(not(feature = "min_const_gen"))] -macro_rules! array_impl { - // recursive, given at least one type parameter: - {$n:expr, $t:ident, $($ts:ident,)*} => { - array_impl!{($n - 1), $($ts,)*} - - impl Distribution<[T; $n]> for Standard where Standard: Distribution { - #[inline] - fn sample(&self, _rng: &mut R) -> [T; $n] { - [_rng.gen::<$t>(), $(_rng.gen::<$ts>()),*] - } - } - }; - // empty case: - {$n:expr,} => { - impl Distribution<[T; $n]> for Standard { - fn sample(&self, _rng: &mut R) -> [T; $n] { [] } - } - }; -} - -#[cfg(not(feature = "min_const_gen"))] -array_impl! {32, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,} - -impl Distribution> for Standard -where Standard: Distribution -{ - #[inline] - fn sample(&self, rng: &mut R) -> Option { - // UFCS is needed here: https://github.com/rust-lang/rust/issues/24066 - if rng.gen::() { - Some(rng.gen()) - } else { - None - } - } -} - -impl Distribution> for Standard -where Standard: Distribution -{ - #[inline] - fn sample(&self, rng: &mut R) -> Wrapping { - Wrapping(rng.gen()) - } -} - - -#[cfg(test)] -mod tests { - use super::*; - use crate::RngCore; - #[cfg(feature = "alloc")] use alloc::string::String; - - #[test] - fn test_misc() { - let rng: &mut dyn RngCore = &mut crate::test::rng(820); - - rng.sample::(Standard); - rng.sample::(Standard); - } - - #[cfg(feature = "alloc")] - #[test] - fn test_chars() { - use core::iter; - let mut rng = crate::test::rng(805); - - // Test by generating a relatively large number of chars, so we also - // take the rejection sampling path. - let word: String = iter::repeat(()) - .map(|()| rng.gen::()) - .take(1000) - .collect(); - assert!(!word.is_empty()); - } - - #[test] - fn test_alphanumeric() { - let mut rng = crate::test::rng(806); - - // Test by generating a relatively large number of chars, so we also - // take the rejection sampling path. - let mut incorrect = false; - for _ in 0..100 { - let c: char = rng.sample(Alphanumeric).into(); - incorrect |= !(('0'..='9').contains(&c) || - ('A'..='Z').contains(&c) || - ('a'..='z').contains(&c) ); - } - assert!(!incorrect); - } - - #[test] - fn value_stability() { - fn test_samples>( - distr: &D, zero: T, expected: &[T], - ) { - let mut rng = crate::test::rng(807); - let mut buf = [zero; 5]; - for x in &mut buf { - *x = rng.sample(&distr); - } - assert_eq!(&buf, expected); - } - - test_samples(&Standard, 'a', &[ - '\u{8cdac}', - '\u{a346a}', - '\u{80120}', - '\u{ed692}', - '\u{35888}', - ]); - test_samples(&Alphanumeric, 0, &[104, 109, 101, 51, 77]); - test_samples(&Standard, false, &[true, true, false, true, false]); - test_samples(&Standard, None as Option, &[ - Some(true), - None, - Some(false), - None, - Some(false), - ]); - test_samples(&Standard, Wrapping(0i32), &[ - Wrapping(-2074640887), - Wrapping(-1719949321), - Wrapping(2018088303), - Wrapping(-547181756), - Wrapping(838957336), - ]); - - // We test only sub-sets of tuple and array impls - test_samples(&Standard, (), &[(), (), (), (), ()]); - test_samples(&Standard, (false,), &[ - (true,), - (true,), - (false,), - (true,), - (false,), - ]); - test_samples(&Standard, (false, false), &[ - (true, true), - (false, true), - (false, false), - (true, false), - (false, false), - ]); - - test_samples(&Standard, [0u8; 0], &[[], [], [], [], []]); - test_samples(&Standard, [0u8; 3], &[ - [9, 247, 111], - [68, 24, 13], - [174, 19, 194], - [172, 69, 213], - [149, 207, 29], - ]); - } -} diff -Nru cargo-0.58.0/vendor/rand/src/distributions/slice.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/slice.rs --- cargo-0.58.0/vendor/rand/src/distributions/slice.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ -// Copyright 2021 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use crate::distributions::{Distribution, Uniform}; - -/// A distribution to sample items uniformly from a slice. -/// -/// [`Slice::new`] constructs a distribution referencing a slice and uniformly -/// samples references from the items in the slice. It may do extra work up -/// front to make sampling of multiple values faster; if only one sample from -/// the slice is required, [`SliceRandom::choose`] can be more efficient. -/// -/// Steps are taken to avoid bias which might be present in naive -/// implementations; for example `slice[rng.gen() % slice.len()]` samples from -/// the slice, but may be more likely to select numbers in the low range than -/// other values. -/// -/// This distribution samples with replacement; each sample is independent. -/// Sampling without replacement requires state to be retained, and therefore -/// cannot be handled by a distribution; you should instead consider methods -/// on [`SliceRandom`], such as [`SliceRandom::choose_multiple`]. -/// -/// # Example -/// -/// ``` -/// use rand::Rng; -/// use rand::distributions::Slice; -/// -/// let vowels = ['a', 'e', 'i', 'o', 'u']; -/// let vowels_dist = Slice::new(&vowels).unwrap(); -/// let rng = rand::thread_rng(); -/// -/// // build a string of 10 vowels -/// let vowel_string: String = rng -/// .sample_iter(&vowels_dist) -/// .take(10) -/// .collect(); -/// -/// println!("{}", vowel_string); -/// assert_eq!(vowel_string.len(), 10); -/// assert!(vowel_string.chars().all(|c| vowels.contains(&c))); -/// ``` -/// -/// For a single sample, [`SliceRandom::choose`][crate::seq::SliceRandom::choose] -/// may be preferred: -/// -/// ``` -/// use rand::seq::SliceRandom; -/// -/// let vowels = ['a', 'e', 'i', 'o', 'u']; -/// let mut rng = rand::thread_rng(); -/// -/// println!("{}", vowels.choose(&mut rng).unwrap()) -/// ``` -/// -/// [`SliceRandom`]: crate::seq::SliceRandom -/// [`SliceRandom::choose`]: crate::seq::SliceRandom::choose -/// [`SliceRandom::choose_multiple`]: crate::seq::SliceRandom::choose_multiple -#[derive(Debug, Clone, Copy)] -pub struct Slice<'a, T> { - slice: &'a [T], - range: Uniform, -} - -impl<'a, T> Slice<'a, T> { - /// Create a new `Slice` instance which samples uniformly from the slice. - /// Returns `Err` if the slice is empty. - pub fn new(slice: &'a [T]) -> Result { - match slice.len() { - 0 => Err(EmptySlice), - len => Ok(Self { - slice, - range: Uniform::new(0, len), - }), - } - } -} - -impl<'a, T> Distribution<&'a T> for Slice<'a, T> { - fn sample(&self, rng: &mut R) -> &'a T { - let idx = self.range.sample(rng); - - debug_assert!( - idx < self.slice.len(), - "Uniform::new(0, {}) somehow returned {}", - self.slice.len(), - idx - ); - - // Safety: at construction time, it was ensured that the slice was - // non-empty, and that the `Uniform` range produces values in range - // for the slice - unsafe { self.slice.get_unchecked(idx) } - } -} - -/// Error type indicating that a [`Slice`] distribution was improperly -/// constructed with an empty slice. -#[derive(Debug, Clone, Copy)] -pub struct EmptySlice; - -impl core::fmt::Display for EmptySlice { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!( - f, - "Tried to create a `distributions::Slice` with an empty slice" - ) - } -} - -#[cfg(feature = "std")] -impl std::error::Error for EmptySlice {} diff -Nru cargo-0.58.0/vendor/rand/src/distributions/uniform.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/uniform.rs --- cargo-0.58.0/vendor/rand/src/distributions/uniform.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/uniform.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,1653 +0,0 @@ -// Copyright 2018-2020 Developers of the Rand project. -// Copyright 2017 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A distribution uniformly sampling numbers within a given range. -//! -//! [`Uniform`] is the standard distribution to sample uniformly from a range; -//! e.g. `Uniform::new_inclusive(1, 6)` can sample integers from 1 to 6, like a -//! standard die. [`Rng::gen_range`] supports any type supported by -//! [`Uniform`]. -//! -//! This distribution is provided with support for several primitive types -//! (all integer and floating-point types) as well as [`std::time::Duration`], -//! and supports extension to user-defined types via a type-specific *back-end* -//! implementation. -//! -//! The types [`UniformInt`], [`UniformFloat`] and [`UniformDuration`] are the -//! back-ends supporting sampling from primitive integer and floating-point -//! ranges as well as from [`std::time::Duration`]; these types do not normally -//! need to be used directly (unless implementing a derived back-end). -//! -//! # Example usage -//! -//! ``` -//! use rand::{Rng, thread_rng}; -//! use rand::distributions::Uniform; -//! -//! let mut rng = thread_rng(); -//! let side = Uniform::new(-10.0, 10.0); -//! -//! // sample between 1 and 10 points -//! for _ in 0..rng.gen_range(1..=10) { -//! // sample a point from the square with sides -10 - 10 in two dimensions -//! let (x, y) = (rng.sample(side), rng.sample(side)); -//! println!("Point: {}, {}", x, y); -//! } -//! ``` -//! -//! # Extending `Uniform` to support a custom type -//! -//! To extend [`Uniform`] to support your own types, write a back-end which -//! implements the [`UniformSampler`] trait, then implement the [`SampleUniform`] -//! helper trait to "register" your back-end. See the `MyF32` example below. -//! -//! At a minimum, the back-end needs to store any parameters needed for sampling -//! (e.g. the target range) and implement `new`, `new_inclusive` and `sample`. -//! Those methods should include an assert to check the range is valid (i.e. -//! `low < high`). The example below merely wraps another back-end. -//! -//! The `new`, `new_inclusive` and `sample_single` functions use arguments of -//! type SampleBorrow in order to support passing in values by reference or -//! by value. In the implementation of these functions, you can choose to -//! simply use the reference returned by [`SampleBorrow::borrow`], or you can choose -//! to copy or clone the value, whatever is appropriate for your type. -//! -//! ``` -//! use rand::prelude::*; -//! use rand::distributions::uniform::{Uniform, SampleUniform, -//! UniformSampler, UniformFloat, SampleBorrow}; -//! -//! struct MyF32(f32); -//! -//! #[derive(Clone, Copy, Debug)] -//! struct UniformMyF32(UniformFloat); -//! -//! impl UniformSampler for UniformMyF32 { -//! type X = MyF32; -//! fn new(low: B1, high: B2) -> Self -//! where B1: SampleBorrow + Sized, -//! B2: SampleBorrow + Sized -//! { -//! UniformMyF32(UniformFloat::::new(low.borrow().0, high.borrow().0)) -//! } -//! fn new_inclusive(low: B1, high: B2) -> Self -//! where B1: SampleBorrow + Sized, -//! B2: SampleBorrow + Sized -//! { -//! UniformSampler::new(low, high) -//! } -//! fn sample(&self, rng: &mut R) -> Self::X { -//! MyF32(self.0.sample(rng)) -//! } -//! } -//! -//! impl SampleUniform for MyF32 { -//! type Sampler = UniformMyF32; -//! } -//! -//! let (low, high) = (MyF32(17.0f32), MyF32(22.0f32)); -//! let uniform = Uniform::new(low, high); -//! let x = uniform.sample(&mut thread_rng()); -//! ``` -//! -//! [`SampleUniform`]: crate::distributions::uniform::SampleUniform -//! [`UniformSampler`]: crate::distributions::uniform::UniformSampler -//! [`UniformInt`]: crate::distributions::uniform::UniformInt -//! [`UniformFloat`]: crate::distributions::uniform::UniformFloat -//! [`UniformDuration`]: crate::distributions::uniform::UniformDuration -//! [`SampleBorrow::borrow`]: crate::distributions::uniform::SampleBorrow::borrow - -#[cfg(not(feature = "std"))] use core::time::Duration; -#[cfg(feature = "std")] use std::time::Duration; -use core::ops::{Range, RangeInclusive}; - -use crate::distributions::float::IntoFloat; -use crate::distributions::utils::{BoolAsSIMD, FloatAsSIMD, FloatSIMDUtils, WideningMultiply}; -use crate::distributions::Distribution; -use crate::{Rng, RngCore}; - -#[cfg(not(feature = "std"))] -#[allow(unused_imports)] // rustc doesn't detect that this is actually used -use crate::distributions::utils::Float; - -#[cfg(feature = "simd_support")] use packed_simd::*; - -#[cfg(feature = "serde1")] -use serde::{Serialize, Deserialize}; - -/// Sample values uniformly between two bounds. -/// -/// [`Uniform::new`] and [`Uniform::new_inclusive`] construct a uniform -/// distribution sampling from the given range; these functions may do extra -/// work up front to make sampling of multiple values faster. If only one sample -/// from the range is required, [`Rng::gen_range`] can be more efficient. -/// -/// When sampling from a constant range, many calculations can happen at -/// compile-time and all methods should be fast; for floating-point ranges and -/// the full range of integer types this should have comparable performance to -/// the `Standard` distribution. -/// -/// Steps are taken to avoid bias which might be present in naive -/// implementations; for example `rng.gen::() % 170` samples from the range -/// `[0, 169]` but is twice as likely to select numbers less than 85 than other -/// values. Further, the implementations here give more weight to the high-bits -/// generated by the RNG than the low bits, since with some RNGs the low-bits -/// are of lower quality than the high bits. -/// -/// Implementations must sample in `[low, high)` range for -/// `Uniform::new(low, high)`, i.e., excluding `high`. In particular, care must -/// be taken to ensure that rounding never results values `< low` or `>= high`. -/// -/// # Example -/// -/// ``` -/// use rand::distributions::{Distribution, Uniform}; -/// -/// let between = Uniform::from(10..10000); -/// let mut rng = rand::thread_rng(); -/// let mut sum = 0; -/// for _ in 0..1000 { -/// sum += between.sample(&mut rng); -/// } -/// println!("{}", sum); -/// ``` -/// -/// For a single sample, [`Rng::gen_range`] may be prefered: -/// -/// ``` -/// use rand::Rng; -/// -/// let mut rng = rand::thread_rng(); -/// println!("{}", rng.gen_range(0..10)); -/// ``` -/// -/// [`new`]: Uniform::new -/// [`new_inclusive`]: Uniform::new_inclusive -/// [`Rng::gen_range`]: Rng::gen_range -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub struct Uniform(X::Sampler); - -impl Uniform { - /// Create a new `Uniform` instance which samples uniformly from the half - /// open range `[low, high)` (excluding `high`). Panics if `low >= high`. - pub fn new(low: B1, high: B2) -> Uniform - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - Uniform(X::Sampler::new(low, high)) - } - - /// Create a new `Uniform` instance which samples uniformly from the closed - /// range `[low, high]` (inclusive). Panics if `low > high`. - pub fn new_inclusive(low: B1, high: B2) -> Uniform - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - Uniform(X::Sampler::new_inclusive(low, high)) - } -} - -impl Distribution for Uniform { - fn sample(&self, rng: &mut R) -> X { - self.0.sample(rng) - } -} - -/// Helper trait for creating objects using the correct implementation of -/// [`UniformSampler`] for the sampling type. -/// -/// See the [module documentation] on how to implement [`Uniform`] range -/// sampling for a custom type. -/// -/// [module documentation]: crate::distributions::uniform -pub trait SampleUniform: Sized { - /// The `UniformSampler` implementation supporting type `X`. - type Sampler: UniformSampler; -} - -/// Helper trait handling actual uniform sampling. -/// -/// See the [module documentation] on how to implement [`Uniform`] range -/// sampling for a custom type. -/// -/// Implementation of [`sample_single`] is optional, and is only useful when -/// the implementation can be faster than `Self::new(low, high).sample(rng)`. -/// -/// [module documentation]: crate::distributions::uniform -/// [`sample_single`]: UniformSampler::sample_single -pub trait UniformSampler: Sized { - /// The type sampled by this implementation. - type X; - - /// Construct self, with inclusive lower bound and exclusive upper bound - /// `[low, high)`. - /// - /// Usually users should not call this directly but instead use - /// `Uniform::new`, which asserts that `low < high` before calling this. - fn new(low: B1, high: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized; - - /// Construct self, with inclusive bounds `[low, high]`. - /// - /// Usually users should not call this directly but instead use - /// `Uniform::new_inclusive`, which asserts that `low <= high` before - /// calling this. - fn new_inclusive(low: B1, high: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized; - - /// Sample a value. - fn sample(&self, rng: &mut R) -> Self::X; - - /// Sample a single value uniformly from a range with inclusive lower bound - /// and exclusive upper bound `[low, high)`. - /// - /// By default this is implemented using - /// `UniformSampler::new(low, high).sample(rng)`. However, for some types - /// more optimal implementations for single usage may be provided via this - /// method (which is the case for integers and floats). - /// Results may not be identical. - /// - /// Note that to use this method in a generic context, the type needs to be - /// retrieved via `SampleUniform::Sampler` as follows: - /// ``` - /// use rand::{thread_rng, distributions::uniform::{SampleUniform, UniformSampler}}; - /// # #[allow(unused)] - /// fn sample_from_range(lb: T, ub: T) -> T { - /// let mut rng = thread_rng(); - /// ::Sampler::sample_single(lb, ub, &mut rng) - /// } - /// ``` - fn sample_single(low: B1, high: B2, rng: &mut R) -> Self::X - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let uniform: Self = UniformSampler::new(low, high); - uniform.sample(rng) - } - - /// Sample a single value uniformly from a range with inclusive lower bound - /// and inclusive upper bound `[low, high]`. - /// - /// By default this is implemented using - /// `UniformSampler::new_inclusive(low, high).sample(rng)`. However, for - /// some types more optimal implementations for single usage may be provided - /// via this method. - /// Results may not be identical. - fn sample_single_inclusive(low: B1, high: B2, rng: &mut R) - -> Self::X - where B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized - { - let uniform: Self = UniformSampler::new_inclusive(low, high); - uniform.sample(rng) - } -} - -impl From> for Uniform { - fn from(r: ::core::ops::Range) -> Uniform { - Uniform::new(r.start, r.end) - } -} - -impl From> for Uniform { - fn from(r: ::core::ops::RangeInclusive) -> Uniform { - Uniform::new_inclusive(r.start(), r.end()) - } -} - - -/// Helper trait similar to [`Borrow`] but implemented -/// only for SampleUniform and references to SampleUniform in -/// order to resolve ambiguity issues. -/// -/// [`Borrow`]: std::borrow::Borrow -pub trait SampleBorrow { - /// Immutably borrows from an owned value. See [`Borrow::borrow`] - /// - /// [`Borrow::borrow`]: std::borrow::Borrow::borrow - fn borrow(&self) -> &Borrowed; -} -impl SampleBorrow for Borrowed -where Borrowed: SampleUniform -{ - #[inline(always)] - fn borrow(&self) -> &Borrowed { - self - } -} -impl<'a, Borrowed> SampleBorrow for &'a Borrowed -where Borrowed: SampleUniform -{ - #[inline(always)] - fn borrow(&self) -> &Borrowed { - *self - } -} - -/// Range that supports generating a single sample efficiently. -/// -/// Any type implementing this trait can be used to specify the sampled range -/// for `Rng::gen_range`. -pub trait SampleRange { - /// Generate a sample from the given range. - fn sample_single(self, rng: &mut R) -> T; - - /// Check whether the range is empty. - fn is_empty(&self) -> bool; -} - -impl SampleRange for Range { - #[inline] - fn sample_single(self, rng: &mut R) -> T { - T::Sampler::sample_single(self.start, self.end, rng) - } - - #[inline] - fn is_empty(&self) -> bool { - !(self.start < self.end) - } -} - -impl SampleRange for RangeInclusive { - #[inline] - fn sample_single(self, rng: &mut R) -> T { - T::Sampler::sample_single_inclusive(self.start(), self.end(), rng) - } - - #[inline] - fn is_empty(&self) -> bool { - !(self.start() <= self.end()) - } -} - - -//////////////////////////////////////////////////////////////////////////////// - -// What follows are all back-ends. - - -/// The back-end implementing [`UniformSampler`] for integer types. -/// -/// Unless you are implementing [`UniformSampler`] for your own type, this type -/// should not be used directly, use [`Uniform`] instead. -/// -/// # Implementation notes -/// -/// For simplicity, we use the same generic struct `UniformInt` for all -/// integer types `X`. This gives us only one field type, `X`; to store unsigned -/// values of this size, we take use the fact that these conversions are no-ops. -/// -/// For a closed range, the number of possible numbers we should generate is -/// `range = (high - low + 1)`. To avoid bias, we must ensure that the size of -/// our sample space, `zone`, is a multiple of `range`; other values must be -/// rejected (by replacing with a new random sample). -/// -/// As a special case, we use `range = 0` to represent the full range of the -/// result type (i.e. for `new_inclusive($ty::MIN, $ty::MAX)`). -/// -/// The optimum `zone` is the largest product of `range` which fits in our -/// (unsigned) target type. We calculate this by calculating how many numbers we -/// must reject: `reject = (MAX + 1) % range = (MAX - range + 1) % range`. Any (large) -/// product of `range` will suffice, thus in `sample_single` we multiply by a -/// power of 2 via bit-shifting (faster but may cause more rejections). -/// -/// The smallest integer PRNGs generate is `u32`. For 8- and 16-bit outputs we -/// use `u32` for our `zone` and samples (because it's not slower and because -/// it reduces the chance of having to reject a sample). In this case we cannot -/// store `zone` in the target type since it is too large, however we know -/// `ints_to_reject < range <= $unsigned::MAX`. -/// -/// An alternative to using a modulus is widening multiply: After a widening -/// multiply by `range`, the result is in the high word. Then comparing the low -/// word against `zone` makes sure our distribution is uniform. -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub struct UniformInt { - low: X, - range: X, - z: X, // either ints_to_reject or zone depending on implementation -} - -macro_rules! uniform_int_impl { - ($ty:ty, $unsigned:ident, $u_large:ident) => { - impl SampleUniform for $ty { - type Sampler = UniformInt<$ty>; - } - - impl UniformSampler for UniformInt<$ty> { - // We play free and fast with unsigned vs signed here - // (when $ty is signed), but that's fine, since the - // contract of this macro is for $ty and $unsigned to be - // "bit-equal", so casting between them is a no-op. - - type X = $ty; - - #[inline] // if the range is constant, this helps LLVM to do the - // calculations at compile-time. - fn new(low_b: B1, high_b: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - assert!(low < high, "Uniform::new called with `low >= high`"); - UniformSampler::new_inclusive(low, high - 1) - } - - #[inline] // if the range is constant, this helps LLVM to do the - // calculations at compile-time. - fn new_inclusive(low_b: B1, high_b: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - assert!( - low <= high, - "Uniform::new_inclusive called with `low > high`" - ); - let unsigned_max = ::core::$u_large::MAX; - - let range = high.wrapping_sub(low).wrapping_add(1) as $unsigned; - let ints_to_reject = if range > 0 { - let range = $u_large::from(range); - (unsigned_max - range + 1) % range - } else { - 0 - }; - - UniformInt { - low, - // These are really $unsigned values, but store as $ty: - range: range as $ty, - z: ints_to_reject as $unsigned as $ty, - } - } - - #[inline] - fn sample(&self, rng: &mut R) -> Self::X { - let range = self.range as $unsigned as $u_large; - if range > 0 { - let unsigned_max = ::core::$u_large::MAX; - let zone = unsigned_max - (self.z as $unsigned as $u_large); - loop { - let v: $u_large = rng.gen(); - let (hi, lo) = v.wmul(range); - if lo <= zone { - return self.low.wrapping_add(hi as $ty); - } - } - } else { - // Sample from the entire integer range. - rng.gen() - } - } - - #[inline] - fn sample_single(low_b: B1, high_b: B2, rng: &mut R) -> Self::X - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - assert!(low < high, "UniformSampler::sample_single: low >= high"); - Self::sample_single_inclusive(low, high - 1, rng) - } - - #[inline] - fn sample_single_inclusive(low_b: B1, high_b: B2, rng: &mut R) -> Self::X - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - assert!(low <= high, "UniformSampler::sample_single_inclusive: low > high"); - let range = high.wrapping_sub(low).wrapping_add(1) as $unsigned as $u_large; - // If the above resulted in wrap-around to 0, the range is $ty::MIN..=$ty::MAX, - // and any integer will do. - if range == 0 { - return rng.gen(); - } - - let zone = if ::core::$unsigned::MAX <= ::core::u16::MAX as $unsigned { - // Using a modulus is faster than the approximation for - // i8 and i16. I suppose we trade the cost of one - // modulus for near-perfect branch prediction. - let unsigned_max: $u_large = ::core::$u_large::MAX; - let ints_to_reject = (unsigned_max - range + 1) % range; - unsigned_max - ints_to_reject - } else { - // conservative but fast approximation. `- 1` is necessary to allow the - // same comparison without bias. - (range << range.leading_zeros()).wrapping_sub(1) - }; - - loop { - let v: $u_large = rng.gen(); - let (hi, lo) = v.wmul(range); - if lo <= zone { - return low.wrapping_add(hi as $ty); - } - } - } - } - }; -} - -uniform_int_impl! { i8, u8, u32 } -uniform_int_impl! { i16, u16, u32 } -uniform_int_impl! { i32, u32, u32 } -uniform_int_impl! { i64, u64, u64 } -#[cfg(not(target_os = "emscripten"))] -uniform_int_impl! { i128, u128, u128 } -uniform_int_impl! { isize, usize, usize } -uniform_int_impl! { u8, u8, u32 } -uniform_int_impl! { u16, u16, u32 } -uniform_int_impl! { u32, u32, u32 } -uniform_int_impl! { u64, u64, u64 } -uniform_int_impl! { usize, usize, usize } -#[cfg(not(target_os = "emscripten"))] -uniform_int_impl! { u128, u128, u128 } - -#[cfg(feature = "simd_support")] -macro_rules! uniform_simd_int_impl { - ($ty:ident, $unsigned:ident, $u_scalar:ident) => { - // The "pick the largest zone that can fit in an `u32`" optimization - // is less useful here. Multiple lanes complicate things, we don't - // know the PRNG's minimal output size, and casting to a larger vector - // is generally a bad idea for SIMD performance. The user can still - // implement it manually. - - // TODO: look into `Uniform::::new(0u32, 100)` functionality - // perhaps `impl SampleUniform for $u_scalar`? - impl SampleUniform for $ty { - type Sampler = UniformInt<$ty>; - } - - impl UniformSampler for UniformInt<$ty> { - type X = $ty; - - #[inline] // if the range is constant, this helps LLVM to do the - // calculations at compile-time. - fn new(low_b: B1, high_b: B2) -> Self - where B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - assert!(low.lt(high).all(), "Uniform::new called with `low >= high`"); - UniformSampler::new_inclusive(low, high - 1) - } - - #[inline] // if the range is constant, this helps LLVM to do the - // calculations at compile-time. - fn new_inclusive(low_b: B1, high_b: B2) -> Self - where B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - assert!(low.le(high).all(), - "Uniform::new_inclusive called with `low > high`"); - let unsigned_max = ::core::$u_scalar::MAX; - - // NOTE: these may need to be replaced with explicitly - // wrapping operations if `packed_simd` changes - let range: $unsigned = ((high - low) + 1).cast(); - // `% 0` will panic at runtime. - let not_full_range = range.gt($unsigned::splat(0)); - // replacing 0 with `unsigned_max` allows a faster `select` - // with bitwise OR - let modulo = not_full_range.select(range, $unsigned::splat(unsigned_max)); - // wrapping addition - let ints_to_reject = (unsigned_max - range + 1) % modulo; - // When `range` is 0, `lo` of `v.wmul(range)` will always be - // zero which means only one sample is needed. - let zone = unsigned_max - ints_to_reject; - - UniformInt { - low, - // These are really $unsigned values, but store as $ty: - range: range.cast(), - z: zone.cast(), - } - } - - fn sample(&self, rng: &mut R) -> Self::X { - let range: $unsigned = self.range.cast(); - let zone: $unsigned = self.z.cast(); - - // This might seem very slow, generating a whole new - // SIMD vector for every sample rejection. For most uses - // though, the chance of rejection is small and provides good - // general performance. With multiple lanes, that chance is - // multiplied. To mitigate this, we replace only the lanes of - // the vector which fail, iteratively reducing the chance of - // rejection. The replacement method does however add a little - // overhead. Benchmarking or calculating probabilities might - // reveal contexts where this replacement method is slower. - let mut v: $unsigned = rng.gen(); - loop { - let (hi, lo) = v.wmul(range); - let mask = lo.le(zone); - if mask.all() { - let hi: $ty = hi.cast(); - // wrapping addition - let result = self.low + hi; - // `select` here compiles to a blend operation - // When `range.eq(0).none()` the compare and blend - // operations are avoided. - let v: $ty = v.cast(); - return range.gt($unsigned::splat(0)).select(result, v); - } - // Replace only the failing lanes - v = mask.select(v, rng.gen()); - } - } - } - }; - - // bulk implementation - ($(($unsigned:ident, $signed:ident),)+ $u_scalar:ident) => { - $( - uniform_simd_int_impl!($unsigned, $unsigned, $u_scalar); - uniform_simd_int_impl!($signed, $unsigned, $u_scalar); - )+ - }; -} - -#[cfg(feature = "simd_support")] -uniform_simd_int_impl! { - (u64x2, i64x2), - (u64x4, i64x4), - (u64x8, i64x8), - u64 -} - -#[cfg(feature = "simd_support")] -uniform_simd_int_impl! { - (u32x2, i32x2), - (u32x4, i32x4), - (u32x8, i32x8), - (u32x16, i32x16), - u32 -} - -#[cfg(feature = "simd_support")] -uniform_simd_int_impl! { - (u16x2, i16x2), - (u16x4, i16x4), - (u16x8, i16x8), - (u16x16, i16x16), - (u16x32, i16x32), - u16 -} - -#[cfg(feature = "simd_support")] -uniform_simd_int_impl! { - (u8x2, i8x2), - (u8x4, i8x4), - (u8x8, i8x8), - (u8x16, i8x16), - (u8x32, i8x32), - (u8x64, i8x64), - u8 -} - -impl SampleUniform for char { - type Sampler = UniformChar; -} - -/// The back-end implementing [`UniformSampler`] for `char`. -/// -/// Unless you are implementing [`UniformSampler`] for your own type, this type -/// should not be used directly, use [`Uniform`] instead. -/// -/// This differs from integer range sampling since the range `0xD800..=0xDFFF` -/// are used for surrogate pairs in UCS and UTF-16, and consequently are not -/// valid Unicode code points. We must therefore avoid sampling values in this -/// range. -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub struct UniformChar { - sampler: UniformInt, -} - -/// UTF-16 surrogate range start -const CHAR_SURROGATE_START: u32 = 0xD800; -/// UTF-16 surrogate range size -const CHAR_SURROGATE_LEN: u32 = 0xE000 - CHAR_SURROGATE_START; - -/// Convert `char` to compressed `u32` -fn char_to_comp_u32(c: char) -> u32 { - match c as u32 { - c if c >= CHAR_SURROGATE_START => c - CHAR_SURROGATE_LEN, - c => c, - } -} - -impl UniformSampler for UniformChar { - type X = char; - - #[inline] // if the range is constant, this helps LLVM to do the - // calculations at compile-time. - fn new(low_b: B1, high_b: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = char_to_comp_u32(*low_b.borrow()); - let high = char_to_comp_u32(*high_b.borrow()); - let sampler = UniformInt::::new(low, high); - UniformChar { sampler } - } - - #[inline] // if the range is constant, this helps LLVM to do the - // calculations at compile-time. - fn new_inclusive(low_b: B1, high_b: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = char_to_comp_u32(*low_b.borrow()); - let high = char_to_comp_u32(*high_b.borrow()); - let sampler = UniformInt::::new_inclusive(low, high); - UniformChar { sampler } - } - - fn sample(&self, rng: &mut R) -> Self::X { - let mut x = self.sampler.sample(rng); - if x >= CHAR_SURROGATE_START { - x += CHAR_SURROGATE_LEN; - } - // SAFETY: x must not be in surrogate range or greater than char::MAX. - // This relies on range constructors which accept char arguments. - // Validity of input char values is assumed. - unsafe { core::char::from_u32_unchecked(x) } - } -} - -/// The back-end implementing [`UniformSampler`] for floating-point types. -/// -/// Unless you are implementing [`UniformSampler`] for your own type, this type -/// should not be used directly, use [`Uniform`] instead. -/// -/// # Implementation notes -/// -/// Instead of generating a float in the `[0, 1)` range using [`Standard`], the -/// `UniformFloat` implementation converts the output of an PRNG itself. This -/// way one or two steps can be optimized out. -/// -/// The floats are first converted to a value in the `[1, 2)` interval using a -/// transmute-based method, and then mapped to the expected range with a -/// multiply and addition. Values produced this way have what equals 23 bits of -/// random digits for an `f32`, and 52 for an `f64`. -/// -/// [`new`]: UniformSampler::new -/// [`new_inclusive`]: UniformSampler::new_inclusive -/// [`Standard`]: crate::distributions::Standard -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub struct UniformFloat { - low: X, - scale: X, -} - -macro_rules! uniform_float_impl { - ($ty:ty, $uty:ident, $f_scalar:ident, $u_scalar:ident, $bits_to_discard:expr) => { - impl SampleUniform for $ty { - type Sampler = UniformFloat<$ty>; - } - - impl UniformSampler for UniformFloat<$ty> { - type X = $ty; - - fn new(low_b: B1, high_b: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - debug_assert!( - low.all_finite(), - "Uniform::new called with `low` non-finite." - ); - debug_assert!( - high.all_finite(), - "Uniform::new called with `high` non-finite." - ); - assert!(low.all_lt(high), "Uniform::new called with `low >= high`"); - let max_rand = <$ty>::splat( - (::core::$u_scalar::MAX >> $bits_to_discard).into_float_with_exponent(0) - 1.0, - ); - - let mut scale = high - low; - assert!(scale.all_finite(), "Uniform::new: range overflow"); - - loop { - let mask = (scale * max_rand + low).ge_mask(high); - if mask.none() { - break; - } - scale = scale.decrease_masked(mask); - } - - debug_assert!(<$ty>::splat(0.0).all_le(scale)); - - UniformFloat { low, scale } - } - - fn new_inclusive(low_b: B1, high_b: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - debug_assert!( - low.all_finite(), - "Uniform::new_inclusive called with `low` non-finite." - ); - debug_assert!( - high.all_finite(), - "Uniform::new_inclusive called with `high` non-finite." - ); - assert!( - low.all_le(high), - "Uniform::new_inclusive called with `low > high`" - ); - let max_rand = <$ty>::splat( - (::core::$u_scalar::MAX >> $bits_to_discard).into_float_with_exponent(0) - 1.0, - ); - - let mut scale = (high - low) / max_rand; - assert!(scale.all_finite(), "Uniform::new_inclusive: range overflow"); - - loop { - let mask = (scale * max_rand + low).gt_mask(high); - if mask.none() { - break; - } - scale = scale.decrease_masked(mask); - } - - debug_assert!(<$ty>::splat(0.0).all_le(scale)); - - UniformFloat { low, scale } - } - - fn sample(&self, rng: &mut R) -> Self::X { - // Generate a value in the range [1, 2) - let value1_2 = (rng.gen::<$uty>() >> $bits_to_discard).into_float_with_exponent(0); - - // Get a value in the range [0, 1) in order to avoid - // overflowing into infinity when multiplying with scale - let value0_1 = value1_2 - 1.0; - - // We don't use `f64::mul_add`, because it is not available with - // `no_std`. Furthermore, it is slower for some targets (but - // faster for others). However, the order of multiplication and - // addition is important, because on some platforms (e.g. ARM) - // it will be optimized to a single (non-FMA) instruction. - value0_1 * self.scale + self.low - } - - #[inline] - fn sample_single(low_b: B1, high_b: B2, rng: &mut R) -> Self::X - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - debug_assert!( - low.all_finite(), - "UniformSampler::sample_single called with `low` non-finite." - ); - debug_assert!( - high.all_finite(), - "UniformSampler::sample_single called with `high` non-finite." - ); - assert!( - low.all_lt(high), - "UniformSampler::sample_single: low >= high" - ); - let mut scale = high - low; - assert!(scale.all_finite(), "UniformSampler::sample_single: range overflow"); - - loop { - // Generate a value in the range [1, 2) - let value1_2 = - (rng.gen::<$uty>() >> $bits_to_discard).into_float_with_exponent(0); - - // Get a value in the range [0, 1) in order to avoid - // overflowing into infinity when multiplying with scale - let value0_1 = value1_2 - 1.0; - - // Doing multiply before addition allows some architectures - // to use a single instruction. - let res = value0_1 * scale + low; - - debug_assert!(low.all_le(res) || !scale.all_finite()); - if res.all_lt(high) { - return res; - } - - // This handles a number of edge cases. - // * `low` or `high` is NaN. In this case `scale` and - // `res` are going to end up as NaN. - // * `low` is negative infinity and `high` is finite. - // `scale` is going to be infinite and `res` will be - // NaN. - // * `high` is positive infinity and `low` is finite. - // `scale` is going to be infinite and `res` will - // be infinite or NaN (if value0_1 is 0). - // * `low` is negative infinity and `high` is positive - // infinity. `scale` will be infinite and `res` will - // be NaN. - // * `low` and `high` are finite, but `high - low` - // overflows to infinite. `scale` will be infinite - // and `res` will be infinite or NaN (if value0_1 is 0). - // So if `high` or `low` are non-finite, we are guaranteed - // to fail the `res < high` check above and end up here. - // - // While we technically should check for non-finite `low` - // and `high` before entering the loop, by doing the checks - // here instead, we allow the common case to avoid these - // checks. But we are still guaranteed that if `low` or - // `high` are non-finite we'll end up here and can do the - // appropriate checks. - // - // Likewise `high - low` overflowing to infinity is also - // rare, so handle it here after the common case. - let mask = !scale.finite_mask(); - if mask.any() { - assert!( - low.all_finite() && high.all_finite(), - "Uniform::sample_single: low and high must be finite" - ); - scale = scale.decrease_masked(mask); - } - } - } - } - }; -} - -uniform_float_impl! { f32, u32, f32, u32, 32 - 23 } -uniform_float_impl! { f64, u64, f64, u64, 64 - 52 } - -#[cfg(feature = "simd_support")] -uniform_float_impl! { f32x2, u32x2, f32, u32, 32 - 23 } -#[cfg(feature = "simd_support")] -uniform_float_impl! { f32x4, u32x4, f32, u32, 32 - 23 } -#[cfg(feature = "simd_support")] -uniform_float_impl! { f32x8, u32x8, f32, u32, 32 - 23 } -#[cfg(feature = "simd_support")] -uniform_float_impl! { f32x16, u32x16, f32, u32, 32 - 23 } - -#[cfg(feature = "simd_support")] -uniform_float_impl! { f64x2, u64x2, f64, u64, 64 - 52 } -#[cfg(feature = "simd_support")] -uniform_float_impl! { f64x4, u64x4, f64, u64, 64 - 52 } -#[cfg(feature = "simd_support")] -uniform_float_impl! { f64x8, u64x8, f64, u64, 64 - 52 } - - -/// The back-end implementing [`UniformSampler`] for `Duration`. -/// -/// Unless you are implementing [`UniformSampler`] for your own types, this type -/// should not be used directly, use [`Uniform`] instead. -#[derive(Clone, Copy, Debug)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub struct UniformDuration { - mode: UniformDurationMode, - offset: u32, -} - -#[derive(Debug, Copy, Clone)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -enum UniformDurationMode { - Small { - secs: u64, - nanos: Uniform, - }, - Medium { - nanos: Uniform, - }, - Large { - max_secs: u64, - max_nanos: u32, - secs: Uniform, - }, -} - -impl SampleUniform for Duration { - type Sampler = UniformDuration; -} - -impl UniformSampler for UniformDuration { - type X = Duration; - - #[inline] - fn new(low_b: B1, high_b: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - assert!(low < high, "Uniform::new called with `low >= high`"); - UniformDuration::new_inclusive(low, high - Duration::new(0, 1)) - } - - #[inline] - fn new_inclusive(low_b: B1, high_b: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - let low = *low_b.borrow(); - let high = *high_b.borrow(); - assert!( - low <= high, - "Uniform::new_inclusive called with `low > high`" - ); - - let low_s = low.as_secs(); - let low_n = low.subsec_nanos(); - let mut high_s = high.as_secs(); - let mut high_n = high.subsec_nanos(); - - if high_n < low_n { - high_s -= 1; - high_n += 1_000_000_000; - } - - let mode = if low_s == high_s { - UniformDurationMode::Small { - secs: low_s, - nanos: Uniform::new_inclusive(low_n, high_n), - } - } else { - let max = high_s - .checked_mul(1_000_000_000) - .and_then(|n| n.checked_add(u64::from(high_n))); - - if let Some(higher_bound) = max { - let lower_bound = low_s * 1_000_000_000 + u64::from(low_n); - UniformDurationMode::Medium { - nanos: Uniform::new_inclusive(lower_bound, higher_bound), - } - } else { - // An offset is applied to simplify generation of nanoseconds - let max_nanos = high_n - low_n; - UniformDurationMode::Large { - max_secs: high_s, - max_nanos, - secs: Uniform::new_inclusive(low_s, high_s), - } - } - }; - UniformDuration { - mode, - offset: low_n, - } - } - - #[inline] - fn sample(&self, rng: &mut R) -> Duration { - match self.mode { - UniformDurationMode::Small { secs, nanos } => { - let n = nanos.sample(rng); - Duration::new(secs, n) - } - UniformDurationMode::Medium { nanos } => { - let nanos = nanos.sample(rng); - Duration::new(nanos / 1_000_000_000, (nanos % 1_000_000_000) as u32) - } - UniformDurationMode::Large { - max_secs, - max_nanos, - secs, - } => { - // constant folding means this is at least as fast as `Rng::sample(Range)` - let nano_range = Uniform::new(0, 1_000_000_000); - loop { - let s = secs.sample(rng); - let n = nano_range.sample(rng); - if !(s == max_secs && n > max_nanos) { - let sum = n + self.offset; - break Duration::new(s, sum); - } - } - } - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::rngs::mock::StepRng; - - #[test] - #[cfg(feature = "serde1")] - fn test_serialization_uniform_duration() { - let distr = UniformDuration::new(std::time::Duration::from_secs(10), std::time::Duration::from_secs(60)); - let de_distr: UniformDuration = bincode::deserialize(&bincode::serialize(&distr).unwrap()).unwrap(); - assert_eq!( - distr.offset, de_distr.offset - ); - match (distr.mode, de_distr.mode) { - (UniformDurationMode::Small {secs: a_secs, nanos: a_nanos}, UniformDurationMode::Small {secs, nanos}) => { - assert_eq!(a_secs, secs); - - assert_eq!(a_nanos.0.low, nanos.0.low); - assert_eq!(a_nanos.0.range, nanos.0.range); - assert_eq!(a_nanos.0.z, nanos.0.z); - } - (UniformDurationMode::Medium {nanos: a_nanos} , UniformDurationMode::Medium {nanos}) => { - assert_eq!(a_nanos.0.low, nanos.0.low); - assert_eq!(a_nanos.0.range, nanos.0.range); - assert_eq!(a_nanos.0.z, nanos.0.z); - } - (UniformDurationMode::Large {max_secs:a_max_secs, max_nanos:a_max_nanos, secs:a_secs}, UniformDurationMode::Large {max_secs, max_nanos, secs} ) => { - assert_eq!(a_max_secs, max_secs); - assert_eq!(a_max_nanos, max_nanos); - - assert_eq!(a_secs.0.low, secs.0.low); - assert_eq!(a_secs.0.range, secs.0.range); - assert_eq!(a_secs.0.z, secs.0.z); - } - _ => panic!("`UniformDurationMode` was not serialized/deserialized correctly") - } - } - - #[test] - #[cfg(feature = "serde1")] - fn test_uniform_serialization() { - let unit_box: Uniform = Uniform::new(-1, 1); - let de_unit_box: Uniform = bincode::deserialize(&bincode::serialize(&unit_box).unwrap()).unwrap(); - - assert_eq!(unit_box.0.low, de_unit_box.0.low); - assert_eq!(unit_box.0.range, de_unit_box.0.range); - assert_eq!(unit_box.0.z, de_unit_box.0.z); - - let unit_box: Uniform = Uniform::new(-1., 1.); - let de_unit_box: Uniform = bincode::deserialize(&bincode::serialize(&unit_box).unwrap()).unwrap(); - - assert_eq!(unit_box.0.low, de_unit_box.0.low); - assert_eq!(unit_box.0.scale, de_unit_box.0.scale); - } - - #[should_panic] - #[test] - fn test_uniform_bad_limits_equal_int() { - Uniform::new(10, 10); - } - - #[test] - fn test_uniform_good_limits_equal_int() { - let mut rng = crate::test::rng(804); - let dist = Uniform::new_inclusive(10, 10); - for _ in 0..20 { - assert_eq!(rng.sample(dist), 10); - } - } - - #[should_panic] - #[test] - fn test_uniform_bad_limits_flipped_int() { - Uniform::new(10, 5); - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_integers() { - #[cfg(not(target_os = "emscripten"))] use core::{i128, u128}; - use core::{i16, i32, i64, i8, isize}; - use core::{u16, u32, u64, u8, usize}; - - let mut rng = crate::test::rng(251); - macro_rules! t { - ($ty:ident, $v:expr, $le:expr, $lt:expr) => {{ - for &(low, high) in $v.iter() { - let my_uniform = Uniform::new(low, high); - for _ in 0..1000 { - let v: $ty = rng.sample(my_uniform); - assert!($le(low, v) && $lt(v, high)); - } - - let my_uniform = Uniform::new_inclusive(low, high); - for _ in 0..1000 { - let v: $ty = rng.sample(my_uniform); - assert!($le(low, v) && $le(v, high)); - } - - let my_uniform = Uniform::new(&low, high); - for _ in 0..1000 { - let v: $ty = rng.sample(my_uniform); - assert!($le(low, v) && $lt(v, high)); - } - - let my_uniform = Uniform::new_inclusive(&low, &high); - for _ in 0..1000 { - let v: $ty = rng.sample(my_uniform); - assert!($le(low, v) && $le(v, high)); - } - - for _ in 0..1000 { - let v = <$ty as SampleUniform>::Sampler::sample_single(low, high, &mut rng); - assert!($le(low, v) && $lt(v, high)); - } - - for _ in 0..1000 { - let v = <$ty as SampleUniform>::Sampler::sample_single_inclusive(low, high, &mut rng); - assert!($le(low, v) && $le(v, high)); - } - } - }}; - - // scalar bulk - ($($ty:ident),*) => {{ - $(t!( - $ty, - [(0, 10), (10, 127), ($ty::MIN, $ty::MAX)], - |x, y| x <= y, - |x, y| x < y - );)* - }}; - - // simd bulk - ($($ty:ident),* => $scalar:ident) => {{ - $(t!( - $ty, - [ - ($ty::splat(0), $ty::splat(10)), - ($ty::splat(10), $ty::splat(127)), - ($ty::splat($scalar::MIN), $ty::splat($scalar::MAX)), - ], - |x: $ty, y| x.le(y).all(), - |x: $ty, y| x.lt(y).all() - );)* - }}; - } - t!(i8, i16, i32, i64, isize, u8, u16, u32, u64, usize); - #[cfg(not(target_os = "emscripten"))] - t!(i128, u128); - - #[cfg(feature = "simd_support")] - { - t!(u8x2, u8x4, u8x8, u8x16, u8x32, u8x64 => u8); - t!(i8x2, i8x4, i8x8, i8x16, i8x32, i8x64 => i8); - t!(u16x2, u16x4, u16x8, u16x16, u16x32 => u16); - t!(i16x2, i16x4, i16x8, i16x16, i16x32 => i16); - t!(u32x2, u32x4, u32x8, u32x16 => u32); - t!(i32x2, i32x4, i32x8, i32x16 => i32); - t!(u64x2, u64x4, u64x8 => u64); - t!(i64x2, i64x4, i64x8 => i64); - } - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_char() { - let mut rng = crate::test::rng(891); - let mut max = core::char::from_u32(0).unwrap(); - for _ in 0..100 { - let c = rng.gen_range('A'..='Z'); - assert!(('A'..='Z').contains(&c)); - max = max.max(c); - } - assert_eq!(max, 'Z'); - let d = Uniform::new( - core::char::from_u32(0xD7F0).unwrap(), - core::char::from_u32(0xE010).unwrap(), - ); - for _ in 0..100 { - let c = d.sample(&mut rng); - assert!((c as u32) < 0xD800 || (c as u32) > 0xDFFF); - } - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_floats() { - let mut rng = crate::test::rng(252); - let mut zero_rng = StepRng::new(0, 0); - let mut max_rng = StepRng::new(0xffff_ffff_ffff_ffff, 0); - macro_rules! t { - ($ty:ty, $f_scalar:ident, $bits_shifted:expr) => {{ - let v: &[($f_scalar, $f_scalar)] = &[ - (0.0, 100.0), - (-1e35, -1e25), - (1e-35, 1e-25), - (-1e35, 1e35), - (<$f_scalar>::from_bits(0), <$f_scalar>::from_bits(3)), - (-<$f_scalar>::from_bits(10), -<$f_scalar>::from_bits(1)), - (-<$f_scalar>::from_bits(5), 0.0), - (-<$f_scalar>::from_bits(7), -0.0), - (0.1 * ::core::$f_scalar::MAX, ::core::$f_scalar::MAX), - (-::core::$f_scalar::MAX * 0.2, ::core::$f_scalar::MAX * 0.7), - ]; - for &(low_scalar, high_scalar) in v.iter() { - for lane in 0..<$ty>::lanes() { - let low = <$ty>::splat(0.0 as $f_scalar).replace(lane, low_scalar); - let high = <$ty>::splat(1.0 as $f_scalar).replace(lane, high_scalar); - let my_uniform = Uniform::new(low, high); - let my_incl_uniform = Uniform::new_inclusive(low, high); - for _ in 0..100 { - let v = rng.sample(my_uniform).extract(lane); - assert!(low_scalar <= v && v < high_scalar); - let v = rng.sample(my_incl_uniform).extract(lane); - assert!(low_scalar <= v && v <= high_scalar); - let v = <$ty as SampleUniform>::Sampler - ::sample_single(low, high, &mut rng).extract(lane); - assert!(low_scalar <= v && v < high_scalar); - } - - assert_eq!( - rng.sample(Uniform::new_inclusive(low, low)).extract(lane), - low_scalar - ); - - assert_eq!(zero_rng.sample(my_uniform).extract(lane), low_scalar); - assert_eq!(zero_rng.sample(my_incl_uniform).extract(lane), low_scalar); - assert_eq!(<$ty as SampleUniform>::Sampler - ::sample_single(low, high, &mut zero_rng) - .extract(lane), low_scalar); - assert!(max_rng.sample(my_uniform).extract(lane) < high_scalar); - assert!(max_rng.sample(my_incl_uniform).extract(lane) <= high_scalar); - - // Don't run this test for really tiny differences between high and low - // since for those rounding might result in selecting high for a very - // long time. - if (high_scalar - low_scalar) > 0.0001 { - let mut lowering_max_rng = StepRng::new( - 0xffff_ffff_ffff_ffff, - (-1i64 << $bits_shifted) as u64, - ); - assert!( - <$ty as SampleUniform>::Sampler - ::sample_single(low, high, &mut lowering_max_rng) - .extract(lane) < high_scalar - ); - } - } - } - - assert_eq!( - rng.sample(Uniform::new_inclusive( - ::core::$f_scalar::MAX, - ::core::$f_scalar::MAX - )), - ::core::$f_scalar::MAX - ); - assert_eq!( - rng.sample(Uniform::new_inclusive( - -::core::$f_scalar::MAX, - -::core::$f_scalar::MAX - )), - -::core::$f_scalar::MAX - ); - }}; - } - - t!(f32, f32, 32 - 23); - t!(f64, f64, 64 - 52); - #[cfg(feature = "simd_support")] - { - t!(f32x2, f32, 32 - 23); - t!(f32x4, f32, 32 - 23); - t!(f32x8, f32, 32 - 23); - t!(f32x16, f32, 32 - 23); - t!(f64x2, f64, 64 - 52); - t!(f64x4, f64, 64 - 52); - t!(f64x8, f64, 64 - 52); - } - } - - #[test] - #[should_panic] - fn test_float_overflow() { - Uniform::from(::core::f64::MIN..::core::f64::MAX); - } - - #[test] - #[should_panic] - fn test_float_overflow_single() { - let mut rng = crate::test::rng(252); - rng.gen_range(::core::f64::MIN..::core::f64::MAX); - } - - #[test] - #[cfg(all( - feature = "std", - not(target_arch = "wasm32"), - not(target_arch = "asmjs") - ))] - fn test_float_assertions() { - use super::SampleUniform; - use std::panic::catch_unwind; - fn range(low: T, high: T) { - let mut rng = crate::test::rng(253); - T::Sampler::sample_single(low, high, &mut rng); - } - - macro_rules! t { - ($ty:ident, $f_scalar:ident) => {{ - let v: &[($f_scalar, $f_scalar)] = &[ - (::std::$f_scalar::NAN, 0.0), - (1.0, ::std::$f_scalar::NAN), - (::std::$f_scalar::NAN, ::std::$f_scalar::NAN), - (1.0, 0.5), - (::std::$f_scalar::MAX, -::std::$f_scalar::MAX), - (::std::$f_scalar::INFINITY, ::std::$f_scalar::INFINITY), - ( - ::std::$f_scalar::NEG_INFINITY, - ::std::$f_scalar::NEG_INFINITY, - ), - (::std::$f_scalar::NEG_INFINITY, 5.0), - (5.0, ::std::$f_scalar::INFINITY), - (::std::$f_scalar::NAN, ::std::$f_scalar::INFINITY), - (::std::$f_scalar::NEG_INFINITY, ::std::$f_scalar::NAN), - (::std::$f_scalar::NEG_INFINITY, ::std::$f_scalar::INFINITY), - ]; - for &(low_scalar, high_scalar) in v.iter() { - for lane in 0..<$ty>::lanes() { - let low = <$ty>::splat(0.0 as $f_scalar).replace(lane, low_scalar); - let high = <$ty>::splat(1.0 as $f_scalar).replace(lane, high_scalar); - assert!(catch_unwind(|| range(low, high)).is_err()); - assert!(catch_unwind(|| Uniform::new(low, high)).is_err()); - assert!(catch_unwind(|| Uniform::new_inclusive(low, high)).is_err()); - assert!(catch_unwind(|| range(low, low)).is_err()); - assert!(catch_unwind(|| Uniform::new(low, low)).is_err()); - } - } - }}; - } - - t!(f32, f32); - t!(f64, f64); - #[cfg(feature = "simd_support")] - { - t!(f32x2, f32); - t!(f32x4, f32); - t!(f32x8, f32); - t!(f32x16, f32); - t!(f64x2, f64); - t!(f64x4, f64); - t!(f64x8, f64); - } - } - - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_durations() { - #[cfg(not(feature = "std"))] use core::time::Duration; - #[cfg(feature = "std")] use std::time::Duration; - - let mut rng = crate::test::rng(253); - - let v = &[ - (Duration::new(10, 50000), Duration::new(100, 1234)), - (Duration::new(0, 100), Duration::new(1, 50)), - ( - Duration::new(0, 0), - Duration::new(u64::max_value(), 999_999_999), - ), - ]; - for &(low, high) in v.iter() { - let my_uniform = Uniform::new(low, high); - for _ in 0..1000 { - let v = rng.sample(my_uniform); - assert!(low <= v && v < high); - } - } - } - - #[test] - fn test_custom_uniform() { - use crate::distributions::uniform::{ - SampleBorrow, SampleUniform, UniformFloat, UniformSampler, - }; - #[derive(Clone, Copy, PartialEq, PartialOrd)] - struct MyF32 { - x: f32, - } - #[derive(Clone, Copy, Debug)] - struct UniformMyF32(UniformFloat); - impl UniformSampler for UniformMyF32 { - type X = MyF32; - - fn new(low: B1, high: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - UniformMyF32(UniformFloat::::new(low.borrow().x, high.borrow().x)) - } - - fn new_inclusive(low: B1, high: B2) -> Self - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - UniformSampler::new(low, high) - } - - fn sample(&self, rng: &mut R) -> Self::X { - MyF32 { - x: self.0.sample(rng), - } - } - } - impl SampleUniform for MyF32 { - type Sampler = UniformMyF32; - } - - let (low, high) = (MyF32 { x: 17.0f32 }, MyF32 { x: 22.0f32 }); - let uniform = Uniform::new(low, high); - let mut rng = crate::test::rng(804); - for _ in 0..100 { - let x: MyF32 = rng.sample(uniform); - assert!(low <= x && x < high); - } - } - - #[test] - fn test_uniform_from_std_range() { - let r = Uniform::from(2u32..7); - assert_eq!(r.0.low, 2); - assert_eq!(r.0.range, 5); - let r = Uniform::from(2.0f64..7.0); - assert_eq!(r.0.low, 2.0); - assert_eq!(r.0.scale, 5.0); - } - - #[test] - fn test_uniform_from_std_range_inclusive() { - let r = Uniform::from(2u32..=6); - assert_eq!(r.0.low, 2); - assert_eq!(r.0.range, 5); - let r = Uniform::from(2.0f64..=7.0); - assert_eq!(r.0.low, 2.0); - assert!(r.0.scale > 5.0); - assert!(r.0.scale < 5.0 + 1e-14); - } - - #[test] - fn value_stability() { - fn test_samples( - lb: T, ub: T, expected_single: &[T], expected_multiple: &[T], - ) where Uniform: Distribution { - let mut rng = crate::test::rng(897); - let mut buf = [lb; 3]; - - for x in &mut buf { - *x = T::Sampler::sample_single(lb, ub, &mut rng); - } - assert_eq!(&buf, expected_single); - - let distr = Uniform::new(lb, ub); - for x in &mut buf { - *x = rng.sample(&distr); - } - assert_eq!(&buf, expected_multiple); - } - - // We test on a sub-set of types; possibly we should do more. - // TODO: SIMD types - - test_samples(11u8, 219, &[17, 66, 214], &[181, 93, 165]); - test_samples(11u32, 219, &[17, 66, 214], &[181, 93, 165]); - - test_samples(0f32, 1e-2f32, &[0.0003070104, 0.0026630748, 0.00979833], &[ - 0.008194133, - 0.00398172, - 0.007428536, - ]); - test_samples( - -1e10f64, - 1e10f64, - &[-4673848682.871551, 6388267422.932352, 4857075081.198343], - &[1173375212.1808167, 1917642852.109581, 2365076174.3153973], - ); - - test_samples( - Duration::new(2, 0), - Duration::new(4, 0), - &[ - Duration::new(2, 532615131), - Duration::new(3, 638826742), - Duration::new(3, 485707508), - ], - &[ - Duration::new(3, 117337521), - Duration::new(3, 191764285), - Duration::new(3, 236507617), - ], - ); - } -} diff -Nru cargo-0.58.0/vendor/rand/src/distributions/utils.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/utils.rs --- cargo-0.58.0/vendor/rand/src/distributions/utils.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/utils.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,431 +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. - -//! Math helper functions - -#[cfg(feature = "simd_support")] use packed_simd::*; - - -pub(crate) trait WideningMultiply { - type Output; - - fn wmul(self, x: RHS) -> Self::Output; -} - -macro_rules! wmul_impl { - ($ty:ty, $wide:ty, $shift:expr) => { - impl WideningMultiply for $ty { - type Output = ($ty, $ty); - - #[inline(always)] - fn wmul(self, x: $ty) -> Self::Output { - let tmp = (self as $wide) * (x as $wide); - ((tmp >> $shift) as $ty, tmp as $ty) - } - } - }; - - // simd bulk implementation - ($(($ty:ident, $wide:ident),)+, $shift:expr) => { - $( - impl WideningMultiply for $ty { - type Output = ($ty, $ty); - - #[inline(always)] - fn wmul(self, x: $ty) -> Self::Output { - // For supported vectors, this should compile to a couple - // supported multiply & swizzle instructions (no actual - // casting). - // TODO: optimize - let y: $wide = self.cast(); - let x: $wide = x.cast(); - let tmp = y * x; - let hi: $ty = (tmp >> $shift).cast(); - let lo: $ty = tmp.cast(); - (hi, lo) - } - } - )+ - }; -} -wmul_impl! { u8, u16, 8 } -wmul_impl! { u16, u32, 16 } -wmul_impl! { u32, u64, 32 } -#[cfg(not(target_os = "emscripten"))] -wmul_impl! { u64, u128, 64 } - -// This code is a translation of the __mulddi3 function in LLVM's -// compiler-rt. It is an optimised variant of the common method -// `(a + b) * (c + d) = ac + ad + bc + bd`. -// -// For some reason LLVM can optimise the C version very well, but -// keeps shuffling registers in this Rust translation. -macro_rules! wmul_impl_large { - ($ty:ty, $half:expr) => { - impl WideningMultiply for $ty { - type Output = ($ty, $ty); - - #[inline(always)] - fn wmul(self, b: $ty) -> Self::Output { - const LOWER_MASK: $ty = !0 >> $half; - let mut low = (self & LOWER_MASK).wrapping_mul(b & LOWER_MASK); - let mut t = low >> $half; - low &= LOWER_MASK; - t += (self >> $half).wrapping_mul(b & LOWER_MASK); - low += (t & LOWER_MASK) << $half; - let mut high = t >> $half; - t = low >> $half; - low &= LOWER_MASK; - t += (b >> $half).wrapping_mul(self & LOWER_MASK); - low += (t & LOWER_MASK) << $half; - high += t >> $half; - high += (self >> $half).wrapping_mul(b >> $half); - - (high, low) - } - } - }; - - // simd bulk implementation - (($($ty:ty,)+) $scalar:ty, $half:expr) => { - $( - impl WideningMultiply for $ty { - type Output = ($ty, $ty); - - #[inline(always)] - fn wmul(self, b: $ty) -> Self::Output { - // needs wrapping multiplication - const LOWER_MASK: $scalar = !0 >> $half; - let mut low = (self & LOWER_MASK) * (b & LOWER_MASK); - let mut t = low >> $half; - low &= LOWER_MASK; - t += (self >> $half) * (b & LOWER_MASK); - low += (t & LOWER_MASK) << $half; - let mut high = t >> $half; - t = low >> $half; - low &= LOWER_MASK; - t += (b >> $half) * (self & LOWER_MASK); - low += (t & LOWER_MASK) << $half; - high += t >> $half; - high += (self >> $half) * (b >> $half); - - (high, low) - } - } - )+ - }; -} -#[cfg(target_os = "emscripten")] -wmul_impl_large! { u64, 32 } -#[cfg(not(target_os = "emscripten"))] -wmul_impl_large! { u128, 64 } - -macro_rules! wmul_impl_usize { - ($ty:ty) => { - impl WideningMultiply for usize { - type Output = (usize, usize); - - #[inline(always)] - fn wmul(self, x: usize) -> Self::Output { - let (high, low) = (self as $ty).wmul(x as $ty); - (high as usize, low as usize) - } - } - }; -} -#[cfg(target_pointer_width = "32")] -wmul_impl_usize! { u32 } -#[cfg(target_pointer_width = "64")] -wmul_impl_usize! { u64 } - -#[cfg(feature = "simd_support")] -mod simd_wmul { - use super::*; - #[cfg(target_arch = "x86")] use core::arch::x86::*; - #[cfg(target_arch = "x86_64")] use core::arch::x86_64::*; - - wmul_impl! { - (u8x2, u16x2), - (u8x4, u16x4), - (u8x8, u16x8), - (u8x16, u16x16), - (u8x32, u16x32),, - 8 - } - - wmul_impl! { (u16x2, u32x2),, 16 } - wmul_impl! { (u16x4, u32x4),, 16 } - #[cfg(not(target_feature = "sse2"))] - wmul_impl! { (u16x8, u32x8),, 16 } - #[cfg(not(target_feature = "avx2"))] - wmul_impl! { (u16x16, u32x16),, 16 } - - // 16-bit lane widths allow use of the x86 `mulhi` instructions, which - // means `wmul` can be implemented with only two instructions. - #[allow(unused_macros)] - macro_rules! wmul_impl_16 { - ($ty:ident, $intrinsic:ident, $mulhi:ident, $mullo:ident) => { - impl WideningMultiply for $ty { - type Output = ($ty, $ty); - - #[inline(always)] - fn wmul(self, x: $ty) -> Self::Output { - let b = $intrinsic::from_bits(x); - let a = $intrinsic::from_bits(self); - let hi = $ty::from_bits(unsafe { $mulhi(a, b) }); - let lo = $ty::from_bits(unsafe { $mullo(a, b) }); - (hi, lo) - } - } - }; - } - - #[cfg(target_feature = "sse2")] - wmul_impl_16! { u16x8, __m128i, _mm_mulhi_epu16, _mm_mullo_epi16 } - #[cfg(target_feature = "avx2")] - wmul_impl_16! { u16x16, __m256i, _mm256_mulhi_epu16, _mm256_mullo_epi16 } - // FIXME: there are no `__m512i` types in stdsimd yet, so `wmul::` - // cannot use the same implementation. - - wmul_impl! { - (u32x2, u64x2), - (u32x4, u64x4), - (u32x8, u64x8),, - 32 - } - - // TODO: optimize, this seems to seriously slow things down - wmul_impl_large! { (u8x64,) u8, 4 } - wmul_impl_large! { (u16x32,) u16, 8 } - wmul_impl_large! { (u32x16,) u32, 16 } - wmul_impl_large! { (u64x2, u64x4, u64x8,) u64, 32 } -} - -/// Helper trait when dealing with scalar and SIMD floating point types. -pub(crate) trait FloatSIMDUtils { - // `PartialOrd` for vectors compares lexicographically. We want to compare all - // the individual SIMD lanes instead, and get the combined result over all - // lanes. This is possible using something like `a.lt(b).all()`, but we - // implement it as a trait so we can write the same code for `f32` and `f64`. - // Only the comparison functions we need are implemented. - fn all_lt(self, other: Self) -> bool; - fn all_le(self, other: Self) -> bool; - fn all_finite(self) -> bool; - - type Mask; - fn finite_mask(self) -> Self::Mask; - fn gt_mask(self, other: Self) -> Self::Mask; - fn ge_mask(self, other: Self) -> Self::Mask; - - // Decrease all lanes where the mask is `true` to the next lower value - // representable by the floating-point type. At least one of the lanes - // must be set. - fn decrease_masked(self, mask: Self::Mask) -> Self; - - // Convert from int value. Conversion is done while retaining the numerical - // value, not by retaining the binary representation. - type UInt; - fn cast_from_int(i: Self::UInt) -> Self; -} - -/// Implement functions available in std builds but missing from core primitives -#[cfg(not(std))] -// False positive: We are following `std` here. -#[allow(clippy::wrong_self_convention)] -pub(crate) trait Float: Sized { - fn is_nan(self) -> bool; - fn is_infinite(self) -> bool; - fn is_finite(self) -> bool; -} - -/// Implement functions on f32/f64 to give them APIs similar to SIMD types -pub(crate) trait FloatAsSIMD: Sized { - #[inline(always)] - fn lanes() -> usize { - 1 - } - #[inline(always)] - fn splat(scalar: Self) -> Self { - scalar - } - #[inline(always)] - fn extract(self, index: usize) -> Self { - debug_assert_eq!(index, 0); - self - } - #[inline(always)] - fn replace(self, index: usize, new_value: Self) -> Self { - debug_assert_eq!(index, 0); - new_value - } -} - -pub(crate) trait BoolAsSIMD: Sized { - fn any(self) -> bool; - fn all(self) -> bool; - fn none(self) -> bool; -} - -impl BoolAsSIMD for bool { - #[inline(always)] - fn any(self) -> bool { - self - } - - #[inline(always)] - fn all(self) -> bool { - self - } - - #[inline(always)] - fn none(self) -> bool { - !self - } -} - -macro_rules! scalar_float_impl { - ($ty:ident, $uty:ident) => { - #[cfg(not(std))] - impl Float for $ty { - #[inline] - fn is_nan(self) -> bool { - self != self - } - - #[inline] - fn is_infinite(self) -> bool { - self == ::core::$ty::INFINITY || self == ::core::$ty::NEG_INFINITY - } - - #[inline] - fn is_finite(self) -> bool { - !(self.is_nan() || self.is_infinite()) - } - } - - impl FloatSIMDUtils for $ty { - type Mask = bool; - type UInt = $uty; - - #[inline(always)] - fn all_lt(self, other: Self) -> bool { - self < other - } - - #[inline(always)] - fn all_le(self, other: Self) -> bool { - self <= other - } - - #[inline(always)] - fn all_finite(self) -> bool { - self.is_finite() - } - - #[inline(always)] - fn finite_mask(self) -> Self::Mask { - self.is_finite() - } - - #[inline(always)] - fn gt_mask(self, other: Self) -> Self::Mask { - self > other - } - - #[inline(always)] - fn ge_mask(self, other: Self) -> Self::Mask { - self >= other - } - - #[inline(always)] - fn decrease_masked(self, mask: Self::Mask) -> Self { - debug_assert!(mask, "At least one lane must be set"); - <$ty>::from_bits(self.to_bits() - 1) - } - - #[inline] - fn cast_from_int(i: Self::UInt) -> Self { - i as $ty - } - } - - impl FloatAsSIMD for $ty {} - }; -} - -scalar_float_impl!(f32, u32); -scalar_float_impl!(f64, u64); - - -#[cfg(feature = "simd_support")] -macro_rules! simd_impl { - ($ty:ident, $f_scalar:ident, $mty:ident, $uty:ident) => { - impl FloatSIMDUtils for $ty { - type Mask = $mty; - type UInt = $uty; - - #[inline(always)] - fn all_lt(self, other: Self) -> bool { - self.lt(other).all() - } - - #[inline(always)] - fn all_le(self, other: Self) -> bool { - self.le(other).all() - } - - #[inline(always)] - fn all_finite(self) -> bool { - self.finite_mask().all() - } - - #[inline(always)] - fn finite_mask(self) -> Self::Mask { - // This can possibly be done faster by checking bit patterns - let neg_inf = $ty::splat(::core::$f_scalar::NEG_INFINITY); - let pos_inf = $ty::splat(::core::$f_scalar::INFINITY); - self.gt(neg_inf) & self.lt(pos_inf) - } - - #[inline(always)] - fn gt_mask(self, other: Self) -> Self::Mask { - self.gt(other) - } - - #[inline(always)] - fn ge_mask(self, other: Self) -> Self::Mask { - self.ge(other) - } - - #[inline(always)] - fn decrease_masked(self, mask: Self::Mask) -> Self { - // Casting a mask into ints will produce all bits set for - // true, and 0 for false. Adding that to the binary - // representation of a float means subtracting one from - // the binary representation, resulting in the next lower - // value representable by $ty. This works even when the - // current value is infinity. - debug_assert!(mask.any(), "At least one lane must be set"); - <$ty>::from_bits(<$uty>::from_bits(self) + <$uty>::from_bits(mask)) - } - - #[inline] - fn cast_from_int(i: Self::UInt) -> Self { - i.cast() - } - } - }; -} - -#[cfg(feature="simd_support")] simd_impl! { f32x2, f32, m32x2, u32x2 } -#[cfg(feature="simd_support")] simd_impl! { f32x4, f32, m32x4, u32x4 } -#[cfg(feature="simd_support")] simd_impl! { f32x8, f32, m32x8, u32x8 } -#[cfg(feature="simd_support")] simd_impl! { f32x16, f32, m32x16, u32x16 } -#[cfg(feature="simd_support")] simd_impl! { f64x2, f64, m64x2, u64x2 } -#[cfg(feature="simd_support")] simd_impl! { f64x4, f64, m64x4, u64x4 } -#[cfg(feature="simd_support")] simd_impl! { f64x8, f64, m64x8, u64x8 } diff -Nru cargo-0.58.0/vendor/rand/src/distributions/weighted_index.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/weighted_index.rs --- cargo-0.58.0/vendor/rand/src/distributions/weighted_index.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/weighted_index.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,453 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Weighted index sampling - -use crate::distributions::uniform::{SampleBorrow, SampleUniform, UniformSampler}; -use crate::distributions::Distribution; -use crate::Rng; -use core::cmp::PartialOrd; -use core::fmt; - -// Note that this whole module is only imported if feature="alloc" is enabled. -use alloc::vec::Vec; - -#[cfg(feature = "serde1")] -use serde::{Serialize, Deserialize}; - -/// A distribution using weighted sampling of discrete items -/// -/// Sampling a `WeightedIndex` distribution returns the index of a randomly -/// selected element from the iterator used when the `WeightedIndex` was -/// created. The chance of a given element being picked is proportional to the -/// value of the element. The weights can use any type `X` for which an -/// implementation of [`Uniform`] exists. -/// -/// # Performance -/// -/// Time complexity of sampling from `WeightedIndex` is `O(log N)` where -/// `N` is the number of weights. As an alternative, -/// [`rand_distr::weighted_alias`](https://docs.rs/rand_distr/*/rand_distr/weighted_alias/index.html) -/// supports `O(1)` sampling, but with much higher initialisation cost. -/// -/// A `WeightedIndex` contains a `Vec` and a [`Uniform`] and so its -/// size is the sum of the size of those objects, possibly plus some alignment. -/// -/// Creating a `WeightedIndex` will allocate enough space to hold `N - 1` -/// weights of type `X`, where `N` is the number of weights. However, since -/// `Vec` doesn't guarantee a particular growth strategy, additional memory -/// might be allocated but not used. Since the `WeightedIndex` object also -/// contains, this might cause additional allocations, though for primitive -/// types, [`Uniform`] doesn't allocate any memory. -/// -/// Sampling from `WeightedIndex` will result in a single call to -/// `Uniform::sample` (method of the [`Distribution`] trait), which typically -/// will request a single value from the underlying [`RngCore`], though the -/// exact number depends on the implementation of `Uniform::sample`. -/// -/// # Example -/// -/// ``` -/// use rand::prelude::*; -/// use rand::distributions::WeightedIndex; -/// -/// let choices = ['a', 'b', 'c']; -/// let weights = [2, 1, 1]; -/// let dist = WeightedIndex::new(&weights).unwrap(); -/// let mut rng = thread_rng(); -/// for _ in 0..100 { -/// // 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c' -/// println!("{}", choices[dist.sample(&mut rng)]); -/// } -/// -/// let items = [('a', 0), ('b', 3), ('c', 7)]; -/// let dist2 = WeightedIndex::new(items.iter().map(|item| item.1)).unwrap(); -/// for _ in 0..100 { -/// // 0% chance to print 'a', 30% chance to print 'b', 70% chance to print 'c' -/// println!("{}", items[dist2.sample(&mut rng)].0); -/// } -/// ``` -/// -/// [`Uniform`]: crate::distributions::Uniform -/// [`RngCore`]: crate::RngCore -#[derive(Debug, Clone)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] -pub struct WeightedIndex { - cumulative_weights: Vec, - total_weight: X, - weight_distribution: X::Sampler, -} - -impl WeightedIndex { - /// Creates a new a `WeightedIndex` [`Distribution`] using the values - /// in `weights`. The weights can use any type `X` for which an - /// implementation of [`Uniform`] exists. - /// - /// Returns an error if the iterator is empty, if any weight is `< 0`, or - /// if its total value is 0. - /// - /// [`Uniform`]: crate::distributions::uniform::Uniform - pub fn new(weights: I) -> Result, WeightedError> - where - I: IntoIterator, - I::Item: SampleBorrow, - X: for<'a> ::core::ops::AddAssign<&'a X> + Clone + Default, - { - let mut iter = weights.into_iter(); - let mut total_weight: X = iter.next().ok_or(WeightedError::NoItem)?.borrow().clone(); - - let zero = ::default(); - if !(total_weight >= zero) { - return Err(WeightedError::InvalidWeight); - } - - let mut weights = Vec::::with_capacity(iter.size_hint().0); - for w in iter { - // Note that `!(w >= x)` is not equivalent to `w < x` for partially - // ordered types due to NaNs which are equal to nothing. - if !(w.borrow() >= &zero) { - return Err(WeightedError::InvalidWeight); - } - weights.push(total_weight.clone()); - total_weight += w.borrow(); - } - - if total_weight == zero { - return Err(WeightedError::AllWeightsZero); - } - let distr = X::Sampler::new(zero, total_weight.clone()); - - Ok(WeightedIndex { - cumulative_weights: weights, - total_weight, - weight_distribution: distr, - }) - } - - /// Update a subset of weights, without changing the number of weights. - /// - /// `new_weights` must be sorted by the index. - /// - /// Using this method instead of `new` might be more efficient if only a small number of - /// weights is modified. No allocations are performed, unless the weight type `X` uses - /// allocation internally. - /// - /// In case of error, `self` is not modified. - pub fn update_weights(&mut self, new_weights: &[(usize, &X)]) -> Result<(), WeightedError> - where X: for<'a> ::core::ops::AddAssign<&'a X> - + for<'a> ::core::ops::SubAssign<&'a X> - + Clone - + Default { - if new_weights.is_empty() { - return Ok(()); - } - - let zero = ::default(); - - let mut total_weight = self.total_weight.clone(); - - // Check for errors first, so we don't modify `self` in case something - // goes wrong. - let mut prev_i = None; - for &(i, w) in new_weights { - if let Some(old_i) = prev_i { - if old_i >= i { - return Err(WeightedError::InvalidWeight); - } - } - if !(*w >= zero) { - return Err(WeightedError::InvalidWeight); - } - if i > self.cumulative_weights.len() { - return Err(WeightedError::TooMany); - } - - let mut old_w = if i < self.cumulative_weights.len() { - self.cumulative_weights[i].clone() - } else { - self.total_weight.clone() - }; - if i > 0 { - old_w -= &self.cumulative_weights[i - 1]; - } - - total_weight -= &old_w; - total_weight += w; - prev_i = Some(i); - } - if total_weight <= zero { - return Err(WeightedError::AllWeightsZero); - } - - // Update the weights. Because we checked all the preconditions in the - // previous loop, this should never panic. - let mut iter = new_weights.iter(); - - let mut prev_weight = zero.clone(); - let mut next_new_weight = iter.next(); - let &(first_new_index, _) = next_new_weight.unwrap(); - let mut cumulative_weight = if first_new_index > 0 { - self.cumulative_weights[first_new_index - 1].clone() - } else { - zero.clone() - }; - for i in first_new_index..self.cumulative_weights.len() { - match next_new_weight { - Some(&(j, w)) if i == j => { - cumulative_weight += w; - next_new_weight = iter.next(); - } - _ => { - let mut tmp = self.cumulative_weights[i].clone(); - tmp -= &prev_weight; // We know this is positive. - cumulative_weight += &tmp; - } - } - prev_weight = cumulative_weight.clone(); - core::mem::swap(&mut prev_weight, &mut self.cumulative_weights[i]); - } - - self.total_weight = total_weight; - self.weight_distribution = X::Sampler::new(zero, self.total_weight.clone()); - - Ok(()) - } -} - -impl Distribution for WeightedIndex -where X: SampleUniform + PartialOrd -{ - fn sample(&self, rng: &mut R) -> usize { - use ::core::cmp::Ordering; - let chosen_weight = self.weight_distribution.sample(rng); - // Find the first item which has a weight *higher* than the chosen weight. - self.cumulative_weights - .binary_search_by(|w| { - if *w <= chosen_weight { - Ordering::Less - } else { - Ordering::Greater - } - }) - .unwrap_err() - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[cfg(feature = "serde1")] - #[test] - fn test_weightedindex_serde1() { - let weighted_index = WeightedIndex::new(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(); - - let ser_weighted_index = bincode::serialize(&weighted_index).unwrap(); - let de_weighted_index: WeightedIndex = - bincode::deserialize(&ser_weighted_index).unwrap(); - - assert_eq!( - de_weighted_index.cumulative_weights, - weighted_index.cumulative_weights - ); - assert_eq!(de_weighted_index.total_weight, weighted_index.total_weight); - } - - #[test] - fn test_accepting_nan(){ - assert_eq!( - WeightedIndex::new(&[core::f32::NAN, 0.5]).unwrap_err(), - WeightedError::InvalidWeight, - ); - assert_eq!( - WeightedIndex::new(&[core::f32::NAN]).unwrap_err(), - WeightedError::InvalidWeight, - ); - assert_eq!( - WeightedIndex::new(&[0.5, core::f32::NAN]).unwrap_err(), - WeightedError::InvalidWeight, - ); - - assert_eq!( - WeightedIndex::new(&[0.5, 7.0]) - .unwrap() - .update_weights(&[(0, &core::f32::NAN)]) - .unwrap_err(), - WeightedError::InvalidWeight, - ) - } - - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_weightedindex() { - let mut r = crate::test::rng(700); - const N_REPS: u32 = 5000; - let weights = [1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7]; - let total_weight = weights.iter().sum::() as f32; - - let verify = |result: [i32; 14]| { - for (i, count) in result.iter().enumerate() { - let exp = (weights[i] * N_REPS) as f32 / total_weight; - let mut err = (*count as f32 - exp).abs(); - if err != 0.0 { - err /= exp; - } - assert!(err <= 0.25); - } - }; - - // WeightedIndex from vec - let mut chosen = [0i32; 14]; - let distr = WeightedIndex::new(weights.to_vec()).unwrap(); - for _ in 0..N_REPS { - chosen[distr.sample(&mut r)] += 1; - } - verify(chosen); - - // WeightedIndex from slice - chosen = [0i32; 14]; - let distr = WeightedIndex::new(&weights[..]).unwrap(); - for _ in 0..N_REPS { - chosen[distr.sample(&mut r)] += 1; - } - verify(chosen); - - // WeightedIndex from iterator - chosen = [0i32; 14]; - let distr = WeightedIndex::new(weights.iter()).unwrap(); - for _ in 0..N_REPS { - chosen[distr.sample(&mut r)] += 1; - } - verify(chosen); - - for _ in 0..5 { - assert_eq!(WeightedIndex::new(&[0, 1]).unwrap().sample(&mut r), 1); - assert_eq!(WeightedIndex::new(&[1, 0]).unwrap().sample(&mut r), 0); - assert_eq!( - WeightedIndex::new(&[0, 0, 0, 0, 10, 0]) - .unwrap() - .sample(&mut r), - 4 - ); - } - - assert_eq!( - WeightedIndex::new(&[10][0..0]).unwrap_err(), - WeightedError::NoItem - ); - assert_eq!( - WeightedIndex::new(&[0]).unwrap_err(), - WeightedError::AllWeightsZero - ); - assert_eq!( - WeightedIndex::new(&[10, 20, -1, 30]).unwrap_err(), - WeightedError::InvalidWeight - ); - assert_eq!( - WeightedIndex::new(&[-10, 20, 1, 30]).unwrap_err(), - WeightedError::InvalidWeight - ); - assert_eq!( - WeightedIndex::new(&[-10]).unwrap_err(), - WeightedError::InvalidWeight - ); - } - - #[test] - fn test_update_weights() { - let data = [ - ( - &[10u32, 2, 3, 4][..], - &[(1, &100), (2, &4)][..], // positive change - &[10, 100, 4, 4][..], - ), - ( - &[1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7][..], - &[(2, &1), (5, &1), (13, &100)][..], // negative change and last element - &[1u32, 2, 1, 0, 5, 1, 7, 1, 2, 3, 4, 5, 6, 100][..], - ), - ]; - - for (weights, update, expected_weights) in data.iter() { - let total_weight = weights.iter().sum::(); - let mut distr = WeightedIndex::new(weights.to_vec()).unwrap(); - assert_eq!(distr.total_weight, total_weight); - - distr.update_weights(update).unwrap(); - let expected_total_weight = expected_weights.iter().sum::(); - let expected_distr = WeightedIndex::new(expected_weights.to_vec()).unwrap(); - assert_eq!(distr.total_weight, expected_total_weight); - assert_eq!(distr.total_weight, expected_distr.total_weight); - assert_eq!(distr.cumulative_weights, expected_distr.cumulative_weights); - } - } - - #[test] - fn value_stability() { - fn test_samples( - weights: I, buf: &mut [usize], expected: &[usize], - ) where - I: IntoIterator, - I::Item: SampleBorrow, - X: for<'a> ::core::ops::AddAssign<&'a X> + Clone + Default, - { - assert_eq!(buf.len(), expected.len()); - let distr = WeightedIndex::new(weights).unwrap(); - let mut rng = crate::test::rng(701); - for r in buf.iter_mut() { - *r = rng.sample(&distr); - } - assert_eq!(buf, expected); - } - - let mut buf = [0; 10]; - test_samples(&[1i32, 1, 1, 1, 1, 1, 1, 1, 1], &mut buf, &[ - 0, 6, 2, 6, 3, 4, 7, 8, 2, 5, - ]); - test_samples(&[0.7f32, 0.1, 0.1, 0.1], &mut buf, &[ - 0, 0, 0, 1, 0, 0, 2, 3, 0, 0, - ]); - test_samples(&[1.0f64, 0.999, 0.998, 0.997], &mut buf, &[ - 2, 2, 1, 3, 2, 1, 3, 3, 2, 1, - ]); - } -} - -/// Error type returned from `WeightedIndex::new`. -#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum WeightedError { - /// The provided weight collection contains no items. - NoItem, - - /// A weight is either less than zero, greater than the supported maximum, - /// NaN, or otherwise invalid. - InvalidWeight, - - /// All items in the provided weight collection are zero. - AllWeightsZero, - - /// Too many weights are provided (length greater than `u32::MAX`) - TooMany, -} - -#[cfg(feature = "std")] -impl std::error::Error for WeightedError {} - -impl fmt::Display for WeightedError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(match *self { - WeightedError::NoItem => "No weights provided in distribution", - WeightedError::InvalidWeight => "A weight is invalid in distribution", - WeightedError::AllWeightsZero => "All weights are zero in distribution", - WeightedError::TooMany => "Too many weights (hit u32::MAX) in distribution", - }) - } -} diff -Nru cargo-0.58.0/vendor/rand/src/distributions/weighted.rs cargo-0.60.0ubuntu1/vendor/rand/src/distributions/weighted.rs --- cargo-0.58.0/vendor/rand/src/distributions/weighted.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/distributions/weighted.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Weighted index sampling -//! -//! This module is deprecated. Use [`crate::distributions::WeightedIndex`] and -//! [`crate::distributions::WeightedError`] instead. - -pub use super::{WeightedIndex, WeightedError}; - -#[allow(missing_docs)] -#[deprecated(since = "0.8.0", note = "moved to rand_distr crate")] -pub mod alias_method { - // This module exists to provide a deprecation warning which minimises - // compile errors, but still fails to compile if ever used. - use core::marker::PhantomData; - use alloc::vec::Vec; - use super::WeightedError; - - #[derive(Debug)] - pub struct WeightedIndex { - _phantom: PhantomData, - } - impl WeightedIndex { - pub fn new(_weights: Vec) -> Result { - Err(WeightedError::NoItem) - } - } - - pub trait Weight {} - macro_rules! impl_weight { - () => {}; - ($T:ident, $($more:ident,)*) => { - impl Weight for $T {} - impl_weight!($($more,)*); - }; - } - impl_weight!(f64, f32,); - impl_weight!(u8, u16, u32, u64, usize,); - impl_weight!(i8, i16, i32, i64, isize,); - #[cfg(not(target_os = "emscripten"))] - impl_weight!(u128, i128,); -} diff -Nru cargo-0.58.0/vendor/rand/src/lib.rs cargo-0.60.0ubuntu1/vendor/rand/src/lib.rs --- cargo-0.58.0/vendor/rand/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,215 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013-2017 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Utilities for random number generation -//! -//! Rand provides utilities to generate random numbers, to convert them to -//! useful types and distributions, and some randomness-related algorithms. -//! -//! # Quick Start -//! -//! To get you started quickly, the easiest and highest-level way to get -//! a random value is to use [`random()`]; alternatively you can use -//! [`thread_rng()`]. The [`Rng`] trait provides a useful API on all RNGs, while -//! the [`distributions`] and [`seq`] modules provide further -//! functionality on top of RNGs. -//! -//! ``` -//! use rand::prelude::*; -//! -//! if rand::random() { // generates a boolean -//! // Try printing a random unicode code point (probably a bad idea)! -//! println!("char: {}", rand::random::()); -//! } -//! -//! let mut rng = rand::thread_rng(); -//! let y: f64 = rng.gen(); // generates a float between 0 and 1 -//! -//! let mut nums: Vec = (1..100).collect(); -//! nums.shuffle(&mut rng); -//! ``` -//! -//! # The Book -//! -//! For the user guide and further documentation, please read -//! [The Rust Rand Book](https://rust-random.github.io/book). - -#![doc( - html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://rust-random.github.io/rand/" -)] -#![deny(missing_docs)] -#![deny(missing_debug_implementations)] -#![doc(test(attr(allow(unused_variables), deny(warnings))))] -#![no_std] -#![cfg_attr(feature = "simd_support", feature(stdsimd))] -#![cfg_attr(feature = "nightly", feature(slice_partition_at_index))] -#![cfg_attr(doc_cfg, feature(doc_cfg))] -#![allow( - clippy::float_cmp, - clippy::neg_cmp_op_on_partial_ord, -)] - -#[cfg(feature = "std")] extern crate std; -#[cfg(feature = "alloc")] extern crate alloc; - -#[allow(unused)] -macro_rules! trace { ($($x:tt)*) => ( - #[cfg(feature = "log")] { - log::trace!($($x)*) - } -) } -#[allow(unused)] -macro_rules! debug { ($($x:tt)*) => ( - #[cfg(feature = "log")] { - log::debug!($($x)*) - } -) } -#[allow(unused)] -macro_rules! info { ($($x:tt)*) => ( - #[cfg(feature = "log")] { - log::info!($($x)*) - } -) } -#[allow(unused)] -macro_rules! warn { ($($x:tt)*) => ( - #[cfg(feature = "log")] { - log::warn!($($x)*) - } -) } -#[allow(unused)] -macro_rules! error { ($($x:tt)*) => ( - #[cfg(feature = "log")] { - log::error!($($x)*) - } -) } - -// Re-exports from rand_core -pub use rand_core::{CryptoRng, Error, RngCore, SeedableRng}; - -// Public modules -pub mod distributions; -pub mod prelude; -mod rng; -pub mod rngs; -pub mod seq; - -// Public exports -#[cfg(all(feature = "std", feature = "std_rng"))] -pub use crate::rngs::thread::thread_rng; -pub use rng::{Fill, Rng}; - -#[cfg(all(feature = "std", feature = "std_rng"))] -use crate::distributions::{Distribution, Standard}; - -/// Generates a random value using the thread-local random number generator. -/// -/// This is simply a shortcut for `thread_rng().gen()`. See [`thread_rng`] for -/// documentation of the entropy source and [`Standard`] for documentation of -/// distributions and type-specific generation. -/// -/// # Provided implementations -/// -/// The following types have provided implementations that -/// generate values with the following ranges and distributions: -/// -/// * Integers (`i32`, `u32`, `isize`, `usize`, etc.): Uniformly distributed -/// over all values of the type. -/// * `char`: Uniformly distributed over all Unicode scalar values, i.e. all -/// code points in the range `0...0x10_FFFF`, except for the range -/// `0xD800...0xDFFF` (the surrogate code points). This includes -/// unassigned/reserved code points. -/// * `bool`: Generates `false` or `true`, each with probability 0.5. -/// * Floating point types (`f32` and `f64`): Uniformly distributed in the -/// half-open range `[0, 1)`. See notes below. -/// * Wrapping integers (`Wrapping`), besides the type identical to their -/// normal integer variants. -/// -/// Also supported is the generation of the following -/// compound types where all component types are supported: -/// -/// * Tuples (up to 12 elements): each element is generated sequentially. -/// * Arrays (up to 32 elements): each element is generated sequentially; -/// see also [`Rng::fill`] which supports arbitrary array length for integer -/// types and tends to be faster for `u32` and smaller types. -/// * `Option` first generates a `bool`, and if true generates and returns -/// `Some(value)` where `value: T`, otherwise returning `None`. -/// -/// # Examples -/// -/// ``` -/// let x = rand::random::(); -/// println!("{}", x); -/// -/// let y = rand::random::(); -/// println!("{}", y); -/// -/// if rand::random() { // generates a boolean -/// println!("Better lucky than good!"); -/// } -/// ``` -/// -/// If you're calling `random()` in a loop, caching the generator as in the -/// following example can increase performance. -/// -/// ``` -/// use rand::Rng; -/// -/// let mut v = vec![1, 2, 3]; -/// -/// for x in v.iter_mut() { -/// *x = rand::random() -/// } -/// -/// // can be made faster by caching thread_rng -/// -/// let mut rng = rand::thread_rng(); -/// -/// for x in v.iter_mut() { -/// *x = rng.gen(); -/// } -/// ``` -/// -/// [`Standard`]: distributions::Standard -#[cfg(all(feature = "std", feature = "std_rng"))] -#[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", feature = "std_rng"))))] -#[inline] -pub fn random() -> T -where Standard: Distribution { - thread_rng().gen() -} - -#[cfg(test)] -mod test { - use super::*; - - /// Construct a deterministic RNG with the given seed - pub fn rng(seed: u64) -> impl RngCore { - // For tests, we want a statistically good, fast, reproducible RNG. - // PCG32 will do fine, and will be easy to embed if we ever need to. - const INC: u64 = 11634580027462260723; - rand_pcg::Pcg32::new(seed, INC) - } - - #[test] - #[cfg(all(feature = "std", feature = "std_rng"))] - fn test_random() { - let _n: usize = random(); - let _f: f32 = random(); - let _o: Option> = random(); - #[allow(clippy::type_complexity)] - let _many: ( - (), - (usize, isize, Option<(u32, (bool,))>), - (u8, i8, u16, i16, u32, i32, u64, i64), - (f32, (f64, (f64,))), - ) = random(); - } -} diff -Nru cargo-0.58.0/vendor/rand/src/prelude.rs cargo-0.60.0ubuntu1/vendor/rand/src/prelude.rs --- cargo-0.58.0/vendor/rand/src/prelude.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/prelude.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +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. - -//! Convenience re-export of common members -//! -//! Like the standard library's prelude, this module simplifies importing of -//! common items. Unlike the standard prelude, the contents of this module must -//! be imported manually: -//! -//! ``` -//! use rand::prelude::*; -//! # let mut r = StdRng::from_rng(thread_rng()).unwrap(); -//! # let _: f32 = r.gen(); -//! ``` - -#[doc(no_inline)] pub use crate::distributions::Distribution; -#[cfg(feature = "small_rng")] -#[doc(no_inline)] -pub use crate::rngs::SmallRng; -#[cfg(feature = "std_rng")] -#[doc(no_inline)] pub use crate::rngs::StdRng; -#[doc(no_inline)] -#[cfg(all(feature = "std", feature = "std_rng"))] -pub use crate::rngs::ThreadRng; -#[doc(no_inline)] pub use crate::seq::{IteratorRandom, SliceRandom}; -#[doc(no_inline)] -#[cfg(all(feature = "std", feature = "std_rng"))] -pub use crate::{random, thread_rng}; -#[doc(no_inline)] pub use crate::{CryptoRng, Rng, RngCore, SeedableRng}; diff -Nru cargo-0.58.0/vendor/rand/src/rng.rs cargo-0.60.0ubuntu1/vendor/rand/src/rng.rs --- cargo-0.58.0/vendor/rand/src/rng.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rng.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,603 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013-2017 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! [`Rng`] trait - -use rand_core::{Error, RngCore}; -use crate::distributions::uniform::{SampleRange, SampleUniform}; -use crate::distributions::{self, Distribution, Standard}; -use core::num::Wrapping; -use core::{mem, slice}; - -/// An automatically-implemented extension trait on [`RngCore`] providing high-level -/// generic methods for sampling values and other convenience methods. -/// -/// This is the primary trait to use when generating random values. -/// -/// # Generic usage -/// -/// The basic pattern is `fn foo(rng: &mut R)`. Some -/// things are worth noting here: -/// -/// - Since `Rng: RngCore` and every `RngCore` implements `Rng`, it makes no -/// difference whether we use `R: Rng` or `R: RngCore`. -/// - The `+ ?Sized` un-bounding allows functions to be called directly on -/// type-erased references; i.e. `foo(r)` where `r: &mut dyn RngCore`. Without -/// this it would be necessary to write `foo(&mut r)`. -/// -/// An alternative pattern is possible: `fn foo(rng: R)`. This has some -/// trade-offs. It allows the argument to be consumed directly without a `&mut` -/// (which is how `from_rng(thread_rng())` works); also it still works directly -/// on references (including type-erased references). Unfortunately within the -/// function `foo` it is not known whether `rng` is a reference type or not, -/// hence many uses of `rng` require an extra reference, either explicitly -/// (`distr.sample(&mut rng)`) or implicitly (`rng.gen()`); one may hope the -/// optimiser can remove redundant references later. -/// -/// Example: -/// -/// ``` -/// # use rand::thread_rng; -/// use rand::Rng; -/// -/// fn foo(rng: &mut R) -> f32 { -/// rng.gen() -/// } -/// -/// # let v = foo(&mut thread_rng()); -/// ``` -pub trait Rng: RngCore { - /// Return a random value supporting the [`Standard`] distribution. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut rng = thread_rng(); - /// let x: u32 = rng.gen(); - /// println!("{}", x); - /// println!("{:?}", rng.gen::<(f64, bool)>()); - /// ``` - /// - /// # Arrays and tuples - /// - /// The `rng.gen()` method is able to generate arrays (up to 32 elements) - /// and tuples (up to 12 elements), so long as all element types can be - /// generated. - /// When using `rustc` ≥ 1.51, enable the `min_const_gen` feature to support - /// arrays larger than 32 elements. - /// - /// For arrays of integers, especially for those with small element types - /// (< 64 bit), it will likely be faster to instead use [`Rng::fill`]. - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut rng = thread_rng(); - /// let tuple: (u8, i32, char) = rng.gen(); // arbitrary tuple support - /// - /// let arr1: [f32; 32] = rng.gen(); // array construction - /// let mut arr2 = [0u8; 128]; - /// rng.fill(&mut arr2); // array fill - /// ``` - /// - /// [`Standard`]: distributions::Standard - #[inline] - fn gen(&mut self) -> T - where Standard: Distribution { - Standard.sample(self) - } - - /// Generate a random value in the given range. - /// - /// This function is optimised for the case that only a single sample is - /// made from the given range. See also the [`Uniform`] distribution - /// type which may be faster if sampling from the same range repeatedly. - /// - /// Only `gen_range(low..high)` and `gen_range(low..=high)` are supported. - /// - /// # Panics - /// - /// Panics if the range is empty. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut rng = thread_rng(); - /// - /// // Exclusive range - /// let n: u32 = rng.gen_range(0..10); - /// println!("{}", n); - /// let m: f64 = rng.gen_range(-40.0..1.3e5); - /// println!("{}", m); - /// - /// // Inclusive range - /// let n: u32 = rng.gen_range(0..=10); - /// println!("{}", n); - /// ``` - /// - /// [`Uniform`]: distributions::uniform::Uniform - fn gen_range(&mut self, range: R) -> T - where - T: SampleUniform, - R: SampleRange - { - assert!(!range.is_empty(), "cannot sample empty range"); - range.sample_single(self) - } - - /// Sample a new value, using the given distribution. - /// - /// ### Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// use rand::distributions::Uniform; - /// - /// let mut rng = thread_rng(); - /// let x = rng.sample(Uniform::new(10u32, 15)); - /// // Type annotation requires two types, the type and distribution; the - /// // distribution can be inferred. - /// let y = rng.sample::(Uniform::new(10, 15)); - /// ``` - fn sample>(&mut self, distr: D) -> T { - distr.sample(self) - } - - /// Create an iterator that generates values using the given distribution. - /// - /// Note that this function takes its arguments by value. This works since - /// `(&mut R): Rng where R: Rng` and - /// `(&D): Distribution where D: Distribution`, - /// however borrowing is not automatic hence `rng.sample_iter(...)` may - /// need to be replaced with `(&mut rng).sample_iter(...)`. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// use rand::distributions::{Alphanumeric, Uniform, Standard}; - /// - /// let mut rng = thread_rng(); - /// - /// // Vec of 16 x f32: - /// let v: Vec = (&mut rng).sample_iter(Standard).take(16).collect(); - /// - /// // String: - /// let s: String = (&mut rng).sample_iter(Alphanumeric) - /// .take(7) - /// .map(char::from) - /// .collect(); - /// - /// // Combined values - /// println!("{:?}", (&mut rng).sample_iter(Standard).take(5) - /// .collect::>()); - /// - /// // Dice-rolling: - /// let die_range = Uniform::new_inclusive(1, 6); - /// let mut roll_die = (&mut rng).sample_iter(die_range); - /// while roll_die.next().unwrap() != 6 { - /// println!("Not a 6; rolling again!"); - /// } - /// ``` - fn sample_iter(self, distr: D) -> distributions::DistIter - where - D: Distribution, - Self: Sized, - { - distr.sample_iter(self) - } - - /// Fill any type implementing [`Fill`] with random data - /// - /// The distribution is expected to be uniform with portable results, but - /// this cannot be guaranteed for third-party implementations. - /// - /// This is identical to [`try_fill`] except that it panics on error. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut arr = [0i8; 20]; - /// thread_rng().fill(&mut arr[..]); - /// ``` - /// - /// [`fill_bytes`]: RngCore::fill_bytes - /// [`try_fill`]: Rng::try_fill - fn fill(&mut self, dest: &mut T) { - dest.try_fill(self).unwrap_or_else(|_| panic!("Rng::fill failed")) - } - - /// Fill any type implementing [`Fill`] with random data - /// - /// The distribution is expected to be uniform with portable results, but - /// this cannot be guaranteed for third-party implementations. - /// - /// This is identical to [`fill`] except that it forwards errors. - /// - /// # Example - /// - /// ``` - /// # use rand::Error; - /// use rand::{thread_rng, Rng}; - /// - /// # fn try_inner() -> Result<(), Error> { - /// let mut arr = [0u64; 4]; - /// thread_rng().try_fill(&mut arr[..])?; - /// # Ok(()) - /// # } - /// - /// # try_inner().unwrap() - /// ``` - /// - /// [`try_fill_bytes`]: RngCore::try_fill_bytes - /// [`fill`]: Rng::fill - fn try_fill(&mut self, dest: &mut T) -> Result<(), Error> { - dest.try_fill(self) - } - - /// Return a bool with a probability `p` of being true. - /// - /// See also the [`Bernoulli`] distribution, which may be faster if - /// sampling from the same probability repeatedly. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut rng = thread_rng(); - /// println!("{}", rng.gen_bool(1.0 / 3.0)); - /// ``` - /// - /// # Panics - /// - /// If `p < 0` or `p > 1`. - /// - /// [`Bernoulli`]: distributions::Bernoulli - #[inline] - fn gen_bool(&mut self, p: f64) -> bool { - let d = distributions::Bernoulli::new(p).unwrap(); - self.sample(d) - } - - /// Return a bool with a probability of `numerator/denominator` of being - /// true. I.e. `gen_ratio(2, 3)` has chance of 2 in 3, or about 67%, of - /// returning true. If `numerator == denominator`, then the returned value - /// is guaranteed to be `true`. If `numerator == 0`, then the returned - /// value is guaranteed to be `false`. - /// - /// See also the [`Bernoulli`] distribution, which may be faster if - /// sampling from the same `numerator` and `denominator` repeatedly. - /// - /// # Panics - /// - /// If `denominator == 0` or `numerator > denominator`. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut rng = thread_rng(); - /// println!("{}", rng.gen_ratio(2, 3)); - /// ``` - /// - /// [`Bernoulli`]: distributions::Bernoulli - #[inline] - fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool { - let d = distributions::Bernoulli::from_ratio(numerator, denominator).unwrap(); - self.sample(d) - } -} - -impl Rng for R {} - -/// Types which may be filled with random data -/// -/// This trait allows arrays to be efficiently filled with random data. -/// -/// Implementations are expected to be portable across machines unless -/// clearly documented otherwise (see the -/// [Chapter on Portability](https://rust-random.github.io/book/portability.html)). -pub trait Fill { - /// Fill self with random data - fn try_fill(&mut self, rng: &mut R) -> Result<(), Error>; -} - -macro_rules! impl_fill_each { - () => {}; - ($t:ty) => { - impl Fill for [$t] { - fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { - for elt in self.iter_mut() { - *elt = rng.gen(); - } - Ok(()) - } - } - }; - ($t:ty, $($tt:ty,)*) => { - impl_fill_each!($t); - impl_fill_each!($($tt,)*); - }; -} - -impl_fill_each!(bool, char, f32, f64,); - -impl Fill for [u8] { - fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { - rng.try_fill_bytes(self) - } -} - -macro_rules! impl_fill { - () => {}; - ($t:ty) => { - impl Fill for [$t] { - #[inline(never)] // in micro benchmarks, this improves performance - fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { - if self.len() > 0 { - rng.try_fill_bytes(unsafe { - slice::from_raw_parts_mut(self.as_mut_ptr() - as *mut u8, - self.len() * mem::size_of::<$t>() - ) - })?; - for x in self { - *x = x.to_le(); - } - } - Ok(()) - } - } - - impl Fill for [Wrapping<$t>] { - #[inline(never)] - fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { - if self.len() > 0 { - rng.try_fill_bytes(unsafe { - slice::from_raw_parts_mut(self.as_mut_ptr() - as *mut u8, - self.len() * mem::size_of::<$t>() - ) - })?; - for x in self { - *x = Wrapping(x.0.to_le()); - } - } - Ok(()) - } - } - }; - ($t:ty, $($tt:ty,)*) => { - impl_fill!($t); - // TODO: this could replace above impl once Rust #32463 is fixed - // impl_fill!(Wrapping<$t>); - impl_fill!($($tt,)*); - } -} - -impl_fill!(u16, u32, u64, usize,); -#[cfg(not(target_os = "emscripten"))] -impl_fill!(u128); -impl_fill!(i8, i16, i32, i64, isize,); -#[cfg(not(target_os = "emscripten"))] -impl_fill!(i128); - -#[cfg(feature = "min_const_gen")] -impl Fill for [T; N] -where [T]: Fill -{ - fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { - self[..].try_fill(rng) - } -} - -#[cfg(not(feature = "min_const_gen"))] -macro_rules! impl_fill_arrays { - ($n:expr,) => {}; - ($n:expr, $N:ident) => { - impl Fill for [T; $n] where [T]: Fill { - fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { - self[..].try_fill(rng) - } - } - }; - ($n:expr, $N:ident, $($NN:ident,)*) => { - impl_fill_arrays!($n, $N); - impl_fill_arrays!($n - 1, $($NN,)*); - }; - (!div $n:expr,) => {}; - (!div $n:expr, $N:ident, $($NN:ident,)*) => { - impl_fill_arrays!($n, $N); - impl_fill_arrays!(!div $n / 2, $($NN,)*); - }; -} -#[cfg(not(feature = "min_const_gen"))] -#[rustfmt::skip] -impl_fill_arrays!(32, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,); -#[cfg(not(feature = "min_const_gen"))] -impl_fill_arrays!(!div 4096, N,N,N,N,N,N,N,); - -#[cfg(test)] -mod test { - use super::*; - use crate::test::rng; - use crate::rngs::mock::StepRng; - #[cfg(feature = "alloc")] use alloc::boxed::Box; - - #[test] - fn test_fill_bytes_default() { - let mut r = StepRng::new(0x11_22_33_44_55_66_77_88, 0); - - // check every remainder mod 8, both in small and big vectors. - let lengths = [0, 1, 2, 3, 4, 5, 6, 7, 80, 81, 82, 83, 84, 85, 86, 87]; - for &n in lengths.iter() { - let mut buffer = [0u8; 87]; - let v = &mut buffer[0..n]; - r.fill_bytes(v); - - // use this to get nicer error messages. - for (i, &byte) in v.iter().enumerate() { - if byte == 0 { - panic!("byte {} of {} is zero", i, n) - } - } - } - } - - #[test] - fn test_fill() { - let x = 9041086907909331047; // a random u64 - let mut rng = StepRng::new(x, 0); - - // Convert to byte sequence and back to u64; byte-swap twice if BE. - let mut array = [0u64; 2]; - rng.fill(&mut array[..]); - assert_eq!(array, [x, x]); - assert_eq!(rng.next_u64(), x); - - // Convert to bytes then u32 in LE order - let mut array = [0u32; 2]; - rng.fill(&mut array[..]); - assert_eq!(array, [x as u32, (x >> 32) as u32]); - assert_eq!(rng.next_u32(), x as u32); - - // Check equivalence using wrapped arrays - let mut warray = [Wrapping(0u32); 2]; - rng.fill(&mut warray[..]); - assert_eq!(array[0], warray[0].0); - assert_eq!(array[1], warray[1].0); - - // Check equivalence for generated floats - let mut array = [0f32; 2]; - rng.fill(&mut array); - let gen: [f32; 2] = rng.gen(); - assert_eq!(array, gen); - } - - #[test] - fn test_fill_empty() { - let mut array = [0u32; 0]; - let mut rng = StepRng::new(0, 1); - rng.fill(&mut array); - rng.fill(&mut array[..]); - } - - #[test] - fn test_gen_range_int() { - let mut r = rng(101); - for _ in 0..1000 { - let a = r.gen_range(-4711..17); - assert!((-4711..17).contains(&a)); - let a: i8 = r.gen_range(-3..42); - assert!((-3..42).contains(&a)); - let a: u16 = r.gen_range(10..99); - assert!((10..99).contains(&a)); - let a: i32 = r.gen_range(-100..2000); - assert!((-100..2000).contains(&a)); - let a: u32 = r.gen_range(12..=24); - assert!((12..=24).contains(&a)); - - assert_eq!(r.gen_range(0u32..1), 0u32); - assert_eq!(r.gen_range(-12i64..-11), -12i64); - assert_eq!(r.gen_range(3_000_000..3_000_001), 3_000_000); - } - } - - #[test] - fn test_gen_range_float() { - let mut r = rng(101); - for _ in 0..1000 { - let a = r.gen_range(-4.5..1.7); - assert!((-4.5..1.7).contains(&a)); - let a = r.gen_range(-1.1..=-0.3); - assert!((-1.1..=-0.3).contains(&a)); - - assert_eq!(r.gen_range(0.0f32..=0.0), 0.); - assert_eq!(r.gen_range(-11.0..=-11.0), -11.); - assert_eq!(r.gen_range(3_000_000.0..=3_000_000.0), 3_000_000.); - } - } - - #[test] - #[should_panic] - fn test_gen_range_panic_int() { - #![allow(clippy::reversed_empty_ranges)] - let mut r = rng(102); - r.gen_range(5..-2); - } - - #[test] - #[should_panic] - fn test_gen_range_panic_usize() { - #![allow(clippy::reversed_empty_ranges)] - let mut r = rng(103); - r.gen_range(5..2); - } - - #[test] - fn test_gen_bool() { - #![allow(clippy::bool_assert_comparison)] - - let mut r = rng(105); - for _ in 0..5 { - assert_eq!(r.gen_bool(0.0), false); - assert_eq!(r.gen_bool(1.0), true); - } - } - - #[test] - fn test_rng_trait_object() { - use crate::distributions::{Distribution, Standard}; - let mut rng = rng(109); - let mut r = &mut rng as &mut dyn RngCore; - r.next_u32(); - r.gen::(); - assert_eq!(r.gen_range(0..1), 0); - let _c: u8 = Standard.sample(&mut r); - } - - #[test] - #[cfg(feature = "alloc")] - fn test_rng_boxed_trait() { - use crate::distributions::{Distribution, Standard}; - let rng = rng(110); - let mut r = Box::new(rng) as Box; - r.next_u32(); - r.gen::(); - assert_eq!(r.gen_range(0..1), 0); - let _c: u8 = Standard.sample(&mut r); - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_gen_ratio_average() { - const NUM: u32 = 3; - const DENOM: u32 = 10; - const N: u32 = 100_000; - - let mut sum: u32 = 0; - let mut rng = rng(111); - for _ in 0..N { - if rng.gen_ratio(NUM, DENOM) { - sum += 1; - } - } - // Have Binomial(N, NUM/DENOM) distribution - let expected = (NUM * N) / DENOM; // exact integer - assert!(((sum - expected) as i32).abs() < 500); - } -} diff -Nru cargo-0.58.0/vendor/rand/src/rngs/adapter/mod.rs cargo-0.60.0ubuntu1/vendor/rand/src/rngs/adapter/mod.rs --- cargo-0.58.0/vendor/rand/src/rngs/adapter/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rngs/adapter/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +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. - -//! Wrappers / adapters forming RNGs - -mod read; -mod reseeding; - -#[allow(deprecated)] -pub use self::read::{ReadError, ReadRng}; -pub use self::reseeding::ReseedingRng; diff -Nru cargo-0.58.0/vendor/rand/src/rngs/adapter/read.rs cargo-0.60.0ubuntu1/vendor/rand/src/rngs/adapter/read.rs --- cargo-0.58.0/vendor/rand/src/rngs/adapter/read.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rngs/adapter/read.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A wrapper around any Read to treat it as an RNG. - -#![allow(deprecated)] - -use std::fmt; -use std::io::Read; - -use rand_core::{impls, Error, RngCore}; - - -/// An RNG that reads random bytes straight from any type supporting -/// [`std::io::Read`], for example files. -/// -/// This will work best with an infinite reader, but that is not required. -/// -/// This can be used with `/dev/urandom` on Unix but it is recommended to use -/// [`OsRng`] instead. -/// -/// # Panics -/// -/// `ReadRng` uses [`std::io::Read::read_exact`], which retries on interrupts. -/// All other errors from the underlying reader, including when it does not -/// have enough data, will only be reported through [`try_fill_bytes`]. -/// The other [`RngCore`] methods will panic in case of an error. -/// -/// [`OsRng`]: crate::rngs::OsRng -/// [`try_fill_bytes`]: RngCore::try_fill_bytes -#[derive(Debug)] -#[deprecated(since="0.8.4", note="removal due to lack of usage")] -pub struct ReadRng { - reader: R, -} - -impl ReadRng { - /// Create a new `ReadRng` from a `Read`. - pub fn new(r: R) -> ReadRng { - ReadRng { reader: r } - } -} - -impl RngCore for ReadRng { - fn next_u32(&mut self) -> u32 { - impls::next_u32_via_fill(self) - } - - fn next_u64(&mut self) -> u64 { - impls::next_u64_via_fill(self) - } - - fn fill_bytes(&mut self, dest: &mut [u8]) { - self.try_fill_bytes(dest).unwrap_or_else(|err| { - panic!( - "reading random bytes from Read implementation failed; error: {}", - err - ) - }); - } - - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - if dest.is_empty() { - return Ok(()); - } - // Use `std::io::read_exact`, which retries on `ErrorKind::Interrupted`. - self.reader - .read_exact(dest) - .map_err(|e| Error::new(ReadError(e))) - } -} - -/// `ReadRng` error type -#[derive(Debug)] -#[deprecated(since="0.8.4")] -pub struct ReadError(std::io::Error); - -impl fmt::Display for ReadError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "ReadError: {}", self.0) - } -} - -impl std::error::Error for ReadError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - Some(&self.0) - } -} - - -#[cfg(test)] -mod test { - use std::println; - - use super::ReadRng; - use crate::RngCore; - - #[test] - fn test_reader_rng_u64() { - // transmute from the target to avoid endianness concerns. - #[rustfmt::skip] - let v = [0u8, 0, 0, 0, 0, 0, 0, 1, - 0, 4, 0, 0, 3, 0, 0, 2, - 5, 0, 0, 0, 0, 0, 0, 0]; - let mut rng = ReadRng::new(&v[..]); - - assert_eq!(rng.next_u64(), 1 << 56); - assert_eq!(rng.next_u64(), (2 << 56) + (3 << 32) + (4 << 8)); - assert_eq!(rng.next_u64(), 5); - } - - #[test] - fn test_reader_rng_u32() { - let v = [0u8, 0, 0, 1, 0, 0, 2, 0, 3, 0, 0, 0]; - let mut rng = ReadRng::new(&v[..]); - - assert_eq!(rng.next_u32(), 1 << 24); - assert_eq!(rng.next_u32(), 2 << 16); - assert_eq!(rng.next_u32(), 3); - } - - #[test] - fn test_reader_rng_fill_bytes() { - let v = [1u8, 2, 3, 4, 5, 6, 7, 8]; - let mut w = [0u8; 8]; - - let mut rng = ReadRng::new(&v[..]); - rng.fill_bytes(&mut w); - - assert!(v == w); - } - - #[test] - fn test_reader_rng_insufficient_bytes() { - let v = [1u8, 2, 3, 4, 5, 6, 7, 8]; - let mut w = [0u8; 9]; - - let mut rng = ReadRng::new(&v[..]); - - let result = rng.try_fill_bytes(&mut w); - assert!(result.is_err()); - println!("Error: {}", result.unwrap_err()); - } -} diff -Nru cargo-0.58.0/vendor/rand/src/rngs/adapter/reseeding.rs cargo-0.60.0ubuntu1/vendor/rand/src/rngs/adapter/reseeding.rs --- cargo-0.58.0/vendor/rand/src/rngs/adapter/reseeding.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rngs/adapter/reseeding.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,372 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A wrapper around another PRNG that reseeds it after it -//! generates a certain number of random bytes. - -use core::mem::size_of; - -use rand_core::block::{BlockRng, BlockRngCore}; -use rand_core::{CryptoRng, Error, RngCore, SeedableRng}; - -/// A wrapper around any PRNG that implements [`BlockRngCore`], that adds the -/// ability to reseed it. -/// -/// `ReseedingRng` reseeds the underlying PRNG in the following cases: -/// -/// - On a manual call to [`reseed()`]. -/// - After `clone()`, the clone will be reseeded on first use. -/// - After a process is forked, the RNG in the child process is reseeded within -/// the next few generated values, depending on the block size of the -/// underlying PRNG. For ChaCha and Hc128 this is a maximum of -/// 15 `u32` values before reseeding. -/// - After the PRNG has generated a configurable number of random bytes. -/// -/// # When should reseeding after a fixed number of generated bytes be used? -/// -/// Reseeding after a fixed number of generated bytes is never strictly -/// *necessary*. Cryptographic PRNGs don't have a limited number of bytes they -/// can output, or at least not a limit reachable in any practical way. There is -/// no such thing as 'running out of entropy'. -/// -/// Occasionally reseeding can be seen as some form of 'security in depth'. Even -/// if in the future a cryptographic weakness is found in the CSPRNG being used, -/// or a flaw in the implementation, occasionally reseeding should make -/// exploiting it much more difficult or even impossible. -/// -/// Use [`ReseedingRng::new`] with a `threshold` of `0` to disable reseeding -/// after a fixed number of generated bytes. -/// -/// # Error handling -/// -/// Although unlikely, reseeding the wrapped PRNG can fail. `ReseedingRng` will -/// never panic but try to handle the error intelligently through some -/// combination of retrying and delaying reseeding until later. -/// If handling the source error fails `ReseedingRng` will continue generating -/// data from the wrapped PRNG without reseeding. -/// -/// Manually calling [`reseed()`] will not have this retry or delay logic, but -/// reports the error. -/// -/// # Example -/// -/// ``` -/// use rand::prelude::*; -/// use rand_chacha::ChaCha20Core; // Internal part of ChaChaRng that -/// // implements BlockRngCore -/// use rand::rngs::OsRng; -/// use rand::rngs::adapter::ReseedingRng; -/// -/// let prng = ChaCha20Core::from_entropy(); -/// let mut reseeding_rng = ReseedingRng::new(prng, 0, OsRng); -/// -/// println!("{}", reseeding_rng.gen::()); -/// -/// let mut cloned_rng = reseeding_rng.clone(); -/// assert!(reseeding_rng.gen::() != cloned_rng.gen::()); -/// ``` -/// -/// [`BlockRngCore`]: rand_core::block::BlockRngCore -/// [`ReseedingRng::new`]: ReseedingRng::new -/// [`reseed()`]: ReseedingRng::reseed -#[derive(Debug)] -pub struct ReseedingRng(BlockRng>) -where - R: BlockRngCore + SeedableRng, - Rsdr: RngCore; - -impl ReseedingRng -where - R: BlockRngCore + SeedableRng, - Rsdr: RngCore, -{ - /// Create a new `ReseedingRng` from an existing PRNG, combined with a RNG - /// to use as reseeder. - /// - /// `threshold` sets the number of generated bytes after which to reseed the - /// PRNG. Set it to zero to never reseed based on the number of generated - /// values. - pub fn new(rng: R, threshold: u64, reseeder: Rsdr) -> Self { - ReseedingRng(BlockRng::new(ReseedingCore::new(rng, threshold, reseeder))) - } - - /// Reseed the internal PRNG. - pub fn reseed(&mut self) -> Result<(), Error> { - self.0.core.reseed() - } -} - -// TODO: this should be implemented for any type where the inner type -// implements RngCore, but we can't specify that because ReseedingCore is private -impl RngCore for ReseedingRng -where - R: BlockRngCore + SeedableRng, - ::Results: AsRef<[u32]> + AsMut<[u32]>, -{ - #[inline(always)] - fn next_u32(&mut self) -> u32 { - self.0.next_u32() - } - - #[inline(always)] - fn next_u64(&mut self) -> u64 { - self.0.next_u64() - } - - fn fill_bytes(&mut self, dest: &mut [u8]) { - self.0.fill_bytes(dest) - } - - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.0.try_fill_bytes(dest) - } -} - -impl Clone for ReseedingRng -where - R: BlockRngCore + SeedableRng + Clone, - Rsdr: RngCore + Clone, -{ - fn clone(&self) -> ReseedingRng { - // Recreating `BlockRng` seems easier than cloning it and resetting - // the index. - ReseedingRng(BlockRng::new(self.0.core.clone())) - } -} - -impl CryptoRng for ReseedingRng -where - R: BlockRngCore + SeedableRng + CryptoRng, - Rsdr: RngCore + CryptoRng, -{ -} - -#[derive(Debug)] -struct ReseedingCore { - inner: R, - reseeder: Rsdr, - threshold: i64, - bytes_until_reseed: i64, - fork_counter: usize, -} - -impl BlockRngCore for ReseedingCore -where - R: BlockRngCore + SeedableRng, - Rsdr: RngCore, -{ - type Item = ::Item; - type Results = ::Results; - - fn generate(&mut self, results: &mut Self::Results) { - let global_fork_counter = fork::get_fork_counter(); - if self.bytes_until_reseed <= 0 || self.is_forked(global_fork_counter) { - // We get better performance by not calling only `reseed` here - // and continuing with the rest of the function, but by directly - // returning from a non-inlined function. - return self.reseed_and_generate(results, global_fork_counter); - } - let num_bytes = results.as_ref().len() * size_of::(); - self.bytes_until_reseed -= num_bytes as i64; - self.inner.generate(results); - } -} - -impl ReseedingCore -where - R: BlockRngCore + SeedableRng, - Rsdr: RngCore, -{ - /// Create a new `ReseedingCore`. - fn new(rng: R, threshold: u64, reseeder: Rsdr) -> Self { - use ::core::i64::MAX; - fork::register_fork_handler(); - - // Because generating more values than `i64::MAX` takes centuries on - // current hardware, we just clamp to that value. - // Also we set a threshold of 0, which indicates no limit, to that - // value. - let threshold = if threshold == 0 { - MAX - } else if threshold <= MAX as u64 { - threshold as i64 - } else { - MAX - }; - - ReseedingCore { - inner: rng, - reseeder, - threshold: threshold as i64, - bytes_until_reseed: threshold as i64, - fork_counter: 0, - } - } - - /// Reseed the internal PRNG. - fn reseed(&mut self) -> Result<(), Error> { - R::from_rng(&mut self.reseeder).map(|result| { - self.bytes_until_reseed = self.threshold; - self.inner = result - }) - } - - fn is_forked(&self, global_fork_counter: usize) -> bool { - // In theory, on 32-bit platforms, it is possible for - // `global_fork_counter` to wrap around after ~4e9 forks. - // - // This check will detect a fork in the normal case where - // `fork_counter < global_fork_counter`, and also when the difference - // between both is greater than `isize::MAX` (wrapped around). - // - // It will still fail to detect a fork if there have been more than - // `isize::MAX` forks, without any reseed in between. Seems unlikely - // enough. - (self.fork_counter.wrapping_sub(global_fork_counter) as isize) < 0 - } - - #[inline(never)] - fn reseed_and_generate( - &mut self, results: &mut ::Results, global_fork_counter: usize, - ) { - #![allow(clippy::if_same_then_else)] // false positive - if self.is_forked(global_fork_counter) { - info!("Fork detected, reseeding RNG"); - } else { - trace!("Reseeding RNG (periodic reseed)"); - } - - let num_bytes = results.as_ref().len() * size_of::<::Item>(); - - if let Err(e) = self.reseed() { - warn!("Reseeding RNG failed: {}", e); - let _ = e; - } - self.fork_counter = global_fork_counter; - - self.bytes_until_reseed = self.threshold - num_bytes as i64; - self.inner.generate(results); - } -} - -impl Clone for ReseedingCore -where - R: BlockRngCore + SeedableRng + Clone, - Rsdr: RngCore + Clone, -{ - fn clone(&self) -> ReseedingCore { - ReseedingCore { - inner: self.inner.clone(), - reseeder: self.reseeder.clone(), - threshold: self.threshold, - bytes_until_reseed: 0, // reseed clone on first use - fork_counter: self.fork_counter, - } - } -} - -impl CryptoRng for ReseedingCore -where - R: BlockRngCore + SeedableRng + CryptoRng, - Rsdr: RngCore + CryptoRng, -{ -} - - -#[cfg(all(unix, not(target_os = "emscripten")))] -mod fork { - use core::sync::atomic::{AtomicUsize, Ordering}; - use std::sync::Once; - - // Fork protection - // - // We implement fork protection on Unix using `pthread_atfork`. - // When the process is forked, we increment `RESEEDING_RNG_FORK_COUNTER`. - // Every `ReseedingRng` stores the last known value of the static in - // `fork_counter`. If the cached `fork_counter` is less than - // `RESEEDING_RNG_FORK_COUNTER`, it is time to reseed this RNG. - // - // If reseeding fails, we don't deal with this by setting a delay, but just - // don't update `fork_counter`, so a reseed is attempted as soon as - // possible. - - static RESEEDING_RNG_FORK_COUNTER: AtomicUsize = AtomicUsize::new(0); - - pub fn get_fork_counter() -> usize { - RESEEDING_RNG_FORK_COUNTER.load(Ordering::Relaxed) - } - - extern "C" fn fork_handler() { - // Note: fetch_add is defined to wrap on overflow - // (which is what we want). - RESEEDING_RNG_FORK_COUNTER.fetch_add(1, Ordering::Relaxed); - } - - pub fn register_fork_handler() { - static REGISTER: Once = Once::new(); - REGISTER.call_once(|| unsafe { - libc::pthread_atfork(None, None, Some(fork_handler)); - }); - } -} - -#[cfg(not(all(unix, not(target_os = "emscripten"))))] -mod fork { - pub fn get_fork_counter() -> usize { - 0 - } - pub fn register_fork_handler() {} -} - - -#[cfg(feature = "std_rng")] -#[cfg(test)] -mod test { - use super::ReseedingRng; - use crate::rngs::mock::StepRng; - use crate::rngs::std::Core; - use crate::{Rng, SeedableRng}; - - #[test] - fn test_reseeding() { - let mut zero = StepRng::new(0, 0); - let rng = Core::from_rng(&mut zero).unwrap(); - let thresh = 1; // reseed every time the buffer is exhausted - let mut reseeding = ReseedingRng::new(rng, thresh, zero); - - // RNG buffer size is [u32; 64] - // Debug is only implemented up to length 32 so use two arrays - let mut buf = ([0u32; 32], [0u32; 32]); - reseeding.fill(&mut buf.0); - reseeding.fill(&mut buf.1); - let seq = buf; - for _ in 0..10 { - reseeding.fill(&mut buf.0); - reseeding.fill(&mut buf.1); - assert_eq!(buf, seq); - } - } - - #[test] - fn test_clone_reseeding() { - #![allow(clippy::redundant_clone)] - - let mut zero = StepRng::new(0, 0); - let rng = Core::from_rng(&mut zero).unwrap(); - let mut rng1 = ReseedingRng::new(rng, 32 * 4, zero); - - let first: u32 = rng1.gen(); - for _ in 0..10 { - let _ = rng1.gen::(); - } - - let mut rng2 = rng1.clone(); - assert_eq!(first, rng2.gen::()); - } -} diff -Nru cargo-0.58.0/vendor/rand/src/rngs/mock.rs cargo-0.60.0ubuntu1/vendor/rand/src/rngs/mock.rs --- cargo-0.58.0/vendor/rand/src/rngs/mock.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rngs/mock.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +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. - -//! Mock random number generator - -use rand_core::{impls, Error, RngCore}; - -#[cfg(feature = "serde1")] -use serde::{Serialize, Deserialize}; - -/// A simple implementation of `RngCore` for testing purposes. -/// -/// This generates an arithmetic sequence (i.e. adds a constant each step) -/// over a `u64` number, using wrapping arithmetic. If the increment is 0 -/// the generator yields a constant. -/// -/// ``` -/// use rand::Rng; -/// use rand::rngs::mock::StepRng; -/// -/// let mut my_rng = StepRng::new(2, 1); -/// let sample: [u64; 3] = my_rng.gen(); -/// assert_eq!(sample, [2, 3, 4]); -/// ``` -#[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub struct StepRng { - v: u64, - a: u64, -} - -impl StepRng { - /// Create a `StepRng`, yielding an arithmetic sequence starting with - /// `initial` and incremented by `increment` each time. - pub fn new(initial: u64, increment: u64) -> Self { - StepRng { - v: initial, - a: increment, - } - } -} - -impl RngCore for StepRng { - #[inline] - fn next_u32(&mut self) -> u32 { - self.next_u64() as u32 - } - - #[inline] - fn next_u64(&mut self) -> u64 { - let result = self.v; - self.v = self.v.wrapping_add(self.a); - result - } - - #[inline] - fn fill_bytes(&mut self, dest: &mut [u8]) { - impls::fill_bytes_via_next(self, dest); - } - - #[inline] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.fill_bytes(dest); - Ok(()) - } -} - -#[cfg(test)] -mod tests { - #[test] - #[cfg(feature = "serde1")] - fn test_serialization_step_rng() { - use super::StepRng; - - let some_rng = StepRng::new(42, 7); - let de_some_rng: StepRng = - bincode::deserialize(&bincode::serialize(&some_rng).unwrap()).unwrap(); - assert_eq!(some_rng.v, de_some_rng.v); - assert_eq!(some_rng.a, de_some_rng.a); - - } -} diff -Nru cargo-0.58.0/vendor/rand/src/rngs/mod.rs cargo-0.60.0ubuntu1/vendor/rand/src/rngs/mod.rs --- cargo-0.58.0/vendor/rand/src/rngs/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rngs/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +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. - -//! Random number generators and adapters -//! -//! ## Background: Random number generators (RNGs) -//! -//! Computers cannot produce random numbers from nowhere. We classify -//! random number generators as follows: -//! -//! - "True" random number generators (TRNGs) use hard-to-predict data sources -//! (e.g. the high-resolution parts of event timings and sensor jitter) to -//! harvest random bit-sequences, apply algorithms to remove bias and -//! estimate available entropy, then combine these bits into a byte-sequence -//! or an entropy pool. This job is usually done by the operating system or -//! a hardware generator (HRNG). -//! - "Pseudo"-random number generators (PRNGs) use algorithms to transform a -//! seed into a sequence of pseudo-random numbers. These generators can be -//! fast and produce well-distributed unpredictable random numbers (or not). -//! They are usually deterministic: given algorithm and seed, the output -//! sequence can be reproduced. They have finite period and eventually loop; -//! with many algorithms this period is fixed and can be proven sufficiently -//! long, while others are chaotic and the period depends on the seed. -//! - "Cryptographically secure" pseudo-random number generators (CSPRNGs) -//! are the sub-set of PRNGs which are secure. Security of the generator -//! relies both on hiding the internal state and using a strong algorithm. -//! -//! ## Traits and functionality -//! -//! All RNGs implement the [`RngCore`] trait, as a consequence of which the -//! [`Rng`] extension trait is automatically implemented. Secure RNGs may -//! additionally implement the [`CryptoRng`] trait. -//! -//! All PRNGs require a seed to produce their random number sequence. The -//! [`SeedableRng`] trait provides three ways of constructing PRNGs: -//! -//! - `from_seed` accepts a type specific to the PRNG -//! - `from_rng` allows a PRNG to be seeded from any other RNG -//! - `seed_from_u64` allows any PRNG to be seeded from a `u64` insecurely -//! - `from_entropy` securely seeds a PRNG from fresh entropy -//! -//! Use the [`rand_core`] crate when implementing your own RNGs. -//! -//! ## Our generators -//! -//! This crate provides several random number generators: -//! -//! - [`OsRng`] is an interface to the operating system's random number -//! source. Typically the operating system uses a CSPRNG with entropy -//! provided by a TRNG and some type of on-going re-seeding. -//! - [`ThreadRng`], provided by the [`thread_rng`] function, is a handle to a -//! thread-local CSPRNG with periodic seeding from [`OsRng`]. Because this -//! is local, it is typically much faster than [`OsRng`]. It should be -//! secure, though the paranoid may prefer [`OsRng`]. -//! - [`StdRng`] is a CSPRNG chosen for good performance and trust of security -//! (based on reviews, maturity and usage). The current algorithm is ChaCha12, -//! which is well established and rigorously analysed. -//! [`StdRng`] provides the algorithm used by [`ThreadRng`] but without -//! periodic reseeding. -//! - [`SmallRng`] is an **insecure** PRNG designed to be fast, simple, require -//! little memory, and have good output quality. -//! -//! The algorithms selected for [`StdRng`] and [`SmallRng`] may change in any -//! release and may be platform-dependent, therefore they should be considered -//! **not reproducible**. -//! -//! ## Additional generators -//! -//! **TRNGs**: The [`rdrand`] crate provides an interface to the RDRAND and -//! RDSEED instructions available in modern Intel and AMD CPUs. -//! The [`rand_jitter`] crate provides a user-space implementation of -//! entropy harvesting from CPU timer jitter, but is very slow and has -//! [security issues](https://github.com/rust-random/rand/issues/699). -//! -//! **PRNGs**: Several companion crates are available, providing individual or -//! families of PRNG algorithms. These provide the implementations behind -//! [`StdRng`] and [`SmallRng`] but can also be used directly, indeed *should* -//! be used directly when **reproducibility** matters. -//! Some suggestions are: [`rand_chacha`], [`rand_pcg`], [`rand_xoshiro`]. -//! A full list can be found by searching for crates with the [`rng` tag]. -//! -//! [`Rng`]: crate::Rng -//! [`RngCore`]: crate::RngCore -//! [`CryptoRng`]: crate::CryptoRng -//! [`SeedableRng`]: crate::SeedableRng -//! [`thread_rng`]: crate::thread_rng -//! [`rdrand`]: https://crates.io/crates/rdrand -//! [`rand_jitter`]: https://crates.io/crates/rand_jitter -//! [`rand_chacha`]: https://crates.io/crates/rand_chacha -//! [`rand_pcg`]: https://crates.io/crates/rand_pcg -//! [`rand_xoshiro`]: https://crates.io/crates/rand_xoshiro -//! [`rng` tag]: https://crates.io/keywords/rng - -#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] -#[cfg(feature = "std")] pub mod adapter; - -pub mod mock; // Public so we don't export `StepRng` directly, making it a bit - // more clear it is intended for testing. - -#[cfg(all(feature = "small_rng", target_pointer_width = "64"))] -mod xoshiro256plusplus; -#[cfg(all(feature = "small_rng", not(target_pointer_width = "64")))] -mod xoshiro128plusplus; -#[cfg(feature = "small_rng")] mod small; - -#[cfg(feature = "std_rng")] mod std; -#[cfg(all(feature = "std", feature = "std_rng"))] pub(crate) mod thread; - -#[cfg(feature = "small_rng")] pub use self::small::SmallRng; -#[cfg(feature = "std_rng")] pub use self::std::StdRng; -#[cfg(all(feature = "std", feature = "std_rng"))] pub use self::thread::ThreadRng; - -#[cfg_attr(doc_cfg, doc(cfg(feature = "getrandom")))] -#[cfg(feature = "getrandom")] pub use rand_core::OsRng; diff -Nru cargo-0.58.0/vendor/rand/src/rngs/small.rs cargo-0.60.0ubuntu1/vendor/rand/src/rngs/small.rs --- cargo-0.58.0/vendor/rand/src/rngs/small.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rngs/small.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +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 small fast RNG - -use rand_core::{Error, RngCore, SeedableRng}; - -#[cfg(target_pointer_width = "64")] -type Rng = super::xoshiro256plusplus::Xoshiro256PlusPlus; -#[cfg(not(target_pointer_width = "64"))] -type Rng = super::xoshiro128plusplus::Xoshiro128PlusPlus; - -/// A small-state, fast non-crypto PRNG -/// -/// `SmallRng` may be a good choice when a PRNG with small state, cheap -/// initialization, good statistical quality and good performance are required. -/// Note that depending on the application, [`StdRng`] may be faster on many -/// modern platforms while providing higher-quality randomness. Furthermore, -/// `SmallRng` is **not** a good choice when: -/// - Security against prediction is important. Use [`StdRng`] instead. -/// - Seeds with many zeros are provided. In such cases, it takes `SmallRng` -/// about 10 samples to produce 0 and 1 bits with equal probability. Either -/// provide seeds with an approximately equal number of 0 and 1 (for example -/// by using [`SeedableRng::from_entropy`] or [`SeedableRng::seed_from_u64`]), -/// or use [`StdRng`] instead. -/// -/// The algorithm is deterministic but should not be considered reproducible -/// due to dependence on platform and possible replacement in future -/// library versions. For a reproducible generator, use a named PRNG from an -/// external crate, e.g. [rand_xoshiro] or [rand_chacha]. -/// Refer also to [The Book](https://rust-random.github.io/book/guide-rngs.html). -/// -/// The PRNG algorithm in `SmallRng` is chosen to be efficient on the current -/// platform, without consideration for cryptography or security. The size of -/// its state is much smaller than [`StdRng`]. The current algorithm is -/// `Xoshiro256PlusPlus` on 64-bit platforms and `Xoshiro128PlusPlus` on 32-bit -/// platforms. Both are also implemented by the [rand_xoshiro] crate. -/// -/// # Examples -/// -/// Initializing `SmallRng` with a random seed can be done using [`SeedableRng::from_entropy`]: -/// -/// ``` -/// use rand::{Rng, SeedableRng}; -/// use rand::rngs::SmallRng; -/// -/// // Create small, cheap to initialize and fast RNG with a random seed. -/// // The randomness is supplied by the operating system. -/// let mut small_rng = SmallRng::from_entropy(); -/// # let v: u32 = small_rng.gen(); -/// ``` -/// -/// When initializing a lot of `SmallRng`'s, using [`thread_rng`] can be more -/// efficient: -/// -/// ``` -/// use rand::{SeedableRng, thread_rng}; -/// use rand::rngs::SmallRng; -/// -/// // Create a big, expensive to initialize and slower, but unpredictable RNG. -/// // This is cached and done only once per thread. -/// let mut thread_rng = thread_rng(); -/// // Create small, cheap to initialize and fast RNGs with random seeds. -/// // One can generally assume this won't fail. -/// let rngs: Vec = (0..10) -/// .map(|_| SmallRng::from_rng(&mut thread_rng).unwrap()) -/// .collect(); -/// ``` -/// -/// [`StdRng`]: crate::rngs::StdRng -/// [`thread_rng`]: crate::thread_rng -/// [rand_chacha]: https://crates.io/crates/rand_chacha -/// [rand_xoshiro]: https://crates.io/crates/rand_xoshiro -#[cfg_attr(doc_cfg, doc(cfg(feature = "small_rng")))] -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct SmallRng(Rng); - -impl RngCore for SmallRng { - #[inline(always)] - fn next_u32(&mut self) -> u32 { - self.0.next_u32() - } - - #[inline(always)] - fn next_u64(&mut self) -> u64 { - self.0.next_u64() - } - - #[inline(always)] - fn fill_bytes(&mut self, dest: &mut [u8]) { - self.0.fill_bytes(dest); - } - - #[inline(always)] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.0.try_fill_bytes(dest) - } -} - -impl SeedableRng for SmallRng { - type Seed = ::Seed; - - #[inline(always)] - fn from_seed(seed: Self::Seed) -> Self { - SmallRng(Rng::from_seed(seed)) - } - - #[inline(always)] - fn from_rng(rng: R) -> Result { - Rng::from_rng(rng).map(SmallRng) - } -} diff -Nru cargo-0.58.0/vendor/rand/src/rngs/std.rs cargo-0.60.0ubuntu1/vendor/rand/src/rngs/std.rs --- cargo-0.58.0/vendor/rand/src/rngs/std.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rngs/std.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The standard RNG - -use crate::{CryptoRng, Error, RngCore, SeedableRng}; - -#[cfg(all(any(test, feature = "std"), not(target_os = "emscripten")))] -pub(crate) use rand_chacha::ChaCha12Core as Core; -#[cfg(all(any(test, feature = "std"), target_os = "emscripten"))] -pub(crate) use rand_hc::Hc128Core as Core; - -#[cfg(not(target_os = "emscripten"))] use rand_chacha::ChaCha12Rng as Rng; -#[cfg(target_os = "emscripten")] use rand_hc::Hc128Rng as Rng; - -/// The standard RNG. The PRNG algorithm in `StdRng` is chosen to be efficient -/// on the current platform, to be statistically strong and unpredictable -/// (meaning a cryptographically secure PRNG). -/// -/// The current algorithm used is the ChaCha block cipher with 12 rounds. Please -/// see this relevant [rand issue] for the discussion. This may change as new -/// evidence of cipher security and performance becomes available. -/// -/// The algorithm is deterministic but should not be considered reproducible -/// due to dependence on configuration and possible replacement in future -/// library versions. For a secure reproducible generator, we recommend use of -/// the [rand_chacha] crate directly. -/// -/// [rand_chacha]: https://crates.io/crates/rand_chacha -/// [rand issue]: https://github.com/rust-random/rand/issues/932 -#[cfg_attr(doc_cfg, doc(cfg(feature = "std_rng")))] -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct StdRng(Rng); - -impl RngCore for StdRng { - #[inline(always)] - fn next_u32(&mut self) -> u32 { - self.0.next_u32() - } - - #[inline(always)] - fn next_u64(&mut self) -> u64 { - self.0.next_u64() - } - - #[inline(always)] - fn fill_bytes(&mut self, dest: &mut [u8]) { - self.0.fill_bytes(dest); - } - - #[inline(always)] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.0.try_fill_bytes(dest) - } -} - -impl SeedableRng for StdRng { - type Seed = ::Seed; - - #[inline(always)] - fn from_seed(seed: Self::Seed) -> Self { - StdRng(Rng::from_seed(seed)) - } - - #[inline(always)] - fn from_rng(rng: R) -> Result { - Rng::from_rng(rng).map(StdRng) - } -} - -impl CryptoRng for StdRng {} - - -#[cfg(test)] -mod test { - use crate::rngs::StdRng; - use crate::{RngCore, SeedableRng}; - - #[test] - fn test_stdrng_construction() { - // Test value-stability of StdRng. This is expected to break any time - // the algorithm is changed. - #[rustfmt::skip] - let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; - - let target = [10719222850664546238, 14064965282130556830]; - - let mut rng0 = StdRng::from_seed(seed); - let x0 = rng0.next_u64(); - - let mut rng1 = StdRng::from_rng(rng0).unwrap(); - let x1 = rng1.next_u64(); - - assert_eq!([x0, x1], target); - } -} diff -Nru cargo-0.58.0/vendor/rand/src/rngs/thread.rs cargo-0.60.0ubuntu1/vendor/rand/src/rngs/thread.rs --- cargo-0.58.0/vendor/rand/src/rngs/thread.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rngs/thread.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +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. - -//! Thread-local random number generator - -use core::cell::UnsafeCell; -use std::rc::Rc; -use std::thread_local; - -use super::std::Core; -use crate::rngs::adapter::ReseedingRng; -use crate::rngs::OsRng; -use crate::{CryptoRng, Error, RngCore, SeedableRng}; - -// Rationale for using `UnsafeCell` in `ThreadRng`: -// -// Previously we used a `RefCell`, with an overhead of ~15%. There will only -// ever be one mutable reference to the interior of the `UnsafeCell`, because -// we only have such a reference inside `next_u32`, `next_u64`, etc. Within a -// single thread (which is the definition of `ThreadRng`), there will only ever -// be one of these methods active at a time. -// -// A possible scenario where there could be multiple mutable references is if -// `ThreadRng` is used inside `next_u32` and co. But the implementation is -// completely under our control. We just have to ensure none of them use -// `ThreadRng` internally, which is nonsensical anyway. We should also never run -// `ThreadRng` in destructors of its implementation, which is also nonsensical. - - -// Number of generated bytes after which to reseed `ThreadRng`. -// According to benchmarks, reseeding has a noticable impact with thresholds -// of 32 kB and less. We choose 64 kB to avoid significant overhead. -const THREAD_RNG_RESEED_THRESHOLD: u64 = 1024 * 64; - -/// A reference to the thread-local generator -/// -/// An instance can be obtained via [`thread_rng`] or via `ThreadRng::default()`. -/// This handle is safe to use everywhere (including thread-local destructors) -/// but cannot be passed between threads (is not `Send` or `Sync`). -/// -/// `ThreadRng` uses the same PRNG as [`StdRng`] for security and performance -/// and is automatically seeded from [`OsRng`]. -/// -/// Unlike `StdRng`, `ThreadRng` uses the [`ReseedingRng`] wrapper to reseed -/// the PRNG from fresh entropy every 64 kiB of random data as well as after a -/// fork on Unix (though not quite immediately; see documentation of -/// [`ReseedingRng`]). -/// Note that the reseeding is done as an extra precaution against side-channel -/// attacks and mis-use (e.g. if somehow weak entropy were supplied initially). -/// The PRNG algorithms used are assumed to be secure. -/// -/// [`ReseedingRng`]: crate::rngs::adapter::ReseedingRng -/// [`StdRng`]: crate::rngs::StdRng -#[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", feature = "std_rng"))))] -#[derive(Clone, Debug)] -pub struct ThreadRng { - // Rc is explictly !Send and !Sync - rng: Rc>>, -} - -thread_local!( - // We require Rc<..> to avoid premature freeing when thread_rng is used - // within thread-local destructors. See #968. - static THREAD_RNG_KEY: Rc>> = { - let r = Core::from_rng(OsRng).unwrap_or_else(|err| - panic!("could not initialize thread_rng: {}", err)); - let rng = ReseedingRng::new(r, - THREAD_RNG_RESEED_THRESHOLD, - OsRng); - Rc::new(UnsafeCell::new(rng)) - } -); - -/// Retrieve the lazily-initialized thread-local random number generator, -/// seeded by the system. Intended to be used in method chaining style, -/// e.g. `thread_rng().gen::()`, or cached locally, e.g. -/// `let mut rng = thread_rng();`. Invoked by the `Default` trait, making -/// `ThreadRng::default()` equivalent. -/// -/// For more information see [`ThreadRng`]. -#[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", feature = "std_rng"))))] -pub fn thread_rng() -> ThreadRng { - let rng = THREAD_RNG_KEY.with(|t| t.clone()); - ThreadRng { rng } -} - -impl Default for ThreadRng { - fn default() -> ThreadRng { - crate::prelude::thread_rng() - } -} - -impl RngCore for ThreadRng { - #[inline(always)] - fn next_u32(&mut self) -> u32 { - // SAFETY: We must make sure to stop using `rng` before anyone else - // creates another mutable reference - let rng = unsafe { &mut *self.rng.get() }; - rng.next_u32() - } - - #[inline(always)] - fn next_u64(&mut self) -> u64 { - // SAFETY: We must make sure to stop using `rng` before anyone else - // creates another mutable reference - let rng = unsafe { &mut *self.rng.get() }; - rng.next_u64() - } - - fn fill_bytes(&mut self, dest: &mut [u8]) { - // SAFETY: We must make sure to stop using `rng` before anyone else - // creates another mutable reference - let rng = unsafe { &mut *self.rng.get() }; - rng.fill_bytes(dest) - } - - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - // SAFETY: We must make sure to stop using `rng` before anyone else - // creates another mutable reference - let rng = unsafe { &mut *self.rng.get() }; - rng.try_fill_bytes(dest) - } -} - -impl CryptoRng for ThreadRng {} - - -#[cfg(test)] -mod test { - #[test] - fn test_thread_rng() { - use crate::Rng; - let mut r = crate::thread_rng(); - r.gen::(); - assert_eq!(r.gen_range(0..1), 0); - } -} diff -Nru cargo-0.58.0/vendor/rand/src/rngs/xoshiro128plusplus.rs cargo-0.60.0ubuntu1/vendor/rand/src/rngs/xoshiro128plusplus.rs --- cargo-0.58.0/vendor/rand/src/rngs/xoshiro128plusplus.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rngs/xoshiro128plusplus.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +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. - -#[cfg(feature="serde1")] use serde::{Serialize, Deserialize}; -use rand_core::impls::{next_u64_via_u32, fill_bytes_via_next}; -use rand_core::le::read_u32_into; -use rand_core::{SeedableRng, RngCore, Error}; - -/// A xoshiro128++ random number generator. -/// -/// The xoshiro128++ algorithm is not suitable for cryptographic purposes, but -/// is very fast and has excellent statistical properties. -/// -/// The algorithm used here is translated from [the `xoshiro128plusplus.c` -/// reference source code](http://xoshiro.di.unimi.it/xoshiro128plusplus.c) by -/// David Blackman and Sebastiano Vigna. -#[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] -pub struct Xoshiro128PlusPlus { - s: [u32; 4], -} - -impl SeedableRng for Xoshiro128PlusPlus { - type Seed = [u8; 16]; - - /// Create a new `Xoshiro128PlusPlus`. If `seed` is entirely 0, it will be - /// mapped to a different seed. - #[inline] - fn from_seed(seed: [u8; 16]) -> Xoshiro128PlusPlus { - if seed.iter().all(|&x| x == 0) { - return Self::seed_from_u64(0); - } - let mut state = [0; 4]; - read_u32_into(&seed, &mut state); - Xoshiro128PlusPlus { s: state } - } - - /// Create a new `Xoshiro128PlusPlus` from a `u64` seed. - /// - /// This uses the SplitMix64 generator internally. - fn seed_from_u64(mut state: u64) -> Self { - const PHI: u64 = 0x9e3779b97f4a7c15; - let mut seed = Self::Seed::default(); - for chunk in seed.as_mut().chunks_mut(8) { - state = state.wrapping_add(PHI); - let mut z = state; - z = (z ^ (z >> 30)).wrapping_mul(0xbf58476d1ce4e5b9); - z = (z ^ (z >> 27)).wrapping_mul(0x94d049bb133111eb); - z = z ^ (z >> 31); - chunk.copy_from_slice(&z.to_le_bytes()); - } - Self::from_seed(seed) - } -} - -impl RngCore for Xoshiro128PlusPlus { - #[inline] - fn next_u32(&mut self) -> u32 { - let result_starstar = self.s[0] - .wrapping_add(self.s[3]) - .rotate_left(7) - .wrapping_add(self.s[0]); - - let t = self.s[1] << 9; - - self.s[2] ^= self.s[0]; - self.s[3] ^= self.s[1]; - self.s[1] ^= self.s[2]; - self.s[0] ^= self.s[3]; - - self.s[2] ^= t; - - self.s[3] = self.s[3].rotate_left(11); - - result_starstar - } - - #[inline] - fn next_u64(&mut self) -> u64 { - next_u64_via_u32(self) - } - - #[inline] - fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); - } - - #[inline] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.fill_bytes(dest); - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn reference() { - let mut rng = Xoshiro128PlusPlus::from_seed( - [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]); - // These values were produced with the reference implementation: - // http://xoshiro.di.unimi.it/xoshiro128plusplus.c - let expected = [ - 641, 1573767, 3222811527, 3517856514, 836907274, 4247214768, - 3867114732, 1355841295, 495546011, 621204420, - ]; - for &e in &expected { - assert_eq!(rng.next_u32(), e); - } - } -} diff -Nru cargo-0.58.0/vendor/rand/src/rngs/xoshiro256plusplus.rs cargo-0.60.0ubuntu1/vendor/rand/src/rngs/xoshiro256plusplus.rs --- cargo-0.58.0/vendor/rand/src/rngs/xoshiro256plusplus.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/rngs/xoshiro256plusplus.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +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. - -#[cfg(feature="serde1")] use serde::{Serialize, Deserialize}; -use rand_core::impls::fill_bytes_via_next; -use rand_core::le::read_u64_into; -use rand_core::{SeedableRng, RngCore, Error}; - -/// A xoshiro256++ random number generator. -/// -/// The xoshiro256++ algorithm is not suitable for cryptographic purposes, but -/// is very fast and has excellent statistical properties. -/// -/// The algorithm used here is translated from [the `xoshiro256plusplus.c` -/// reference source code](http://xoshiro.di.unimi.it/xoshiro256plusplus.c) by -/// David Blackman and Sebastiano Vigna. -#[derive(Debug, Clone, PartialEq, Eq)] -#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] -pub struct Xoshiro256PlusPlus { - s: [u64; 4], -} - -impl SeedableRng for Xoshiro256PlusPlus { - type Seed = [u8; 32]; - - /// Create a new `Xoshiro256PlusPlus`. If `seed` is entirely 0, it will be - /// mapped to a different seed. - #[inline] - fn from_seed(seed: [u8; 32]) -> Xoshiro256PlusPlus { - if seed.iter().all(|&x| x == 0) { - return Self::seed_from_u64(0); - } - let mut state = [0; 4]; - read_u64_into(&seed, &mut state); - Xoshiro256PlusPlus { s: state } - } - - /// Create a new `Xoshiro256PlusPlus` from a `u64` seed. - /// - /// This uses the SplitMix64 generator internally. - fn seed_from_u64(mut state: u64) -> Self { - const PHI: u64 = 0x9e3779b97f4a7c15; - let mut seed = Self::Seed::default(); - for chunk in seed.as_mut().chunks_mut(8) { - state = state.wrapping_add(PHI); - let mut z = state; - z = (z ^ (z >> 30)).wrapping_mul(0xbf58476d1ce4e5b9); - z = (z ^ (z >> 27)).wrapping_mul(0x94d049bb133111eb); - z = z ^ (z >> 31); - chunk.copy_from_slice(&z.to_le_bytes()); - } - Self::from_seed(seed) - } -} - -impl RngCore for Xoshiro256PlusPlus { - #[inline] - fn next_u32(&mut self) -> u32 { - // The lowest bits have some linear dependencies, so we use the - // upper bits instead. - (self.next_u64() >> 32) as u32 - } - - #[inline] - fn next_u64(&mut self) -> u64 { - let result_plusplus = self.s[0] - .wrapping_add(self.s[3]) - .rotate_left(23) - .wrapping_add(self.s[0]); - - let t = self.s[1] << 17; - - self.s[2] ^= self.s[0]; - self.s[3] ^= self.s[1]; - self.s[1] ^= self.s[2]; - self.s[0] ^= self.s[3]; - - self.s[2] ^= t; - - self.s[3] = self.s[3].rotate_left(45); - - result_plusplus - } - - #[inline] - fn fill_bytes(&mut self, dest: &mut [u8]) { - fill_bytes_via_next(self, dest); - } - - #[inline] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.fill_bytes(dest); - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn reference() { - let mut rng = Xoshiro256PlusPlus::from_seed( - [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]); - // These values were produced with the reference implementation: - // http://xoshiro.di.unimi.it/xoshiro256plusplus.c - let expected = [ - 41943041, 58720359, 3588806011781223, 3591011842654386, - 9228616714210784205, 9973669472204895162, 14011001112246962877, - 12406186145184390807, 15849039046786891736, 10450023813501588000, - ]; - for &e in &expected { - assert_eq!(rng.next_u64(), e); - } - } -} diff -Nru cargo-0.58.0/vendor/rand/src/seq/index.rs cargo-0.60.0ubuntu1/vendor/rand/src/seq/index.rs --- cargo-0.58.0/vendor/rand/src/seq/index.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/seq/index.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,678 +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. - -//! Low-level API for sampling indices - -#[cfg(feature = "alloc")] use core::slice; - -#[cfg(feature = "alloc")] use alloc::vec::{self, Vec}; -// BTreeMap is not as fast in tests, but better than nothing. -#[cfg(all(feature = "alloc", not(feature = "std")))] -use alloc::collections::BTreeSet; -#[cfg(feature = "std")] use std::collections::HashSet; - -#[cfg(feature = "alloc")] -use crate::distributions::{uniform::SampleUniform, Distribution, Uniform}; -#[cfg(feature = "std")] -use crate::distributions::WeightedError; -use crate::Rng; - -#[cfg(feature = "serde1")] -use serde::{Serialize, Deserialize}; - -/// A vector of indices. -/// -/// Multiple internal representations are possible. -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -pub enum IndexVec { - #[doc(hidden)] - U32(Vec), - #[doc(hidden)] - USize(Vec), -} - -impl IndexVec { - /// Returns the number of indices - #[inline] - pub fn len(&self) -> usize { - match *self { - IndexVec::U32(ref v) => v.len(), - IndexVec::USize(ref v) => v.len(), - } - } - - /// Returns `true` if the length is 0. - #[inline] - pub fn is_empty(&self) -> bool { - match *self { - IndexVec::U32(ref v) => v.is_empty(), - IndexVec::USize(ref v) => v.is_empty(), - } - } - - /// Return the value at the given `index`. - /// - /// (Note: we cannot implement [`std::ops::Index`] because of lifetime - /// restrictions.) - #[inline] - pub fn index(&self, index: usize) -> usize { - match *self { - IndexVec::U32(ref v) => v[index] as usize, - IndexVec::USize(ref v) => v[index], - } - } - - /// Return result as a `Vec`. Conversion may or may not be trivial. - #[inline] - pub fn into_vec(self) -> Vec { - match self { - IndexVec::U32(v) => v.into_iter().map(|i| i as usize).collect(), - IndexVec::USize(v) => v, - } - } - - /// Iterate over the indices as a sequence of `usize` values - #[inline] - pub fn iter(&self) -> IndexVecIter<'_> { - match *self { - IndexVec::U32(ref v) => IndexVecIter::U32(v.iter()), - IndexVec::USize(ref v) => IndexVecIter::USize(v.iter()), - } - } -} - -impl IntoIterator for IndexVec { - type Item = usize; - type IntoIter = IndexVecIntoIter; - - /// Convert into an iterator over the indices as a sequence of `usize` values - #[inline] - fn into_iter(self) -> IndexVecIntoIter { - match self { - IndexVec::U32(v) => IndexVecIntoIter::U32(v.into_iter()), - IndexVec::USize(v) => IndexVecIntoIter::USize(v.into_iter()), - } - } -} - -impl PartialEq for IndexVec { - fn eq(&self, other: &IndexVec) -> bool { - use self::IndexVec::*; - match (self, other) { - (&U32(ref v1), &U32(ref v2)) => v1 == v2, - (&USize(ref v1), &USize(ref v2)) => v1 == v2, - (&U32(ref v1), &USize(ref v2)) => { - (v1.len() == v2.len()) && (v1.iter().zip(v2.iter()).all(|(x, y)| *x as usize == *y)) - } - (&USize(ref v1), &U32(ref v2)) => { - (v1.len() == v2.len()) && (v1.iter().zip(v2.iter()).all(|(x, y)| *x == *y as usize)) - } - } - } -} - -impl From> for IndexVec { - #[inline] - fn from(v: Vec) -> Self { - IndexVec::U32(v) - } -} - -impl From> for IndexVec { - #[inline] - fn from(v: Vec) -> Self { - IndexVec::USize(v) - } -} - -/// Return type of `IndexVec::iter`. -#[derive(Debug)] -pub enum IndexVecIter<'a> { - #[doc(hidden)] - U32(slice::Iter<'a, u32>), - #[doc(hidden)] - USize(slice::Iter<'a, usize>), -} - -impl<'a> Iterator for IndexVecIter<'a> { - type Item = usize; - - #[inline] - fn next(&mut self) -> Option { - use self::IndexVecIter::*; - match *self { - U32(ref mut iter) => iter.next().map(|i| *i as usize), - USize(ref mut iter) => iter.next().cloned(), - } - } - - #[inline] - fn size_hint(&self) -> (usize, Option) { - match *self { - IndexVecIter::U32(ref v) => v.size_hint(), - IndexVecIter::USize(ref v) => v.size_hint(), - } - } -} - -impl<'a> ExactSizeIterator for IndexVecIter<'a> {} - -/// Return type of `IndexVec::into_iter`. -#[derive(Clone, Debug)] -pub enum IndexVecIntoIter { - #[doc(hidden)] - U32(vec::IntoIter), - #[doc(hidden)] - USize(vec::IntoIter), -} - -impl Iterator for IndexVecIntoIter { - type Item = usize; - - #[inline] - fn next(&mut self) -> Option { - use self::IndexVecIntoIter::*; - match *self { - U32(ref mut v) => v.next().map(|i| i as usize), - USize(ref mut v) => v.next(), - } - } - - #[inline] - fn size_hint(&self) -> (usize, Option) { - use self::IndexVecIntoIter::*; - match *self { - U32(ref v) => v.size_hint(), - USize(ref v) => v.size_hint(), - } - } -} - -impl ExactSizeIterator for IndexVecIntoIter {} - - -/// Randomly sample exactly `amount` distinct indices from `0..length`, and -/// return them in random order (fully shuffled). -/// -/// This method is used internally by the slice sampling methods, but it can -/// sometimes be useful to have the indices themselves so this is provided as -/// an alternative. -/// -/// The implementation used is not specified; we automatically select the -/// fastest available algorithm for the `length` and `amount` parameters -/// (based on detailed profiling on an Intel Haswell CPU). Roughly speaking, -/// complexity is `O(amount)`, except that when `amount` is small, performance -/// is closer to `O(amount^2)`, and when `length` is close to `amount` then -/// `O(length)`. -/// -/// Note that performance is significantly better over `u32` indices than over -/// `u64` indices. Because of this we hide the underlying type behind an -/// abstraction, `IndexVec`. -/// -/// If an allocation-free `no_std` function is required, it is suggested -/// to adapt the internal `sample_floyd` implementation. -/// -/// Panics if `amount > length`. -pub fn sample(rng: &mut R, length: usize, amount: usize) -> IndexVec -where R: Rng + ?Sized { - if amount > length { - panic!("`amount` of samples must be less than or equal to `length`"); - } - if length > (::core::u32::MAX as usize) { - // We never want to use inplace here, but could use floyd's alg - // Lazy version: always use the cache alg. - return sample_rejection(rng, length, amount); - } - let amount = amount as u32; - let length = length as u32; - - // Choice of algorithm here depends on both length and amount. See: - // https://github.com/rust-random/rand/pull/479 - // We do some calculations with f32. Accuracy is not very important. - - if amount < 163 { - const C: [[f32; 2]; 2] = [[1.6, 8.0 / 45.0], [10.0, 70.0 / 9.0]]; - let j = if length < 500_000 { 0 } else { 1 }; - let amount_fp = amount as f32; - let m4 = C[0][j] * amount_fp; - // Short-cut: when amount < 12, floyd's is always faster - if amount > 11 && (length as f32) < (C[1][j] + m4) * amount_fp { - sample_inplace(rng, length, amount) - } else { - sample_floyd(rng, length, amount) - } - } else { - const C: [f32; 2] = [270.0, 330.0 / 9.0]; - let j = if length < 500_000 { 0 } else { 1 }; - if (length as f32) < C[j] * (amount as f32) { - sample_inplace(rng, length, amount) - } else { - sample_rejection(rng, length, amount) - } - } -} - -/// Randomly sample exactly `amount` distinct indices from `0..length`, and -/// return them in an arbitrary order (there is no guarantee of shuffling or -/// ordering). The weights are to be provided by the input function `weights`, -/// which will be called once for each index. -/// -/// This method is used internally by the slice sampling methods, but it can -/// sometimes be useful to have the indices themselves so this is provided as -/// an alternative. -/// -/// This implementation uses `O(length + amount)` space and `O(length)` time -/// if the "nightly" feature is enabled, or `O(length)` space and -/// `O(length + amount * log length)` time otherwise. -/// -/// Panics if `amount > length`. -#[cfg(feature = "std")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] -pub fn sample_weighted( - rng: &mut R, length: usize, weight: F, amount: usize, -) -> Result -where - R: Rng + ?Sized, - F: Fn(usize) -> X, - X: Into, -{ - if length > (core::u32::MAX as usize) { - sample_efraimidis_spirakis(rng, length, weight, amount) - } else { - assert!(amount <= core::u32::MAX as usize); - let amount = amount as u32; - let length = length as u32; - sample_efraimidis_spirakis(rng, length, weight, amount) - } -} - - -/// Randomly sample exactly `amount` distinct indices from `0..length`, and -/// return them in an arbitrary order (there is no guarantee of shuffling or -/// ordering). The weights are to be provided by the input function `weights`, -/// which will be called once for each index. -/// -/// This implementation uses the algorithm described by Efraimidis and Spirakis -/// in this paper: https://doi.org/10.1016/j.ipl.2005.11.003 -/// It uses `O(length + amount)` space and `O(length)` time if the -/// "nightly" feature is enabled, or `O(length)` space and `O(length -/// + amount * log length)` time otherwise. -/// -/// Panics if `amount > length`. -#[cfg(feature = "std")] -fn sample_efraimidis_spirakis( - rng: &mut R, length: N, weight: F, amount: N, -) -> Result -where - R: Rng + ?Sized, - F: Fn(usize) -> X, - X: Into, - N: UInt, - IndexVec: From>, -{ - if amount == N::zero() { - return Ok(IndexVec::U32(Vec::new())); - } - - if amount > length { - panic!("`amount` of samples must be less than or equal to `length`"); - } - - struct Element { - index: N, - key: f64, - } - impl PartialOrd for Element { - fn partial_cmp(&self, other: &Self) -> Option { - self.key.partial_cmp(&other.key) - } - } - impl Ord for Element { - fn cmp(&self, other: &Self) -> core::cmp::Ordering { - // partial_cmp will always produce a value, - // because we check that the weights are not nan - self.partial_cmp(other).unwrap() - } - } - impl PartialEq for Element { - fn eq(&self, other: &Self) -> bool { - self.key == other.key - } - } - impl Eq for Element {} - - #[cfg(feature = "nightly")] - { - let mut candidates = Vec::with_capacity(length.as_usize()); - let mut index = N::zero(); - while index < length { - let weight = weight(index.as_usize()).into(); - if !(weight >= 0.) { - return Err(WeightedError::InvalidWeight); - } - - let key = rng.gen::().powf(1.0 / weight); - candidates.push(Element { index, key }); - - index += N::one(); - } - - // Partially sort the array to find the `amount` elements with the greatest - // keys. Do this by using `select_nth_unstable` to put the elements with - // the *smallest* keys at the beginning of the list in `O(n)` time, which - // provides equivalent information about the elements with the *greatest* keys. - let (_, mid, greater) - = candidates.select_nth_unstable(length.as_usize() - amount.as_usize()); - - let mut result: Vec = Vec::with_capacity(amount.as_usize()); - result.push(mid.index); - for element in greater { - result.push(element.index); - } - Ok(IndexVec::from(result)) - } - - #[cfg(not(feature = "nightly"))] - { - use std::collections::BinaryHeap; - - // Partially sort the array such that the `amount` elements with the largest - // keys are first using a binary max heap. - let mut candidates = BinaryHeap::with_capacity(length.as_usize()); - let mut index = N::zero(); - while index < length { - let weight = weight(index.as_usize()).into(); - if !(weight >= 0.) { - return Err(WeightedError::InvalidWeight); - } - - let key = rng.gen::().powf(1.0 / weight); - candidates.push(Element { index, key }); - - index += N::one(); - } - - let mut result: Vec = Vec::with_capacity(amount.as_usize()); - while result.len() < amount.as_usize() { - result.push(candidates.pop().unwrap().index); - } - Ok(IndexVec::from(result)) - } -} - -/// Randomly sample exactly `amount` indices from `0..length`, using Floyd's -/// combination algorithm. -/// -/// The output values are fully shuffled. (Overhead is under 50%.) -/// -/// This implementation uses `O(amount)` memory and `O(amount^2)` time. -fn sample_floyd(rng: &mut R, length: u32, amount: u32) -> IndexVec -where R: Rng + ?Sized { - // For small amount we use Floyd's fully-shuffled variant. For larger - // amounts this is slow due to Vec::insert performance, so we shuffle - // afterwards. Benchmarks show little overhead from extra logic. - let floyd_shuffle = amount < 50; - - debug_assert!(amount <= length); - let mut indices = Vec::with_capacity(amount as usize); - for j in length - amount..length { - let t = rng.gen_range(0..=j); - if floyd_shuffle { - if let Some(pos) = indices.iter().position(|&x| x == t) { - indices.insert(pos, j); - continue; - } - } else if indices.contains(&t) { - indices.push(j); - continue; - } - indices.push(t); - } - if !floyd_shuffle { - // Reimplement SliceRandom::shuffle with smaller indices - for i in (1..amount).rev() { - // invariant: elements with index > i have been locked in place. - indices.swap(i as usize, rng.gen_range(0..=i) as usize); - } - } - IndexVec::from(indices) -} - -/// Randomly sample exactly `amount` indices from `0..length`, using an inplace -/// partial Fisher-Yates method. -/// Sample an amount of indices using an inplace partial fisher yates method. -/// -/// This allocates the entire `length` of indices and randomizes only the first `amount`. -/// It then truncates to `amount` and returns. -/// -/// This method is not appropriate for large `length` and potentially uses a lot -/// of memory; because of this we only implement for `u32` index (which improves -/// performance in all cases). -/// -/// Set-up is `O(length)` time and memory and shuffling is `O(amount)` time. -fn sample_inplace(rng: &mut R, length: u32, amount: u32) -> IndexVec -where R: Rng + ?Sized { - debug_assert!(amount <= length); - let mut indices: Vec = Vec::with_capacity(length as usize); - indices.extend(0..length); - for i in 0..amount { - let j: u32 = rng.gen_range(i..length); - indices.swap(i as usize, j as usize); - } - indices.truncate(amount as usize); - debug_assert_eq!(indices.len(), amount as usize); - IndexVec::from(indices) -} - -trait UInt: Copy + PartialOrd + Ord + PartialEq + Eq + SampleUniform - + core::hash::Hash + core::ops::AddAssign { - fn zero() -> Self; - fn one() -> Self; - fn as_usize(self) -> usize; -} -impl UInt for u32 { - #[inline] - fn zero() -> Self { - 0 - } - - #[inline] - fn one() -> Self { - 1 - } - - #[inline] - fn as_usize(self) -> usize { - self as usize - } -} -impl UInt for usize { - #[inline] - fn zero() -> Self { - 0 - } - - #[inline] - fn one() -> Self { - 1 - } - - #[inline] - fn as_usize(self) -> usize { - self - } -} - -/// Randomly sample exactly `amount` indices from `0..length`, using rejection -/// sampling. -/// -/// Since `amount <<< length` there is a low chance of a random sample in -/// `0..length` being a duplicate. We test for duplicates and resample where -/// necessary. The algorithm is `O(amount)` time and memory. -/// -/// This function is generic over X primarily so that results are value-stable -/// over 32-bit and 64-bit platforms. -fn sample_rejection(rng: &mut R, length: X, amount: X) -> IndexVec -where - R: Rng + ?Sized, - IndexVec: From>, -{ - debug_assert!(amount < length); - #[cfg(feature = "std")] - let mut cache = HashSet::with_capacity(amount.as_usize()); - #[cfg(not(feature = "std"))] - let mut cache = BTreeSet::new(); - let distr = Uniform::new(X::zero(), length); - let mut indices = Vec::with_capacity(amount.as_usize()); - for _ in 0..amount.as_usize() { - let mut pos = distr.sample(rng); - while !cache.insert(pos) { - pos = distr.sample(rng); - } - indices.push(pos); - } - - debug_assert_eq!(indices.len(), amount.as_usize()); - IndexVec::from(indices) -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - #[cfg(feature = "serde1")] - fn test_serialization_index_vec() { - let some_index_vec = IndexVec::from(vec![254_usize, 234, 2, 1]); - let de_some_index_vec: IndexVec = bincode::deserialize(&bincode::serialize(&some_index_vec).unwrap()).unwrap(); - match (some_index_vec, de_some_index_vec) { - (IndexVec::U32(a), IndexVec::U32(b)) => { - assert_eq!(a, b); - }, - (IndexVec::USize(a), IndexVec::USize(b)) => { - assert_eq!(a, b); - }, - _ => {panic!("failed to seralize/deserialize `IndexVec`")} - } - } - - #[cfg(feature = "alloc")] use alloc::vec; - - #[test] - fn test_sample_boundaries() { - let mut r = crate::test::rng(404); - - assert_eq!(sample_inplace(&mut r, 0, 0).len(), 0); - assert_eq!(sample_inplace(&mut r, 1, 0).len(), 0); - assert_eq!(sample_inplace(&mut r, 1, 1).into_vec(), vec![0]); - - assert_eq!(sample_rejection(&mut r, 1u32, 0).len(), 0); - - assert_eq!(sample_floyd(&mut r, 0, 0).len(), 0); - assert_eq!(sample_floyd(&mut r, 1, 0).len(), 0); - assert_eq!(sample_floyd(&mut r, 1, 1).into_vec(), vec![0]); - - // These algorithms should be fast with big numbers. Test average. - let sum: usize = sample_rejection(&mut r, 1 << 25, 10u32).into_iter().sum(); - assert!(1 << 25 < sum && sum < (1 << 25) * 25); - - let sum: usize = sample_floyd(&mut r, 1 << 25, 10).into_iter().sum(); - assert!(1 << 25 < sum && sum < (1 << 25) * 25); - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_sample_alg() { - let seed_rng = crate::test::rng; - - // We can't test which algorithm is used directly, but Floyd's alg - // should produce different results from the others. (Also, `inplace` - // and `cached` currently use different sizes thus produce different results.) - - // A small length and relatively large amount should use inplace - let (length, amount): (usize, usize) = (100, 50); - let v1 = sample(&mut seed_rng(420), length, amount); - let v2 = sample_inplace(&mut seed_rng(420), length as u32, amount as u32); - assert!(v1.iter().all(|e| e < length)); - assert_eq!(v1, v2); - - // Test Floyd's alg does produce different results - let v3 = sample_floyd(&mut seed_rng(420), length as u32, amount as u32); - assert!(v1 != v3); - - // A large length and small amount should use Floyd - let (length, amount): (usize, usize) = (1 << 20, 50); - let v1 = sample(&mut seed_rng(421), length, amount); - let v2 = sample_floyd(&mut seed_rng(421), length as u32, amount as u32); - assert!(v1.iter().all(|e| e < length)); - assert_eq!(v1, v2); - - // A large length and larger amount should use cache - let (length, amount): (usize, usize) = (1 << 20, 600); - let v1 = sample(&mut seed_rng(422), length, amount); - let v2 = sample_rejection(&mut seed_rng(422), length as u32, amount as u32); - assert!(v1.iter().all(|e| e < length)); - assert_eq!(v1, v2); - } - - #[cfg(feature = "std")] - #[test] - fn test_sample_weighted() { - let seed_rng = crate::test::rng; - for &(amount, len) in &[(0, 10), (5, 10), (10, 10)] { - let v = sample_weighted(&mut seed_rng(423), len, |i| i as f64, amount).unwrap(); - match v { - IndexVec::U32(mut indices) => { - assert_eq!(indices.len(), amount); - indices.sort_unstable(); - indices.dedup(); - assert_eq!(indices.len(), amount); - for &i in &indices { - assert!((i as usize) < len); - } - }, - IndexVec::USize(_) => panic!("expected `IndexVec::U32`"), - } - } - } - - #[test] - fn value_stability_sample() { - let do_test = |length, amount, values: &[u32]| { - let mut buf = [0u32; 8]; - let mut rng = crate::test::rng(410); - - let res = sample(&mut rng, length, amount); - let len = res.len().min(buf.len()); - for (x, y) in res.into_iter().zip(buf.iter_mut()) { - *y = x as u32; - } - assert_eq!( - &buf[0..len], - values, - "failed sampling {}, {}", - length, - amount - ); - }; - - do_test(10, 6, &[8, 0, 3, 5, 9, 6]); // floyd - do_test(25, 10, &[18, 15, 14, 9, 0, 13, 5, 24]); // floyd - do_test(300, 8, &[30, 283, 150, 1, 73, 13, 285, 35]); // floyd - do_test(300, 80, &[31, 289, 248, 154, 5, 78, 19, 286]); // inplace - do_test(300, 180, &[31, 289, 248, 154, 5, 78, 19, 286]); // inplace - - do_test(1_000_000, 8, &[ - 103717, 963485, 826422, 509101, 736394, 807035, 5327, 632573, - ]); // floyd - do_test(1_000_000, 180, &[ - 103718, 963490, 826426, 509103, 736396, 807036, 5327, 632573, - ]); // rejection - } -} diff -Nru cargo-0.58.0/vendor/rand/src/seq/mod.rs cargo-0.60.0ubuntu1/vendor/rand/src/seq/mod.rs --- cargo-0.58.0/vendor/rand/src/seq/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand/src/seq/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,1359 +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. - -//! Sequence-related functionality -//! -//! This module provides: -//! -//! * [`SliceRandom`] slice sampling and mutation -//! * [`IteratorRandom`] iterator sampling -//! * [`index::sample`] low-level API to choose multiple indices from -//! `0..length` -//! -//! Also see: -//! -//! * [`crate::distributions::WeightedIndex`] distribution which provides -//! weighted index sampling. -//! -//! In order to make results reproducible across 32-64 bit architectures, all -//! `usize` indices are sampled as a `u32` where possible (also providing a -//! small performance boost in some cases). - - -#[cfg(feature = "alloc")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] -pub mod index; - -#[cfg(feature = "alloc")] use core::ops::Index; - -#[cfg(feature = "alloc")] use alloc::vec::Vec; - -#[cfg(feature = "alloc")] -use crate::distributions::uniform::{SampleBorrow, SampleUniform}; -#[cfg(feature = "alloc")] use crate::distributions::WeightedError; -use crate::Rng; - -/// Extension trait on slices, providing random mutation and sampling methods. -/// -/// This trait is implemented on all `[T]` slice types, providing several -/// methods for choosing and shuffling elements. You must `use` this trait: -/// -/// ``` -/// use rand::seq::SliceRandom; -/// -/// let mut rng = rand::thread_rng(); -/// let mut bytes = "Hello, random!".to_string().into_bytes(); -/// bytes.shuffle(&mut rng); -/// let str = String::from_utf8(bytes).unwrap(); -/// println!("{}", str); -/// ``` -/// Example output (non-deterministic): -/// ```none -/// l,nmroHado !le -/// ``` -pub trait SliceRandom { - /// The element type. - type Item; - - /// Returns a reference to one random element of the slice, or `None` if the - /// slice is empty. - /// - /// For slices, complexity is `O(1)`. - /// - /// # Example - /// - /// ``` - /// use rand::thread_rng; - /// use rand::seq::SliceRandom; - /// - /// let choices = [1, 2, 4, 8, 16, 32]; - /// let mut rng = thread_rng(); - /// println!("{:?}", choices.choose(&mut rng)); - /// assert_eq!(choices[..0].choose(&mut rng), None); - /// ``` - fn choose(&self, rng: &mut R) -> Option<&Self::Item> - where R: Rng + ?Sized; - - /// Returns a mutable reference to one random element of the slice, or - /// `None` if the slice is empty. - /// - /// For slices, complexity is `O(1)`. - fn choose_mut(&mut self, rng: &mut R) -> Option<&mut Self::Item> - where R: Rng + ?Sized; - - /// Chooses `amount` elements from the slice at random, without repetition, - /// and in random order. The returned iterator is appropriate both for - /// collection into a `Vec` and filling an existing buffer (see example). - /// - /// In case this API is not sufficiently flexible, use [`index::sample`]. - /// - /// For slices, complexity is the same as [`index::sample`]. - /// - /// # Example - /// ``` - /// use rand::seq::SliceRandom; - /// - /// let mut rng = &mut rand::thread_rng(); - /// let sample = "Hello, audience!".as_bytes(); - /// - /// // collect the results into a vector: - /// let v: Vec = sample.choose_multiple(&mut rng, 3).cloned().collect(); - /// - /// // store in a buffer: - /// let mut buf = [0u8; 5]; - /// for (b, slot) in sample.choose_multiple(&mut rng, buf.len()).zip(buf.iter_mut()) { - /// *slot = *b; - /// } - /// ``` - #[cfg(feature = "alloc")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] - fn choose_multiple(&self, rng: &mut R, amount: usize) -> SliceChooseIter - where R: Rng + ?Sized; - - /// Similar to [`choose`], but where the likelihood of each outcome may be - /// specified. - /// - /// The specified function `weight` maps each item `x` to a relative - /// likelihood `weight(x)`. The probability of each item being selected is - /// therefore `weight(x) / s`, where `s` is the sum of all `weight(x)`. - /// - /// For slices of length `n`, complexity is `O(n)`. - /// See also [`choose_weighted_mut`], [`distributions::weighted`]. - /// - /// # Example - /// - /// ``` - /// use rand::prelude::*; - /// - /// let choices = [('a', 2), ('b', 1), ('c', 1)]; - /// let mut rng = thread_rng(); - /// // 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c' - /// println!("{:?}", choices.choose_weighted(&mut rng, |item| item.1).unwrap().0); - /// ``` - /// [`choose`]: SliceRandom::choose - /// [`choose_weighted_mut`]: SliceRandom::choose_weighted_mut - /// [`distributions::weighted`]: crate::distributions::weighted - #[cfg(feature = "alloc")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] - fn choose_weighted( - &self, rng: &mut R, weight: F, - ) -> Result<&Self::Item, WeightedError> - where - R: Rng + ?Sized, - F: Fn(&Self::Item) -> B, - B: SampleBorrow, - X: SampleUniform - + for<'a> ::core::ops::AddAssign<&'a X> - + ::core::cmp::PartialOrd - + Clone - + Default; - - /// Similar to [`choose_mut`], but where the likelihood of each outcome may - /// be specified. - /// - /// The specified function `weight` maps each item `x` to a relative - /// likelihood `weight(x)`. The probability of each item being selected is - /// therefore `weight(x) / s`, where `s` is the sum of all `weight(x)`. - /// - /// For slices of length `n`, complexity is `O(n)`. - /// See also [`choose_weighted`], [`distributions::weighted`]. - /// - /// [`choose_mut`]: SliceRandom::choose_mut - /// [`choose_weighted`]: SliceRandom::choose_weighted - /// [`distributions::weighted`]: crate::distributions::weighted - #[cfg(feature = "alloc")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] - fn choose_weighted_mut( - &mut self, rng: &mut R, weight: F, - ) -> Result<&mut Self::Item, WeightedError> - where - R: Rng + ?Sized, - F: Fn(&Self::Item) -> B, - B: SampleBorrow, - X: SampleUniform - + for<'a> ::core::ops::AddAssign<&'a X> - + ::core::cmp::PartialOrd - + Clone - + Default; - - /// Similar to [`choose_multiple`], but where the likelihood of each element's - /// inclusion in the output may be specified. The elements are returned in an - /// arbitrary, unspecified order. - /// - /// The specified function `weight` maps each item `x` to a relative - /// likelihood `weight(x)`. The probability of each item being selected is - /// therefore `weight(x) / s`, where `s` is the sum of all `weight(x)`. - /// - /// If all of the weights are equal, even if they are all zero, each element has - /// an equal likelihood of being selected. - /// - /// The complexity of this method depends on the feature `partition_at_index`. - /// If the feature is enabled, then for slices of length `n`, the complexity - /// is `O(n)` space and `O(n)` time. Otherwise, the complexity is `O(n)` space and - /// `O(n * log amount)` time. - /// - /// # Example - /// - /// ``` - /// use rand::prelude::*; - /// - /// let choices = [('a', 2), ('b', 1), ('c', 1)]; - /// let mut rng = thread_rng(); - /// // First Draw * Second Draw = total odds - /// // ----------------------- - /// // (50% * 50%) + (25% * 67%) = 41.7% chance that the output is `['a', 'b']` in some order. - /// // (50% * 50%) + (25% * 67%) = 41.7% chance that the output is `['a', 'c']` in some order. - /// // (25% * 33%) + (25% * 33%) = 16.6% chance that the output is `['b', 'c']` in some order. - /// println!("{:?}", choices.choose_multiple_weighted(&mut rng, 2, |item| item.1).unwrap().collect::>()); - /// ``` - /// [`choose_multiple`]: SliceRandom::choose_multiple - // - // Note: this is feature-gated on std due to usage of f64::powf. - // If necessary, we may use alloc+libm as an alternative (see PR #1089). - #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] - fn choose_multiple_weighted( - &self, rng: &mut R, amount: usize, weight: F, - ) -> Result, WeightedError> - where - R: Rng + ?Sized, - F: Fn(&Self::Item) -> X, - X: Into; - - /// Shuffle a mutable slice in place. - /// - /// For slices of length `n`, complexity is `O(n)`. - /// - /// # Example - /// - /// ``` - /// use rand::seq::SliceRandom; - /// use rand::thread_rng; - /// - /// let mut rng = thread_rng(); - /// let mut y = [1, 2, 3, 4, 5]; - /// println!("Unshuffled: {:?}", y); - /// y.shuffle(&mut rng); - /// println!("Shuffled: {:?}", y); - /// ``` - fn shuffle(&mut self, rng: &mut R) - where R: Rng + ?Sized; - - /// Shuffle a slice in place, but exit early. - /// - /// Returns two mutable slices from the source slice. The first contains - /// `amount` elements randomly permuted. The second has the remaining - /// elements that are not fully shuffled. - /// - /// This is an efficient method to select `amount` elements at random from - /// the slice, provided the slice may be mutated. - /// - /// If you only need to choose elements randomly and `amount > self.len()/2` - /// then you may improve performance by taking - /// `amount = values.len() - amount` and using only the second slice. - /// - /// If `amount` is greater than the number of elements in the slice, this - /// will perform a full shuffle. - /// - /// For slices, complexity is `O(m)` where `m = amount`. - fn partial_shuffle( - &mut self, rng: &mut R, amount: usize, - ) -> (&mut [Self::Item], &mut [Self::Item]) - where R: Rng + ?Sized; -} - -/// Extension trait on iterators, providing random sampling methods. -/// -/// This trait is implemented on all iterators `I` where `I: Iterator + Sized` -/// and provides methods for -/// choosing one or more elements. You must `use` this trait: -/// -/// ``` -/// use rand::seq::IteratorRandom; -/// -/// let mut rng = rand::thread_rng(); -/// -/// let faces = "😀😎😐😕😠😢"; -/// println!("I am {}!", faces.chars().choose(&mut rng).unwrap()); -/// ``` -/// Example output (non-deterministic): -/// ```none -/// I am 😀! -/// ``` -pub trait IteratorRandom: Iterator + Sized { - /// Choose one element at random from the iterator. - /// - /// Returns `None` if and only if the iterator is empty. - /// - /// This method uses [`Iterator::size_hint`] for optimisation. With an - /// accurate hint and where [`Iterator::nth`] is a constant-time operation - /// this method can offer `O(1)` performance. Where no size hint is - /// available, complexity is `O(n)` where `n` is the iterator length. - /// Partial hints (where `lower > 0`) also improve performance. - /// - /// Note that the output values and the number of RNG samples used - /// depends on size hints. In particular, `Iterator` combinators that don't - /// change the values yielded but change the size hints may result in - /// `choose` returning different elements. If you want consistent results - /// and RNG usage consider using [`IteratorRandom::choose_stable`]. - fn choose(mut self, rng: &mut R) -> Option - where R: Rng + ?Sized { - let (mut lower, mut upper) = self.size_hint(); - let mut consumed = 0; - let mut result = None; - - // Handling for this condition outside the loop allows the optimizer to eliminate the loop - // when the Iterator is an ExactSizeIterator. This has a large performance impact on e.g. - // seq_iter_choose_from_1000. - if upper == Some(lower) { - return if lower == 0 { - None - } else { - self.nth(gen_index(rng, lower)) - }; - } - - // Continue until the iterator is exhausted - loop { - if lower > 1 { - let ix = gen_index(rng, lower + consumed); - let skip = if ix < lower { - result = self.nth(ix); - lower - (ix + 1) - } else { - lower - }; - if upper == Some(lower) { - return result; - } - consumed += lower; - if skip > 0 { - self.nth(skip - 1); - } - } else { - let elem = self.next(); - if elem.is_none() { - return result; - } - consumed += 1; - if gen_index(rng, consumed) == 0 { - result = elem; - } - } - - let hint = self.size_hint(); - lower = hint.0; - upper = hint.1; - } - } - - /// Choose one element at random from the iterator. - /// - /// Returns `None` if and only if the iterator is empty. - /// - /// This method is very similar to [`choose`] except that the result - /// only depends on the length of the iterator and the values produced by - /// `rng`. Notably for any iterator of a given length this will make the - /// same requests to `rng` and if the same sequence of values are produced - /// the same index will be selected from `self`. This may be useful if you - /// need consistent results no matter what type of iterator you are working - /// with. If you do not need this stability prefer [`choose`]. - /// - /// Note that this method still uses [`Iterator::size_hint`] to skip - /// constructing elements where possible, however the selection and `rng` - /// calls are the same in the face of this optimization. If you want to - /// force every element to be created regardless call `.inspect(|e| ())`. - /// - /// [`choose`]: IteratorRandom::choose - fn choose_stable(mut self, rng: &mut R) -> Option - where R: Rng + ?Sized { - let mut consumed = 0; - let mut result = None; - - loop { - // Currently the only way to skip elements is `nth()`. So we need to - // store what index to access next here. - // This should be replaced by `advance_by()` once it is stable: - // https://github.com/rust-lang/rust/issues/77404 - let mut next = 0; - - let (lower, _) = self.size_hint(); - if lower >= 2 { - let highest_selected = (0..lower) - .filter(|ix| gen_index(rng, consumed+ix+1) == 0) - .last(); - - consumed += lower; - next = lower; - - if let Some(ix) = highest_selected { - result = self.nth(ix); - next -= ix + 1; - debug_assert!(result.is_some(), "iterator shorter than size_hint().0"); - } - } - - let elem = self.nth(next); - if elem.is_none() { - return result - } - - if gen_index(rng, consumed+1) == 0 { - result = elem; - } - consumed += 1; - } - } - - /// Collects values at random from the iterator into a supplied buffer - /// until that buffer is filled. - /// - /// Although the elements are selected randomly, the order of elements in - /// the buffer is neither stable nor fully random. If random ordering is - /// desired, shuffle the result. - /// - /// Returns the number of elements added to the buffer. This equals the length - /// of the buffer unless the iterator contains insufficient elements, in which - /// case this equals the number of elements available. - /// - /// Complexity is `O(n)` where `n` is the length of the iterator. - /// For slices, prefer [`SliceRandom::choose_multiple`]. - fn choose_multiple_fill(mut self, rng: &mut R, buf: &mut [Self::Item]) -> usize - where R: Rng + ?Sized { - let amount = buf.len(); - let mut len = 0; - while len < amount { - if let Some(elem) = self.next() { - buf[len] = elem; - len += 1; - } else { - // Iterator exhausted; stop early - return len; - } - } - - // Continue, since the iterator was not exhausted - for (i, elem) in self.enumerate() { - let k = gen_index(rng, i + 1 + amount); - if let Some(slot) = buf.get_mut(k) { - *slot = elem; - } - } - len - } - - /// Collects `amount` values at random from the iterator into a vector. - /// - /// This is equivalent to `choose_multiple_fill` except for the result type. - /// - /// Although the elements are selected randomly, the order of elements in - /// the buffer is neither stable nor fully random. If random ordering is - /// desired, shuffle the result. - /// - /// The length of the returned vector equals `amount` unless the iterator - /// contains insufficient elements, in which case it equals the number of - /// elements available. - /// - /// Complexity is `O(n)` where `n` is the length of the iterator. - /// For slices, prefer [`SliceRandom::choose_multiple`]. - #[cfg(feature = "alloc")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] - fn choose_multiple(mut self, rng: &mut R, amount: usize) -> Vec - where R: Rng + ?Sized { - let mut reservoir = Vec::with_capacity(amount); - reservoir.extend(self.by_ref().take(amount)); - - // Continue unless the iterator was exhausted - // - // note: this prevents iterators that "restart" from causing problems. - // If the iterator stops once, then so do we. - if reservoir.len() == amount { - for (i, elem) in self.enumerate() { - let k = gen_index(rng, i + 1 + amount); - if let Some(slot) = reservoir.get_mut(k) { - *slot = elem; - } - } - } else { - // Don't hang onto extra memory. There is a corner case where - // `amount` was much less than `self.len()`. - reservoir.shrink_to_fit(); - } - reservoir - } -} - - -impl SliceRandom for [T] { - type Item = T; - - fn choose(&self, rng: &mut R) -> Option<&Self::Item> - where R: Rng + ?Sized { - if self.is_empty() { - None - } else { - Some(&self[gen_index(rng, self.len())]) - } - } - - fn choose_mut(&mut self, rng: &mut R) -> Option<&mut Self::Item> - where R: Rng + ?Sized { - if self.is_empty() { - None - } else { - let len = self.len(); - Some(&mut self[gen_index(rng, len)]) - } - } - - #[cfg(feature = "alloc")] - fn choose_multiple(&self, rng: &mut R, amount: usize) -> SliceChooseIter - where R: Rng + ?Sized { - let amount = ::core::cmp::min(amount, self.len()); - SliceChooseIter { - slice: self, - _phantom: Default::default(), - indices: index::sample(rng, self.len(), amount).into_iter(), - } - } - - #[cfg(feature = "alloc")] - fn choose_weighted( - &self, rng: &mut R, weight: F, - ) -> Result<&Self::Item, WeightedError> - where - R: Rng + ?Sized, - F: Fn(&Self::Item) -> B, - B: SampleBorrow, - X: SampleUniform - + for<'a> ::core::ops::AddAssign<&'a X> - + ::core::cmp::PartialOrd - + Clone - + Default, - { - use crate::distributions::{Distribution, WeightedIndex}; - let distr = WeightedIndex::new(self.iter().map(weight))?; - Ok(&self[distr.sample(rng)]) - } - - #[cfg(feature = "alloc")] - fn choose_weighted_mut( - &mut self, rng: &mut R, weight: F, - ) -> Result<&mut Self::Item, WeightedError> - where - R: Rng + ?Sized, - F: Fn(&Self::Item) -> B, - B: SampleBorrow, - X: SampleUniform - + for<'a> ::core::ops::AddAssign<&'a X> - + ::core::cmp::PartialOrd - + Clone - + Default, - { - use crate::distributions::{Distribution, WeightedIndex}; - let distr = WeightedIndex::new(self.iter().map(weight))?; - Ok(&mut self[distr.sample(rng)]) - } - - #[cfg(feature = "std")] - fn choose_multiple_weighted( - &self, rng: &mut R, amount: usize, weight: F, - ) -> Result, WeightedError> - where - R: Rng + ?Sized, - F: Fn(&Self::Item) -> X, - X: Into, - { - let amount = ::core::cmp::min(amount, self.len()); - Ok(SliceChooseIter { - slice: self, - _phantom: Default::default(), - indices: index::sample_weighted( - rng, - self.len(), - |idx| weight(&self[idx]).into(), - amount, - )? - .into_iter(), - }) - } - - fn shuffle(&mut self, rng: &mut R) - where R: Rng + ?Sized { - for i in (1..self.len()).rev() { - // invariant: elements with index > i have been locked in place. - self.swap(i, gen_index(rng, i + 1)); - } - } - - fn partial_shuffle( - &mut self, rng: &mut R, amount: usize, - ) -> (&mut [Self::Item], &mut [Self::Item]) - where R: Rng + ?Sized { - // This applies Durstenfeld's algorithm for the - // [Fisher–Yates shuffle](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm) - // for an unbiased permutation, but exits early after choosing `amount` - // elements. - - let len = self.len(); - let end = if amount >= len { 0 } else { len - amount }; - - for i in (end..len).rev() { - // invariant: elements with index > i have been locked in place. - self.swap(i, gen_index(rng, i + 1)); - } - let r = self.split_at_mut(end); - (r.1, r.0) - } -} - -impl IteratorRandom for I where I: Iterator + Sized {} - - -/// An iterator over multiple slice elements. -/// -/// This struct is created by -/// [`SliceRandom::choose_multiple`](trait.SliceRandom.html#tymethod.choose_multiple). -#[cfg(feature = "alloc")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] -#[derive(Debug)] -pub struct SliceChooseIter<'a, S: ?Sized + 'a, T: 'a> { - slice: &'a S, - _phantom: ::core::marker::PhantomData, - indices: index::IndexVecIntoIter, -} - -#[cfg(feature = "alloc")] -impl<'a, S: Index + ?Sized + 'a, T: 'a> Iterator for SliceChooseIter<'a, S, T> { - type Item = &'a T; - - fn next(&mut self) -> Option { - // TODO: investigate using SliceIndex::get_unchecked when stable - self.indices.next().map(|i| &self.slice[i as usize]) - } - - fn size_hint(&self) -> (usize, Option) { - (self.indices.len(), Some(self.indices.len())) - } -} - -#[cfg(feature = "alloc")] -impl<'a, S: Index + ?Sized + 'a, T: 'a> ExactSizeIterator - for SliceChooseIter<'a, S, T> -{ - fn len(&self) -> usize { - self.indices.len() - } -} - - -// Sample a number uniformly between 0 and `ubound`. Uses 32-bit sampling where -// possible, primarily in order to produce the same output on 32-bit and 64-bit -// platforms. -#[inline] -fn gen_index(rng: &mut R, ubound: usize) -> usize { - if ubound <= (core::u32::MAX as usize) { - rng.gen_range(0..ubound as u32) as usize - } else { - rng.gen_range(0..ubound) - } -} - - -#[cfg(test)] -mod test { - use super::*; - #[cfg(feature = "alloc")] use crate::Rng; - #[cfg(all(feature = "alloc", not(feature = "std")))] use alloc::vec::Vec; - - #[test] - fn test_slice_choose() { - let mut r = crate::test::rng(107); - let chars = [ - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - ]; - let mut chosen = [0i32; 14]; - // The below all use a binomial distribution with n=1000, p=1/14. - // binocdf(40, 1000, 1/14) ~= 2e-5; 1-binocdf(106, ..) ~= 2e-5 - for _ in 0..1000 { - let picked = *chars.choose(&mut r).unwrap(); - chosen[(picked as usize) - ('a' as usize)] += 1; - } - for count in chosen.iter() { - assert!(40 < *count && *count < 106); - } - - chosen.iter_mut().for_each(|x| *x = 0); - for _ in 0..1000 { - *chosen.choose_mut(&mut r).unwrap() += 1; - } - for count in chosen.iter() { - assert!(40 < *count && *count < 106); - } - - let mut v: [isize; 0] = []; - assert_eq!(v.choose(&mut r), None); - assert_eq!(v.choose_mut(&mut r), None); - } - - #[test] - fn value_stability_slice() { - let mut r = crate::test::rng(413); - let chars = [ - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - ]; - let mut nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - - assert_eq!(chars.choose(&mut r), Some(&'l')); - assert_eq!(nums.choose_mut(&mut r), Some(&mut 10)); - - #[cfg(feature = "alloc")] - assert_eq!( - &chars - .choose_multiple(&mut r, 8) - .cloned() - .collect::>(), - &['d', 'm', 'b', 'n', 'c', 'k', 'h', 'e'] - ); - - #[cfg(feature = "alloc")] - assert_eq!(chars.choose_weighted(&mut r, |_| 1), Ok(&'f')); - #[cfg(feature = "alloc")] - assert_eq!(nums.choose_weighted_mut(&mut r, |_| 1), Ok(&mut 5)); - - let mut r = crate::test::rng(414); - nums.shuffle(&mut r); - assert_eq!(nums, [9, 5, 3, 10, 7, 12, 8, 11, 6, 4, 0, 2, 1]); - nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - let res = nums.partial_shuffle(&mut r, 6); - assert_eq!(res.0, &mut [7, 4, 8, 6, 9, 3]); - assert_eq!(res.1, &mut [0, 1, 2, 12, 11, 5, 10]); - } - - #[derive(Clone)] - struct UnhintedIterator { - iter: I, - } - impl Iterator for UnhintedIterator { - type Item = I::Item; - - fn next(&mut self) -> Option { - self.iter.next() - } - } - - #[derive(Clone)] - struct ChunkHintedIterator { - iter: I, - chunk_remaining: usize, - chunk_size: usize, - hint_total_size: bool, - } - impl Iterator for ChunkHintedIterator { - type Item = I::Item; - - fn next(&mut self) -> Option { - if self.chunk_remaining == 0 { - self.chunk_remaining = ::core::cmp::min(self.chunk_size, self.iter.len()); - } - self.chunk_remaining = self.chunk_remaining.saturating_sub(1); - - self.iter.next() - } - - fn size_hint(&self) -> (usize, Option) { - ( - self.chunk_remaining, - if self.hint_total_size { - Some(self.iter.len()) - } else { - None - }, - ) - } - } - - #[derive(Clone)] - struct WindowHintedIterator { - iter: I, - window_size: usize, - hint_total_size: bool, - } - impl Iterator for WindowHintedIterator { - type Item = I::Item; - - fn next(&mut self) -> Option { - self.iter.next() - } - - fn size_hint(&self) -> (usize, Option) { - ( - ::core::cmp::min(self.iter.len(), self.window_size), - if self.hint_total_size { - Some(self.iter.len()) - } else { - None - }, - ) - } - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_iterator_choose() { - let r = &mut crate::test::rng(109); - fn test_iter + Clone>(r: &mut R, iter: Iter) { - let mut chosen = [0i32; 9]; - for _ in 0..1000 { - let picked = iter.clone().choose(r).unwrap(); - chosen[picked] += 1; - } - for count in chosen.iter() { - // Samples should follow Binomial(1000, 1/9) - // Octave: binopdf(x, 1000, 1/9) gives the prob of *count == x - // Note: have seen 153, which is unlikely but not impossible. - assert!( - 72 < *count && *count < 154, - "count not close to 1000/9: {}", - count - ); - } - } - - test_iter(r, 0..9); - test_iter(r, [0, 1, 2, 3, 4, 5, 6, 7, 8].iter().cloned()); - #[cfg(feature = "alloc")] - test_iter(r, (0..9).collect::>().into_iter()); - test_iter(r, UnhintedIterator { iter: 0..9 }); - test_iter(r, ChunkHintedIterator { - iter: 0..9, - chunk_size: 4, - chunk_remaining: 4, - hint_total_size: false, - }); - test_iter(r, ChunkHintedIterator { - iter: 0..9, - chunk_size: 4, - chunk_remaining: 4, - hint_total_size: true, - }); - test_iter(r, WindowHintedIterator { - iter: 0..9, - window_size: 2, - hint_total_size: false, - }); - test_iter(r, WindowHintedIterator { - iter: 0..9, - window_size: 2, - hint_total_size: true, - }); - - assert_eq!((0..0).choose(r), None); - assert_eq!(UnhintedIterator { iter: 0..0 }.choose(r), None); - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_iterator_choose_stable() { - let r = &mut crate::test::rng(109); - fn test_iter + Clone>(r: &mut R, iter: Iter) { - let mut chosen = [0i32; 9]; - for _ in 0..1000 { - let picked = iter.clone().choose_stable(r).unwrap(); - chosen[picked] += 1; - } - for count in chosen.iter() { - // Samples should follow Binomial(1000, 1/9) - // Octave: binopdf(x, 1000, 1/9) gives the prob of *count == x - // Note: have seen 153, which is unlikely but not impossible. - assert!( - 72 < *count && *count < 154, - "count not close to 1000/9: {}", - count - ); - } - } - - test_iter(r, 0..9); - test_iter(r, [0, 1, 2, 3, 4, 5, 6, 7, 8].iter().cloned()); - #[cfg(feature = "alloc")] - test_iter(r, (0..9).collect::>().into_iter()); - test_iter(r, UnhintedIterator { iter: 0..9 }); - test_iter(r, ChunkHintedIterator { - iter: 0..9, - chunk_size: 4, - chunk_remaining: 4, - hint_total_size: false, - }); - test_iter(r, ChunkHintedIterator { - iter: 0..9, - chunk_size: 4, - chunk_remaining: 4, - hint_total_size: true, - }); - test_iter(r, WindowHintedIterator { - iter: 0..9, - window_size: 2, - hint_total_size: false, - }); - test_iter(r, WindowHintedIterator { - iter: 0..9, - window_size: 2, - hint_total_size: true, - }); - - assert_eq!((0..0).choose(r), None); - assert_eq!(UnhintedIterator { iter: 0..0 }.choose(r), None); - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_iterator_choose_stable_stability() { - fn test_iter(iter: impl Iterator + Clone) -> [i32; 9] { - let r = &mut crate::test::rng(109); - let mut chosen = [0i32; 9]; - for _ in 0..1000 { - let picked = iter.clone().choose_stable(r).unwrap(); - chosen[picked] += 1; - } - chosen - } - - let reference = test_iter(0..9); - assert_eq!(test_iter([0, 1, 2, 3, 4, 5, 6, 7, 8].iter().cloned()), reference); - - #[cfg(feature = "alloc")] - assert_eq!(test_iter((0..9).collect::>().into_iter()), reference); - assert_eq!(test_iter(UnhintedIterator { iter: 0..9 }), reference); - assert_eq!(test_iter(ChunkHintedIterator { - iter: 0..9, - chunk_size: 4, - chunk_remaining: 4, - hint_total_size: false, - }), reference); - assert_eq!(test_iter(ChunkHintedIterator { - iter: 0..9, - chunk_size: 4, - chunk_remaining: 4, - hint_total_size: true, - }), reference); - assert_eq!(test_iter(WindowHintedIterator { - iter: 0..9, - window_size: 2, - hint_total_size: false, - }), reference); - assert_eq!(test_iter(WindowHintedIterator { - iter: 0..9, - window_size: 2, - hint_total_size: true, - }), reference); - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_shuffle() { - let mut r = crate::test::rng(108); - let empty: &mut [isize] = &mut []; - empty.shuffle(&mut r); - let mut one = [1]; - one.shuffle(&mut r); - let b: &[_] = &[1]; - assert_eq!(one, b); - - let mut two = [1, 2]; - two.shuffle(&mut r); - assert!(two == [1, 2] || two == [2, 1]); - - fn move_last(slice: &mut [usize], pos: usize) { - // use slice[pos..].rotate_left(1); once we can use that - let last_val = slice[pos]; - for i in pos..slice.len() - 1 { - slice[i] = slice[i + 1]; - } - *slice.last_mut().unwrap() = last_val; - } - let mut counts = [0i32; 24]; - for _ in 0..10000 { - let mut arr: [usize; 4] = [0, 1, 2, 3]; - arr.shuffle(&mut r); - let mut permutation = 0usize; - let mut pos_value = counts.len(); - for i in 0..4 { - pos_value /= 4 - i; - let pos = arr.iter().position(|&x| x == i).unwrap(); - assert!(pos < (4 - i)); - permutation += pos * pos_value; - move_last(&mut arr, pos); - assert_eq!(arr[3], i); - } - for (i, &a) in arr.iter().enumerate() { - assert_eq!(a, i); - } - counts[permutation] += 1; - } - for count in counts.iter() { - // Binomial(10000, 1/24) with average 416.667 - // Octave: binocdf(n, 10000, 1/24) - // 99.9% chance samples lie within this range: - assert!(352 <= *count && *count <= 483, "count: {}", count); - } - } - - #[test] - fn test_partial_shuffle() { - let mut r = crate::test::rng(118); - - let mut empty: [u32; 0] = []; - let res = empty.partial_shuffle(&mut r, 10); - assert_eq!((res.0.len(), res.1.len()), (0, 0)); - - let mut v = [1, 2, 3, 4, 5]; - let res = v.partial_shuffle(&mut r, 2); - assert_eq!((res.0.len(), res.1.len()), (2, 3)); - assert!(res.0[0] != res.0[1]); - // First elements are only modified if selected, so at least one isn't modified: - assert!(res.1[0] == 1 || res.1[1] == 2 || res.1[2] == 3); - } - - #[test] - #[cfg(feature = "alloc")] - fn test_sample_iter() { - let min_val = 1; - let max_val = 100; - - let mut r = crate::test::rng(401); - let vals = (min_val..max_val).collect::>(); - let small_sample = vals.iter().choose_multiple(&mut r, 5); - let large_sample = vals.iter().choose_multiple(&mut r, vals.len() + 5); - - assert_eq!(small_sample.len(), 5); - assert_eq!(large_sample.len(), vals.len()); - // no randomization happens when amount >= len - assert_eq!(large_sample, vals.iter().collect::>()); - - assert!(small_sample - .iter() - .all(|e| { **e >= min_val && **e <= max_val })); - } - - #[test] - #[cfg(feature = "alloc")] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_weighted() { - let mut r = crate::test::rng(406); - const N_REPS: u32 = 3000; - let weights = [1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7]; - let total_weight = weights.iter().sum::() as f32; - - let verify = |result: [i32; 14]| { - for (i, count) in result.iter().enumerate() { - let exp = (weights[i] * N_REPS) as f32 / total_weight; - let mut err = (*count as f32 - exp).abs(); - if err != 0.0 { - err /= exp; - } - assert!(err <= 0.25); - } - }; - - // choose_weighted - fn get_weight(item: &(u32, T)) -> u32 { - item.0 - } - let mut chosen = [0i32; 14]; - let mut items = [(0u32, 0usize); 14]; // (weight, index) - for (i, item) in items.iter_mut().enumerate() { - *item = (weights[i], i); - } - for _ in 0..N_REPS { - let item = items.choose_weighted(&mut r, get_weight).unwrap(); - chosen[item.1] += 1; - } - verify(chosen); - - // choose_weighted_mut - let mut items = [(0u32, 0i32); 14]; // (weight, count) - for (i, item) in items.iter_mut().enumerate() { - *item = (weights[i], 0); - } - for _ in 0..N_REPS { - items.choose_weighted_mut(&mut r, get_weight).unwrap().1 += 1; - } - for (ch, item) in chosen.iter_mut().zip(items.iter()) { - *ch = item.1; - } - verify(chosen); - - // Check error cases - let empty_slice = &mut [10][0..0]; - assert_eq!( - empty_slice.choose_weighted(&mut r, |_| 1), - Err(WeightedError::NoItem) - ); - assert_eq!( - empty_slice.choose_weighted_mut(&mut r, |_| 1), - Err(WeightedError::NoItem) - ); - assert_eq!( - ['x'].choose_weighted_mut(&mut r, |_| 0), - Err(WeightedError::AllWeightsZero) - ); - assert_eq!( - [0, -1].choose_weighted_mut(&mut r, |x| *x), - Err(WeightedError::InvalidWeight) - ); - assert_eq!( - [-1, 0].choose_weighted_mut(&mut r, |x| *x), - Err(WeightedError::InvalidWeight) - ); - } - - #[test] - fn value_stability_choose() { - fn choose>(iter: I) -> Option { - let mut rng = crate::test::rng(411); - iter.choose(&mut rng) - } - - assert_eq!(choose([].iter().cloned()), None); - assert_eq!(choose(0..100), Some(33)); - assert_eq!(choose(UnhintedIterator { iter: 0..100 }), Some(40)); - assert_eq!( - choose(ChunkHintedIterator { - iter: 0..100, - chunk_size: 32, - chunk_remaining: 32, - hint_total_size: false, - }), - Some(39) - ); - assert_eq!( - choose(ChunkHintedIterator { - iter: 0..100, - chunk_size: 32, - chunk_remaining: 32, - hint_total_size: true, - }), - Some(39) - ); - assert_eq!( - choose(WindowHintedIterator { - iter: 0..100, - window_size: 32, - hint_total_size: false, - }), - Some(90) - ); - assert_eq!( - choose(WindowHintedIterator { - iter: 0..100, - window_size: 32, - hint_total_size: true, - }), - Some(90) - ); - } - - #[test] - fn value_stability_choose_stable() { - fn choose>(iter: I) -> Option { - let mut rng = crate::test::rng(411); - iter.choose_stable(&mut rng) - } - - assert_eq!(choose([].iter().cloned()), None); - assert_eq!(choose(0..100), Some(40)); - assert_eq!(choose(UnhintedIterator { iter: 0..100 }), Some(40)); - assert_eq!( - choose(ChunkHintedIterator { - iter: 0..100, - chunk_size: 32, - chunk_remaining: 32, - hint_total_size: false, - }), - Some(40) - ); - assert_eq!( - choose(ChunkHintedIterator { - iter: 0..100, - chunk_size: 32, - chunk_remaining: 32, - hint_total_size: true, - }), - Some(40) - ); - assert_eq!( - choose(WindowHintedIterator { - iter: 0..100, - window_size: 32, - hint_total_size: false, - }), - Some(40) - ); - assert_eq!( - choose(WindowHintedIterator { - iter: 0..100, - window_size: 32, - hint_total_size: true, - }), - Some(40) - ); - } - - #[test] - fn value_stability_choose_multiple() { - fn do_test>(iter: I, v: &[u32]) { - let mut rng = crate::test::rng(412); - let mut buf = [0u32; 8]; - assert_eq!(iter.choose_multiple_fill(&mut rng, &mut buf), v.len()); - assert_eq!(&buf[0..v.len()], v); - } - - do_test(0..4, &[0, 1, 2, 3]); - do_test(0..8, &[0, 1, 2, 3, 4, 5, 6, 7]); - do_test(0..100, &[58, 78, 80, 92, 43, 8, 96, 7]); - - #[cfg(feature = "alloc")] - { - fn do_test>(iter: I, v: &[u32]) { - let mut rng = crate::test::rng(412); - assert_eq!(iter.choose_multiple(&mut rng, v.len()), v); - } - - do_test(0..4, &[0, 1, 2, 3]); - do_test(0..8, &[0, 1, 2, 3, 4, 5, 6, 7]); - do_test(0..100, &[58, 78, 80, 92, 43, 8, 96, 7]); - } - } - - #[test] - #[cfg(feature = "std")] - fn test_multiple_weighted_edge_cases() { - use super::*; - - let mut rng = crate::test::rng(413); - - // Case 1: One of the weights is 0 - let choices = [('a', 2), ('b', 1), ('c', 0)]; - for _ in 0..100 { - let result = choices - .choose_multiple_weighted(&mut rng, 2, |item| item.1) - .unwrap() - .collect::>(); - - assert_eq!(result.len(), 2); - assert!(!result.iter().any(|val| val.0 == 'c')); - } - - // Case 2: All of the weights are 0 - let choices = [('a', 0), ('b', 0), ('c', 0)]; - let result = choices - .choose_multiple_weighted(&mut rng, 2, |item| item.1) - .unwrap() - .collect::>(); - assert_eq!(result.len(), 2); - - // Case 3: Negative weights - let choices = [('a', -1), ('b', 1), ('c', 1)]; - assert_eq!( - choices - .choose_multiple_weighted(&mut rng, 2, |item| item.1) - .unwrap_err(), - WeightedError::InvalidWeight - ); - - // Case 4: Empty list - let choices = []; - let result = choices - .choose_multiple_weighted(&mut rng, 0, |_: &()| 0) - .unwrap() - .collect::>(); - assert_eq!(result.len(), 0); - - // Case 5: NaN weights - let choices = [('a', core::f64::NAN), ('b', 1.0), ('c', 1.0)]; - assert_eq!( - choices - .choose_multiple_weighted(&mut rng, 2, |item| item.1) - .unwrap_err(), - WeightedError::InvalidWeight - ); - - // Case 6: +infinity weights - let choices = [('a', core::f64::INFINITY), ('b', 1.0), ('c', 1.0)]; - for _ in 0..100 { - let result = choices - .choose_multiple_weighted(&mut rng, 2, |item| item.1) - .unwrap() - .collect::>(); - assert_eq!(result.len(), 2); - assert!(result.iter().any(|val| val.0 == 'a')); - } - - // Case 7: -infinity weights - let choices = [('a', core::f64::NEG_INFINITY), ('b', 1.0), ('c', 1.0)]; - assert_eq!( - choices - .choose_multiple_weighted(&mut rng, 2, |item| item.1) - .unwrap_err(), - WeightedError::InvalidWeight - ); - - // Case 8: -0 weights - let choices = [('a', -0.0), ('b', 1.0), ('c', 1.0)]; - assert!(choices - .choose_multiple_weighted(&mut rng, 2, |item| item.1) - .is_ok()); - } - - #[test] - #[cfg(feature = "std")] - fn test_multiple_weighted_distributions() { - use super::*; - - // The theoretical probabilities of the different outcomes are: - // AB: 0.5 * 0.5 = 0.250 - // AC: 0.5 * 0.5 = 0.250 - // BA: 0.25 * 0.67 = 0.167 - // BC: 0.25 * 0.33 = 0.082 - // CA: 0.25 * 0.67 = 0.167 - // CB: 0.25 * 0.33 = 0.082 - let choices = [('a', 2), ('b', 1), ('c', 1)]; - let mut rng = crate::test::rng(414); - - let mut results = [0i32; 3]; - let expected_results = [4167, 4167, 1666]; - for _ in 0..10000 { - let result = choices - .choose_multiple_weighted(&mut rng, 2, |item| item.1) - .unwrap() - .collect::>(); - - assert_eq!(result.len(), 2); - - match (result[0].0, result[1].0) { - ('a', 'b') | ('b', 'a') => { - results[0] += 1; - } - ('a', 'c') | ('c', 'a') => { - results[1] += 1; - } - ('b', 'c') | ('c', 'b') => { - results[2] += 1; - } - (_, _) => panic!("unexpected result"), - } - } - - let mut diffs = results - .iter() - .zip(&expected_results) - .map(|(a, b)| (a - b).abs()); - assert!(!diffs.any(|deviation| deviation > 100)); - } -} diff -Nru cargo-0.58.0/vendor/rand_chacha/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/rand_chacha/.cargo-checksum.json --- cargo-0.58.0/vendor/rand_chacha/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_chacha/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -{"files":{},"package":"e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/rand_chacha/Cargo.toml cargo-0.60.0ubuntu1/vendor/rand_chacha/Cargo.toml --- cargo-0.58.0/vendor/rand_chacha/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_chacha/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - -[package] -edition = "2018" -name = "rand_chacha" -version = "0.3.1" -authors = ["The Rand Project Developers", "The Rust Project Developers", "The CryptoCorrosion Contributors"] -description = "ChaCha random number generator\n" -homepage = "https://rust-random.github.io/book" -documentation = "https://docs.rs/rand_chacha" -readme = "README.md" -keywords = ["random", "rng", "chacha"] -categories = ["algorithms", "no-std"] -license = "MIT OR Apache-2.0" -repository = "https://github.com/rust-random/rand" -[dependencies.ppv-lite86] -version = "0.2.8" -features = ["simd"] -default-features = false - -[dependencies.rand_core] -version = "0.6.0" - -[dependencies.serde] -version = "1.0" -features = ["derive"] -optional = true -[dev-dependencies.serde_json] -version = "1.0" - -[features] -default = ["std"] -serde1 = ["serde"] -simd = [] -std = ["ppv-lite86/std"] diff -Nru cargo-0.58.0/vendor/rand_chacha/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/rand_chacha/CHANGELOG.md --- cargo-0.58.0/vendor/rand_chacha/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_chacha/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [0.3.1] - 2021-06-09 -- add getters corresponding to existing setters: `get_seed`, `get_stream` (#1124) -- add serde support, gated by the `serde1` feature (#1124) -- ensure expected layout via `repr(transparent)` (#1120) - -## [0.3.0] - 2020-12-08 -- Bump `rand_core` version to 0.6.0 -- Bump MSRV to 1.36 (#1011) -- Remove usage of deprecated feature "simd" of `ppv-lite86` (#979), then revert - this change (#1023) since SIMD is only enabled by default from `ppv-lite86 v0.2.10` -- impl PartialEq+Eq for ChaChaXRng and ChaChaXCore (#979) -- Fix panic on block counter wrap that was occurring in debug builds (#980) - -## [0.2.2] - 2020-03-09 -- Integrate `c2-chacha`, reducing dependency count (#931) -- Add CryptoRng to ChaChaXCore (#944) - -## [0.2.1] - 2019-07-22 -- Force enable the `simd` feature of `c2-chacha` (#845) - -## [0.2.0] - 2019-06-06 -- Rewrite based on the much faster `c2-chacha` crate (#789) - -## [0.1.1] - 2019-01-04 -- Disable `i128` and `u128` if the `target_os` is `emscripten` (#671: work-around Emscripten limitation) -- Update readme and doc links - -## [0.1.0] - 2018-10-17 -- Pulled out of the Rand crate diff -Nru cargo-0.58.0/vendor/rand_chacha/COPYRIGHT cargo-0.60.0ubuntu1/vendor/rand_chacha/COPYRIGHT --- cargo-0.58.0/vendor/rand_chacha/COPYRIGHT 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_chacha/COPYRIGHT 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -Copyrights in the Rand project are retained by their contributors. No -copyright assignment is required to contribute to the Rand project. - -For full authorship information, see the version control history. - -Except as otherwise noted (below and/or in individual files), Rand is -licensed under the Apache License, Version 2.0 or - or the MIT license - or , at your option. - -The Rand project includes code from the Rust project -published under these same licenses. diff -Nru cargo-0.58.0/vendor/rand_chacha/LICENSE-APACHE cargo-0.60.0ubuntu1/vendor/rand_chacha/LICENSE-APACHE --- cargo-0.58.0/vendor/rand_chacha/LICENSE-APACHE 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_chacha/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff -Nru cargo-0.58.0/vendor/rand_chacha/LICENSE-MIT cargo-0.60.0ubuntu1/vendor/rand_chacha/LICENSE-MIT --- cargo-0.58.0/vendor/rand_chacha/LICENSE-MIT 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_chacha/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -Copyright 2018 Developers of the Rand project -Copyright (c) 2014 The Rust Project Developers - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff -Nru cargo-0.58.0/vendor/rand_chacha/README.md cargo-0.60.0ubuntu1/vendor/rand_chacha/README.md --- cargo-0.58.0/vendor/rand_chacha/README.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_chacha/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -# rand_chacha - -[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rand/actions) -[![Latest version](https://img.shields.io/crates/v/rand_chacha.svg)](https://crates.io/crates/rand_chacha) -[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) -[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_chacha) -[![API](https://docs.rs/rand_chacha/badge.svg)](https://docs.rs/rand_chacha) -[![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) - -A cryptographically secure random number generator that uses the ChaCha -algorithm. - -ChaCha is a stream cipher designed by Daniel J. Bernstein[^1], that we use -as an RNG. It is an improved variant of the Salsa20 cipher family, which was -selected as one of the "stream ciphers suitable for widespread adoption" by -eSTREAM[^2]. - -The RNGs provided by this crate are implemented via the fast stream ciphers of -the [`c2-chacha`](https://crates.io/crates/c2-chacha) crate. - -Links: - -- [API documentation (master)](https://rust-random.github.io/rand/rand_chacha) -- [API documentation (docs.rs)](https://docs.rs/rand_chacha) -- [Changelog](https://github.com/rust-random/rand/blob/master/rand_chacha/CHANGELOG.md) - -[rand]: https://crates.io/crates/rand -[^1]: D. J. Bernstein, [*ChaCha, a variant of Salsa20*]( - https://cr.yp.to/chacha.html) - -[^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( - http://www.ecrypt.eu.org/stream/) - - -## Crate Features - -`rand_chacha` is `no_std` compatible when disabling default features; the `std` -feature can be explicitly required to re-enable `std` support. Using `std` -allows detection of CPU features and thus better optimisation. - - -# License - -`rand_chacha` is distributed under the terms of both the MIT license and the -Apache License (Version 2.0). - -See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and -[COPYRIGHT](COPYRIGHT) for details. diff -Nru cargo-0.58.0/vendor/rand_chacha/src/chacha.rs cargo-0.60.0ubuntu1/vendor/rand_chacha/src/chacha.rs --- cargo-0.58.0/vendor/rand_chacha/src/chacha.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_chacha/src/chacha.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,632 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The ChaCha random number generator. - -#[cfg(not(feature = "std"))] use core; -#[cfg(feature = "std")] use std as core; - -use self::core::fmt; -use crate::guts::ChaCha; -use rand_core::block::{BlockRng, BlockRngCore}; -use rand_core::{CryptoRng, Error, RngCore, SeedableRng}; - -#[cfg(feature = "serde1")] use serde::{Serialize, Deserialize, Serializer, Deserializer}; - -// NB. this must remain consistent with some currently hard-coded numbers in this module -const BUF_BLOCKS: u8 = 4; -// number of 32-bit words per ChaCha block (fixed by algorithm definition) -const BLOCK_WORDS: u8 = 16; - -#[repr(transparent)] -pub struct Array64([T; 64]); -impl Default for Array64 -where T: Default -{ - #[rustfmt::skip] - fn default() -> Self { - Self([ - T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), - T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), - T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), - T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), - T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), - T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), - T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), - T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), T::default(), - ]) - } -} -impl AsRef<[T]> for Array64 { - fn as_ref(&self) -> &[T] { - &self.0 - } -} -impl AsMut<[T]> for Array64 { - fn as_mut(&mut self) -> &mut [T] { - &mut self.0 - } -} -impl Clone for Array64 -where T: Copy + Default -{ - fn clone(&self) -> Self { - let mut new = Self::default(); - new.0.copy_from_slice(&self.0); - new - } -} -impl fmt::Debug for Array64 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Array64 {{}}") - } -} - -macro_rules! chacha_impl { - ($ChaChaXCore:ident, $ChaChaXRng:ident, $rounds:expr, $doc:expr, $abst:ident) => { - #[doc=$doc] - #[derive(Clone, PartialEq, Eq)] - pub struct $ChaChaXCore { - state: ChaCha, - } - - // Custom Debug implementation that does not expose the internal state - impl fmt::Debug for $ChaChaXCore { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "ChaChaXCore {{}}") - } - } - - impl BlockRngCore for $ChaChaXCore { - type Item = u32; - type Results = Array64; - #[inline] - fn generate(&mut self, r: &mut Self::Results) { - // Fill slice of words by writing to equivalent slice of bytes, then fixing endianness. - self.state.refill4($rounds, unsafe { - &mut *(&mut *r as *mut Array64 as *mut [u8; 256]) - }); - for x in r.as_mut() { - *x = x.to_le(); - } - } - } - - impl SeedableRng for $ChaChaXCore { - type Seed = [u8; 32]; - #[inline] - fn from_seed(seed: Self::Seed) -> Self { - $ChaChaXCore { state: ChaCha::new(&seed, &[0u8; 8]) } - } - } - - impl CryptoRng for $ChaChaXCore {} - - /// A cryptographically secure random number generator that uses the ChaCha algorithm. - /// - /// ChaCha is a stream cipher designed by Daniel J. Bernstein[^1], that we use as an RNG. It is - /// an improved variant of the Salsa20 cipher family, which was selected as one of the "stream - /// ciphers suitable for widespread adoption" by eSTREAM[^2]. - /// - /// ChaCha uses add-rotate-xor (ARX) operations as its basis. These are safe against timing - /// attacks, although that is mostly a concern for ciphers and not for RNGs. We provide a SIMD - /// implementation to support high throughput on a variety of common hardware platforms. - /// - /// With the ChaCha algorithm it is possible to choose the number of rounds the core algorithm - /// should run. The number of rounds is a tradeoff between performance and security, where 8 - /// rounds is the minimum potentially secure configuration, and 20 rounds is widely used as a - /// conservative choice. - /// - /// We use a 64-bit counter and 64-bit stream identifier as in Bernstein's implementation[^1] - /// except that we use a stream identifier in place of a nonce. A 64-bit counter over 64-byte - /// (16 word) blocks allows 1 ZiB of output before cycling, and the stream identifier allows - /// 264 unique streams of output per seed. Both counter and stream are initialized - /// to zero but may be set via the `set_word_pos` and `set_stream` methods. - /// - /// The word layout is: - /// - /// ```text - /// constant constant constant constant - /// seed seed seed seed - /// seed seed seed seed - /// counter counter stream_id stream_id - /// ``` - /// - /// This implementation uses an output buffer of sixteen `u32` words, and uses - /// [`BlockRng`] to implement the [`RngCore`] methods. - /// - /// [^1]: D. J. Bernstein, [*ChaCha, a variant of Salsa20*]( - /// https://cr.yp.to/chacha.html) - /// - /// [^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( - /// http://www.ecrypt.eu.org/stream/) - #[derive(Clone, Debug)] - pub struct $ChaChaXRng { - rng: BlockRng<$ChaChaXCore>, - } - - impl SeedableRng for $ChaChaXRng { - type Seed = [u8; 32]; - #[inline] - fn from_seed(seed: Self::Seed) -> Self { - let core = $ChaChaXCore::from_seed(seed); - Self { - rng: BlockRng::new(core), - } - } - } - - impl RngCore for $ChaChaXRng { - #[inline] - fn next_u32(&mut self) -> u32 { - self.rng.next_u32() - } - #[inline] - fn next_u64(&mut self) -> u64 { - self.rng.next_u64() - } - #[inline] - fn fill_bytes(&mut self, bytes: &mut [u8]) { - self.rng.fill_bytes(bytes) - } - #[inline] - fn try_fill_bytes(&mut self, bytes: &mut [u8]) -> Result<(), Error> { - self.rng.try_fill_bytes(bytes) - } - } - - impl $ChaChaXRng { - // The buffer is a 4-block window, i.e. it is always at a block-aligned position in the - // stream but if the stream has been seeked it may not be self-aligned. - - /// Get the offset from the start of the stream, in 32-bit words. - /// - /// Since the generated blocks are 16 words (24) long and the - /// counter is 64-bits, the offset is a 68-bit number. Sub-word offsets are - /// not supported, hence the result can simply be multiplied by 4 to get a - /// byte-offset. - #[inline] - pub fn get_word_pos(&self) -> u128 { - let buf_start_block = { - let buf_end_block = self.rng.core.state.get_block_pos(); - u64::wrapping_sub(buf_end_block, BUF_BLOCKS.into()) - }; - let (buf_offset_blocks, block_offset_words) = { - let buf_offset_words = self.rng.index() as u64; - let blocks_part = buf_offset_words / u64::from(BLOCK_WORDS); - let words_part = buf_offset_words % u64::from(BLOCK_WORDS); - (blocks_part, words_part) - }; - let pos_block = u64::wrapping_add(buf_start_block, buf_offset_blocks); - let pos_block_words = u128::from(pos_block) * u128::from(BLOCK_WORDS); - pos_block_words + u128::from(block_offset_words) - } - - /// Set the offset from the start of the stream, in 32-bit words. - /// - /// As with `get_word_pos`, we use a 68-bit number. Since the generator - /// simply cycles at the end of its period (1 ZiB), we ignore the upper - /// 60 bits. - #[inline] - pub fn set_word_pos(&mut self, word_offset: u128) { - let block = (word_offset / u128::from(BLOCK_WORDS)) as u64; - self.rng - .core - .state - .set_block_pos(block); - self.rng.generate_and_set((word_offset % u128::from(BLOCK_WORDS)) as usize); - } - - /// Set the stream number. - /// - /// This is initialized to zero; 264 unique streams of output - /// are available per seed/key. - /// - /// Note that in order to reproduce ChaCha output with a specific 64-bit - /// nonce, one can convert that nonce to a `u64` in little-endian fashion - /// and pass to this function. In theory a 96-bit nonce can be used by - /// passing the last 64-bits to this function and using the first 32-bits as - /// the most significant half of the 64-bit counter (which may be set - /// indirectly via `set_word_pos`), but this is not directly supported. - #[inline] - pub fn set_stream(&mut self, stream: u64) { - self.rng - .core - .state - .set_nonce(stream); - if self.rng.index() != 64 { - let wp = self.get_word_pos(); - self.set_word_pos(wp); - } - } - - /// Get the stream number. - #[inline] - pub fn get_stream(&self) -> u64 { - self.rng - .core - .state - .get_nonce() - } - - /// Get the seed. - #[inline] - pub fn get_seed(&self) -> [u8; 32] { - self.rng - .core - .state - .get_seed() - } - } - - impl CryptoRng for $ChaChaXRng {} - - impl From<$ChaChaXCore> for $ChaChaXRng { - fn from(core: $ChaChaXCore) -> Self { - $ChaChaXRng { - rng: BlockRng::new(core), - } - } - } - - impl PartialEq<$ChaChaXRng> for $ChaChaXRng { - fn eq(&self, rhs: &$ChaChaXRng) -> bool { - let a: $abst::$ChaChaXRng = self.into(); - let b: $abst::$ChaChaXRng = rhs.into(); - a == b - } - } - impl Eq for $ChaChaXRng {} - - #[cfg(feature = "serde1")] - impl Serialize for $ChaChaXRng { - fn serialize(&self, s: S) -> Result - where S: Serializer { - $abst::$ChaChaXRng::from(self).serialize(s) - } - } - #[cfg(feature = "serde1")] - impl<'de> Deserialize<'de> for $ChaChaXRng { - fn deserialize(d: D) -> Result where D: Deserializer<'de> { - $abst::$ChaChaXRng::deserialize(d).map(|x| Self::from(&x)) - } - } - - mod $abst { - #[cfg(feature = "serde1")] use serde::{Serialize, Deserialize}; - - // The abstract state of a ChaCha stream, independent of implementation choices. The - // comparison and serialization of this object is considered a semver-covered part of - // the API. - #[derive(Debug, PartialEq, Eq)] - #[cfg_attr( - feature = "serde1", - derive(Serialize, Deserialize), - )] - pub(crate) struct $ChaChaXRng { - seed: [u8; 32], - stream: u64, - word_pos: u128, - } - - impl From<&super::$ChaChaXRng> for $ChaChaXRng { - // Forget all information about the input except what is necessary to determine the - // outputs of any sequence of pub API calls. - fn from(r: &super::$ChaChaXRng) -> Self { - Self { - seed: r.get_seed(), - stream: r.get_stream(), - word_pos: r.get_word_pos(), - } - } - } - - impl From<&$ChaChaXRng> for super::$ChaChaXRng { - // Construct one of the possible concrete RNGs realizing an abstract state. - fn from(a: &$ChaChaXRng) -> Self { - use rand_core::SeedableRng; - let mut r = Self::from_seed(a.seed); - r.set_stream(a.stream); - r.set_word_pos(a.word_pos); - r - } - } - } - } -} - -chacha_impl!(ChaCha20Core, ChaCha20Rng, 10, "ChaCha with 20 rounds", abstract20); -chacha_impl!(ChaCha12Core, ChaCha12Rng, 6, "ChaCha with 12 rounds", abstract12); -chacha_impl!(ChaCha8Core, ChaCha8Rng, 4, "ChaCha with 8 rounds", abstract8); - -#[cfg(test)] -mod test { - use rand_core::{RngCore, SeedableRng}; - - #[cfg(feature = "serde1")] use super::{ChaCha20Rng, ChaCha12Rng, ChaCha8Rng}; - - type ChaChaRng = super::ChaCha20Rng; - - #[cfg(feature = "serde1")] - #[test] - fn test_chacha_serde_roundtrip() { - let seed = [ - 1, 0, 52, 0, 0, 0, 0, 0, 1, 0, 10, 0, 22, 32, 0, 0, 2, 0, 55, 49, 0, 11, 0, 0, 3, 0, 0, 0, 0, - 0, 2, 92, - ]; - let mut rng1 = ChaCha20Rng::from_seed(seed); - let mut rng2 = ChaCha12Rng::from_seed(seed); - let mut rng3 = ChaCha8Rng::from_seed(seed); - - let encoded1 = serde_json::to_string(&rng1).unwrap(); - let encoded2 = serde_json::to_string(&rng2).unwrap(); - let encoded3 = serde_json::to_string(&rng3).unwrap(); - - let mut decoded1: ChaCha20Rng = serde_json::from_str(&encoded1).unwrap(); - let mut decoded2: ChaCha12Rng = serde_json::from_str(&encoded2).unwrap(); - let mut decoded3: ChaCha8Rng = serde_json::from_str(&encoded3).unwrap(); - - assert_eq!(rng1, decoded1); - assert_eq!(rng2, decoded2); - assert_eq!(rng3, decoded3); - - assert_eq!(rng1.next_u32(), decoded1.next_u32()); - assert_eq!(rng2.next_u32(), decoded2.next_u32()); - assert_eq!(rng3.next_u32(), decoded3.next_u32()); - } - - // This test validates that: - // 1. a hard-coded serialization demonstrating the format at time of initial release can still - // be deserialized to a ChaChaRng - // 2. re-serializing the resultant object produces exactly the original string - // - // Condition 2 is stronger than necessary: an equivalent serialization (e.g. with field order - // permuted, or whitespace differences) would also be admissible, but would fail this test. - // However testing for equivalence of serialized data is difficult, and there shouldn't be any - // reason we need to violate the stronger-than-needed condition, e.g. by changing the field - // definition order. - #[cfg(feature = "serde1")] - #[test] - fn test_chacha_serde_format_stability() { - let j = r#"{"seed":[4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8],"stream":27182818284,"word_pos":314159265359}"#; - let r: ChaChaRng = serde_json::from_str(&j).unwrap(); - let j1 = serde_json::to_string(&r).unwrap(); - assert_eq!(j, j1); - } - - #[test] - fn test_chacha_construction() { - let seed = [ - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, - ]; - let mut rng1 = ChaChaRng::from_seed(seed); - assert_eq!(rng1.next_u32(), 137206642); - - let mut rng2 = ChaChaRng::from_rng(rng1).unwrap(); - assert_eq!(rng2.next_u32(), 1325750369); - } - - #[test] - fn test_chacha_true_values_a() { - // Test vectors 1 and 2 from - // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 - let seed = [0u8; 32]; - let mut rng = ChaChaRng::from_seed(seed); - - let mut results = [0u32; 16]; - for i in results.iter_mut() { - *i = rng.next_u32(); - } - let expected = [ - 0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653, 0xb819d2bd, 0x1aed8da0, 0xccef36a8, - 0xc70d778b, 0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8, 0xf4b8436a, 0x1ca11815, - 0x69b687c3, 0x8665eeb2, - ]; - assert_eq!(results, expected); - - for i in results.iter_mut() { - *i = rng.next_u32(); - } - let expected = [ - 0xbee7079f, 0x7a385155, 0x7c97ba98, 0x0d082d73, 0xa0290fcb, 0x6965e348, 0x3e53c612, - 0xed7aee32, 0x7621b729, 0x434ee69c, 0xb03371d5, 0xd539d874, 0x281fed31, 0x45fb0a51, - 0x1f0ae1ac, 0x6f4d794b, - ]; - assert_eq!(results, expected); - } - - #[test] - fn test_chacha_true_values_b() { - // Test vector 3 from - // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 - let seed = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, - ]; - let mut rng = ChaChaRng::from_seed(seed); - - // Skip block 0 - for _ in 0..16 { - rng.next_u32(); - } - - let mut results = [0u32; 16]; - for i in results.iter_mut() { - *i = rng.next_u32(); - } - let expected = [ - 0x2452eb3a, 0x9249f8ec, 0x8d829d9b, 0xddd4ceb1, 0xe8252083, 0x60818b01, 0xf38422b8, - 0x5aaa49c9, 0xbb00ca8e, 0xda3ba7b4, 0xc4b592d1, 0xfdf2732f, 0x4436274e, 0x2561b3c8, - 0xebdd4aa6, 0xa0136c00, - ]; - assert_eq!(results, expected); - } - - #[test] - fn test_chacha_true_values_c() { - // Test vector 4 from - // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 - let seed = [ - 0, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, - ]; - let expected = [ - 0xfb4dd572, 0x4bc42ef1, 0xdf922636, 0x327f1394, 0xa78dea8f, 0x5e269039, 0xa1bebbc1, - 0xcaf09aae, 0xa25ab213, 0x48a6b46c, 0x1b9d9bcb, 0x092c5be6, 0x546ca624, 0x1bec45d5, - 0x87f47473, 0x96f0992e, - ]; - let expected_end = 3 * 16; - let mut results = [0u32; 16]; - - // Test block 2 by skipping block 0 and 1 - let mut rng1 = ChaChaRng::from_seed(seed); - for _ in 0..32 { - rng1.next_u32(); - } - for i in results.iter_mut() { - *i = rng1.next_u32(); - } - assert_eq!(results, expected); - assert_eq!(rng1.get_word_pos(), expected_end); - - // Test block 2 by using `set_word_pos` - let mut rng2 = ChaChaRng::from_seed(seed); - rng2.set_word_pos(2 * 16); - for i in results.iter_mut() { - *i = rng2.next_u32(); - } - assert_eq!(results, expected); - assert_eq!(rng2.get_word_pos(), expected_end); - - // Test skipping behaviour with other types - let mut buf = [0u8; 32]; - rng2.fill_bytes(&mut buf[..]); - assert_eq!(rng2.get_word_pos(), expected_end + 8); - rng2.fill_bytes(&mut buf[0..25]); - assert_eq!(rng2.get_word_pos(), expected_end + 15); - rng2.next_u64(); - assert_eq!(rng2.get_word_pos(), expected_end + 17); - rng2.next_u32(); - rng2.next_u64(); - assert_eq!(rng2.get_word_pos(), expected_end + 20); - rng2.fill_bytes(&mut buf[0..1]); - assert_eq!(rng2.get_word_pos(), expected_end + 21); - } - - #[test] - fn test_chacha_multiple_blocks() { - let seed = [ - 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, - 0, 0, 0, - ]; - let mut rng = ChaChaRng::from_seed(seed); - - // Store the 17*i-th 32-bit word, - // i.e., the i-th word of the i-th 16-word block - let mut results = [0u32; 16]; - for i in results.iter_mut() { - *i = rng.next_u32(); - for _ in 0..16 { - rng.next_u32(); - } - } - let expected = [ - 0xf225c81a, 0x6ab1be57, 0x04d42951, 0x70858036, 0x49884684, 0x64efec72, 0x4be2d186, - 0x3615b384, 0x11cfa18e, 0xd3c50049, 0x75c775f6, 0x434c6530, 0x2c5bad8f, 0x898881dc, - 0x5f1c86d9, 0xc1f8e7f4, - ]; - assert_eq!(results, expected); - } - - #[test] - fn test_chacha_true_bytes() { - let seed = [0u8; 32]; - let mut rng = ChaChaRng::from_seed(seed); - let mut results = [0u8; 32]; - rng.fill_bytes(&mut results); - let expected = [ - 118, 184, 224, 173, 160, 241, 61, 144, 64, 93, 106, 229, 83, 134, 189, 40, 189, 210, - 25, 184, 160, 141, 237, 26, 168, 54, 239, 204, 139, 119, 13, 199, - ]; - assert_eq!(results, expected); - } - - #[test] - fn test_chacha_nonce() { - // Test vector 5 from - // https://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04 - // Although we do not support setting a nonce, we try it here anyway so - // we can use this test vector. - let seed = [0u8; 32]; - let mut rng = ChaChaRng::from_seed(seed); - // 96-bit nonce in LE order is: 0,0,0,0, 0,0,0,0, 0,0,0,2 - rng.set_stream(2u64 << (24 + 32)); - - let mut results = [0u32; 16]; - for i in results.iter_mut() { - *i = rng.next_u32(); - } - let expected = [ - 0x374dc6c2, 0x3736d58c, 0xb904e24a, 0xcd3f93ef, 0x88228b1a, 0x96a4dfb3, 0x5b76ab72, - 0xc727ee54, 0x0e0e978a, 0xf3145c95, 0x1b748ea8, 0xf786c297, 0x99c28f5f, 0x628314e8, - 0x398a19fa, 0x6ded1b53, - ]; - assert_eq!(results, expected); - } - - #[test] - fn test_chacha_clone_streams() { - let seed = [ - 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, - 0, 0, 0, - ]; - let mut rng = ChaChaRng::from_seed(seed); - let mut clone = rng.clone(); - for _ in 0..16 { - assert_eq!(rng.next_u64(), clone.next_u64()); - } - - rng.set_stream(51); - for _ in 0..7 { - assert!(rng.next_u32() != clone.next_u32()); - } - clone.set_stream(51); // switch part way through block - for _ in 7..16 { - assert_eq!(rng.next_u32(), clone.next_u32()); - } - } - - #[test] - fn test_chacha_word_pos_wrap_exact() { - use super::{BUF_BLOCKS, BLOCK_WORDS}; - let mut rng = ChaChaRng::from_seed(Default::default()); - // refilling the buffer in set_word_pos will wrap the block counter to 0 - let last_block = (1 << 68) - u128::from(BUF_BLOCKS * BLOCK_WORDS); - rng.set_word_pos(last_block); - assert_eq!(rng.get_word_pos(), last_block); - } - - #[test] - fn test_chacha_word_pos_wrap_excess() { - use super::BLOCK_WORDS; - let mut rng = ChaChaRng::from_seed(Default::default()); - // refilling the buffer in set_word_pos will wrap the block counter past 0 - let last_block = (1 << 68) - u128::from(BLOCK_WORDS); - rng.set_word_pos(last_block); - assert_eq!(rng.get_word_pos(), last_block); - } - - #[test] - fn test_chacha_word_pos_zero() { - let mut rng = ChaChaRng::from_seed(Default::default()); - assert_eq!(rng.get_word_pos(), 0); - rng.set_word_pos(0); - assert_eq!(rng.get_word_pos(), 0); - } -} diff -Nru cargo-0.58.0/vendor/rand_chacha/src/guts.rs cargo-0.60.0ubuntu1/vendor/rand_chacha/src/guts.rs --- cargo-0.58.0/vendor/rand_chacha/src/guts.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_chacha/src/guts.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,273 +0,0 @@ -// Copyright 2019 The CryptoCorrosion Contributors -// Copyright 2020 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The ChaCha random number generator. - -use ppv_lite86::{dispatch, dispatch_light128}; - -pub use ppv_lite86::Machine; -use ppv_lite86::{vec128_storage, ArithOps, BitOps32, LaneWords4, MultiLane, StoreBytes, Vec4}; - -pub(crate) const BLOCK: usize = 64; -pub(crate) const BLOCK64: u64 = BLOCK as u64; -const LOG2_BUFBLOCKS: u64 = 2; -const BUFBLOCKS: u64 = 1 << LOG2_BUFBLOCKS; -pub(crate) const BUFSZ64: u64 = BLOCK64 * BUFBLOCKS; -pub(crate) const BUFSZ: usize = BUFSZ64 as usize; - -const STREAM_PARAM_NONCE: u32 = 1; -const STREAM_PARAM_BLOCK: u32 = 0; - -#[derive(Clone, PartialEq, Eq)] -pub struct ChaCha { - pub(crate) b: vec128_storage, - pub(crate) c: vec128_storage, - pub(crate) d: vec128_storage, -} - -#[derive(Clone)] -pub struct State { - pub(crate) a: V, - pub(crate) b: V, - pub(crate) c: V, - pub(crate) d: V, -} - -#[inline(always)] -pub(crate) fn round(mut x: State) -> State { - x.a += x.b; - x.d = (x.d ^ x.a).rotate_each_word_right16(); - x.c += x.d; - x.b = (x.b ^ x.c).rotate_each_word_right20(); - x.a += x.b; - x.d = (x.d ^ x.a).rotate_each_word_right24(); - x.c += x.d; - x.b = (x.b ^ x.c).rotate_each_word_right25(); - x -} - -#[inline(always)] -pub(crate) fn diagonalize(mut x: State) -> State { - x.b = x.b.shuffle_lane_words3012(); - x.c = x.c.shuffle_lane_words2301(); - x.d = x.d.shuffle_lane_words1230(); - x -} -#[inline(always)] -pub(crate) fn undiagonalize(mut x: State) -> State { - x.b = x.b.shuffle_lane_words1230(); - x.c = x.c.shuffle_lane_words2301(); - x.d = x.d.shuffle_lane_words3012(); - x -} - -impl ChaCha { - #[inline(always)] - pub fn new(key: &[u8; 32], nonce: &[u8]) -> Self { - init_chacha(key, nonce) - } - - #[inline(always)] - fn pos64(&self, m: M) -> u64 { - let d: M::u32x4 = m.unpack(self.d); - ((d.extract(1) as u64) << 32) | d.extract(0) as u64 - } - - /// Produce 4 blocks of output, advancing the state - #[inline(always)] - pub fn refill4(&mut self, drounds: u32, out: &mut [u8; BUFSZ]) { - refill_wide(self, drounds, out) - } - - #[inline(always)] - pub fn set_block_pos(&mut self, value: u64) { - set_stream_param(self, STREAM_PARAM_BLOCK, value) - } - - #[inline(always)] - pub fn get_block_pos(&self) -> u64 { - get_stream_param(self, STREAM_PARAM_BLOCK) - } - - #[inline(always)] - pub fn set_nonce(&mut self, value: u64) { - set_stream_param(self, STREAM_PARAM_NONCE, value) - } - - #[inline(always)] - pub fn get_nonce(&self) -> u64 { - get_stream_param(self, STREAM_PARAM_NONCE) - } - - #[inline(always)] - pub fn get_seed(&self) -> [u8; 32] { - get_seed(self) - } -} - -#[allow(clippy::many_single_char_names)] -#[inline(always)] -fn refill_wide_impl( - m: Mach, state: &mut ChaCha, drounds: u32, out: &mut [u8; BUFSZ], -) { - let k = m.vec([0x6170_7865, 0x3320_646e, 0x7962_2d32, 0x6b20_6574]); - let mut pos = state.pos64(m); - let d0: Mach::u32x4 = m.unpack(state.d); - pos = pos.wrapping_add(1); - let d1 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - pos = pos.wrapping_add(1); - let d2 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - pos = pos.wrapping_add(1); - let d3 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - - let b = m.unpack(state.b); - let c = m.unpack(state.c); - let mut x = State { - a: Mach::u32x4x4::from_lanes([k, k, k, k]), - b: Mach::u32x4x4::from_lanes([b, b, b, b]), - c: Mach::u32x4x4::from_lanes([c, c, c, c]), - d: m.unpack(Mach::u32x4x4::from_lanes([d0, d1, d2, d3]).into()), - }; - for _ in 0..drounds { - x = round(x); - x = undiagonalize(round(diagonalize(x))); - } - let mut pos = state.pos64(m); - let d0: Mach::u32x4 = m.unpack(state.d); - pos = pos.wrapping_add(1); - let d1 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - pos = pos.wrapping_add(1); - let d2 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - pos = pos.wrapping_add(1); - let d3 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - pos = pos.wrapping_add(1); - let d4 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - - let (a, b, c, d) = ( - x.a.to_lanes(), - x.b.to_lanes(), - x.c.to_lanes(), - x.d.to_lanes(), - ); - let sb = m.unpack(state.b); - let sc = m.unpack(state.c); - let sd = [m.unpack(state.d), d1, d2, d3]; - state.d = d4.into(); - let mut words = out.chunks_exact_mut(16); - for ((((&a, &b), &c), &d), &sd) in a.iter().zip(&b).zip(&c).zip(&d).zip(&sd) { - (a + k).write_le(words.next().unwrap()); - (b + sb).write_le(words.next().unwrap()); - (c + sc).write_le(words.next().unwrap()); - (d + sd).write_le(words.next().unwrap()); - } -} - -dispatch!(m, Mach, { - fn refill_wide(state: &mut ChaCha, drounds: u32, out: &mut [u8; BUFSZ]) { - refill_wide_impl(m, state, drounds, out); - } -}); - -// Single-block, rounds-only; shared by try_apply_keystream for tails shorter than BUFSZ -// and XChaCha's setup step. -dispatch!(m, Mach, { - fn refill_narrow_rounds(state: &mut ChaCha, drounds: u32) -> State { - let k: Mach::u32x4 = m.vec([0x6170_7865, 0x3320_646e, 0x7962_2d32, 0x6b20_6574]); - let mut x = State { - a: k, - b: m.unpack(state.b), - c: m.unpack(state.c), - d: m.unpack(state.d), - }; - for _ in 0..drounds { - x = round(x); - x = undiagonalize(round(diagonalize(x))); - } - State { - a: x.a.into(), - b: x.b.into(), - c: x.c.into(), - d: x.d.into(), - } - } -}); - -dispatch_light128!(m, Mach, { - fn set_stream_param(state: &mut ChaCha, param: u32, value: u64) { - let d: Mach::u32x4 = m.unpack(state.d); - state.d = d - .insert((value >> 32) as u32, (param << 1) | 1) - .insert(value as u32, param << 1) - .into(); - } -}); - -dispatch_light128!(m, Mach, { - fn get_stream_param(state: &ChaCha, param: u32) -> u64 { - let d: Mach::u32x4 = m.unpack(state.d); - ((d.extract((param << 1) | 1) as u64) << 32) | d.extract(param << 1) as u64 - } -}); - -dispatch_light128!(m, Mach, { - fn get_seed(state: &ChaCha) -> [u8; 32] { - let b: Mach::u32x4 = m.unpack(state.b); - let c: Mach::u32x4 = m.unpack(state.c); - let mut key = [0u8; 32]; - b.write_le(&mut key[..16]); - c.write_le(&mut key[16..]); - key - } -}); - -fn read_u32le(xs: &[u8]) -> u32 { - assert_eq!(xs.len(), 4); - u32::from(xs[0]) | (u32::from(xs[1]) << 8) | (u32::from(xs[2]) << 16) | (u32::from(xs[3]) << 24) -} - -dispatch_light128!(m, Mach, { - fn init_chacha(key: &[u8; 32], nonce: &[u8]) -> ChaCha { - let ctr_nonce = [ - 0, - if nonce.len() == 12 { - read_u32le(&nonce[0..4]) - } else { - 0 - }, - read_u32le(&nonce[nonce.len() - 8..nonce.len() - 4]), - read_u32le(&nonce[nonce.len() - 4..]), - ]; - let key0: Mach::u32x4 = m.read_le(&key[..16]); - let key1: Mach::u32x4 = m.read_le(&key[16..]); - ChaCha { - b: key0.into(), - c: key1.into(), - d: ctr_nonce.into(), - } - } -}); - -dispatch_light128!(m, Mach, { - fn init_chacha_x(key: &[u8; 32], nonce: &[u8; 24], rounds: u32) -> ChaCha { - let key0: Mach::u32x4 = m.read_le(&key[..16]); - let key1: Mach::u32x4 = m.read_le(&key[16..]); - let nonce0: Mach::u32x4 = m.read_le(&nonce[..16]); - let mut state = ChaCha { - b: key0.into(), - c: key1.into(), - d: nonce0.into(), - }; - let x = refill_narrow_rounds(&mut state, rounds); - let ctr_nonce1 = [0, 0, read_u32le(&nonce[16..20]), read_u32le(&nonce[20..24])]; - state.b = x.a; - state.c = x.d; - state.d = ctr_nonce1.into(); - state - } -}); diff -Nru cargo-0.58.0/vendor/rand_chacha/src/lib.rs cargo-0.60.0ubuntu1/vendor/rand_chacha/src/lib.rs --- cargo-0.58.0/vendor/rand_chacha/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_chacha/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The ChaCha random number generator. - -#![doc( - html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://rust-random.github.io/rand/" -)] -#![deny(missing_docs)] -#![deny(missing_debug_implementations)] -#![doc(test(attr(allow(unused_variables), deny(warnings))))] -#![cfg_attr(not(feature = "std"), no_std)] - -pub use rand_core; - -mod chacha; -mod guts; - -pub use crate::chacha::{ - ChaCha12Core, ChaCha12Rng, ChaCha20Core, ChaCha20Rng, ChaCha8Core, ChaCha8Rng, -}; - -/// ChaCha with 20 rounds -pub type ChaChaRng = ChaCha20Rng; -/// ChaCha with 20 rounds, low-level interface -pub type ChaChaCore = ChaCha20Core; diff -Nru cargo-0.58.0/vendor/rand_core/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/rand_core/.cargo-checksum.json --- cargo-0.58.0/vendor/rand_core/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"} \ No newline at end of file +{"files":{},"package":"90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/rand_core/Cargo.toml cargo-0.60.0ubuntu1/vendor/rand_core/Cargo.toml --- cargo-0.58.0/vendor/rand_core/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -13,24 +13,18 @@ [package] edition = "2018" name = "rand_core" -version = "0.6.3" +version = "0.5.1" authors = ["The Rand Project Developers", "The Rust Project Developers"] description = "Core random number generator traits and tools for implementation.\n" -homepage = "https://rust-random.github.io/book" -documentation = "https://docs.rs/rand_core" +homepage = "https://crates.io/crates/rand_core" +documentation = "https://rust-random.github.io/rand/rand_core/" readme = "README.md" keywords = ["random", "rng"] categories = ["algorithms", "no-std"] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-random/rand" -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "doc_cfg"] - -[package.metadata.playground] -all-features = true [dependencies.getrandom] -version = "0.2" +version = "0.1" optional = true [dependencies.serde] @@ -42,3 +36,8 @@ alloc = [] serde1 = ["serde"] std = ["alloc", "getrandom", "getrandom/std"] +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff -Nru cargo-0.58.0/vendor/rand_core/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/rand_core/CHANGELOG.md --- cargo-0.58.0/vendor/rand_core/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core/CHANGELOG.md 2022-04-20 13:48:09.000000000 +0000 @@ -4,37 +4,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.6.3] - 2021-06-15 -### Changed -- Improved bound for `serde` impls on `BlockRng` (#1130) -- Minor doc additions (#1118) - -## [0.6.2] - 2021-02-12 -### Fixed -- Fixed assertions in `le::read_u32_into` and `le::read_u64_into` which could - have allowed buffers not to be fully populated (#1096) - -## [0.6.1] - 2021-01-03 -### Fixed -- Avoid panic when using `RngCore::seed_from_u64` with a seed which is not a - multiple of four (#1082) -### Other -- Enable all stable features in the playground (#1081) - -## [0.6.0] - 2020-12-08 -### Breaking changes -- Bump MSRV to 1.36, various code improvements (#1011) -- Update to getrandom v0.2 (#1041) -- Fix: `next_u32_via_fill` and `next_u64_via_fill` now use LE as documented (#1061) - -### Other -- Reduce usage of `unsafe` (#962, #963, #1011) -- Annotate feature-gates in documentation (#1019) -- Document available error codes (#1061) -- Various documentation tweaks -- Fix some clippy warnings (#1036) -- Apply rustfmt (#926) - ## [0.5.1] - 2019-08-28 - `OsRng` added to `rand_core` (#863) - `Error::INTERNAL_START` and `Error::CUSTOM_START` constants (#864) diff -Nru cargo-0.58.0/vendor/rand_core/README.md cargo-0.60.0ubuntu1/vendor/rand_core/README.md --- cargo-0.58.0/vendor/rand_core/README.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -1,11 +1,12 @@ # rand_core -[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rand/actions) +[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) [![Latest version](https://img.shields.io/crates/v/rand_core.svg)](https://crates.io/crates/rand_core) [![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) [![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_core) [![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core) -[![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) Core traits and error types of the [rand] library, plus tools for implementing RNGs. @@ -43,7 +44,7 @@ The current version is: ``` -rand_core = "0.6.0" +rand_core = "0.5.0" ``` Rand libs have inter-dependencies and make use of the diff -Nru cargo-0.58.0/vendor/rand_core/src/block.rs cargo-0.60.0ubuntu1/vendor/rand_core/src/block.rs --- cargo-0.58.0/vendor/rand_core/src/block.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core/src/block.rs 2022-04-20 13:48:09.000000000 +0000 @@ -21,14 +21,12 @@ //! //! # Example //! -//! ```no_run -//! use rand_core::{RngCore, SeedableRng}; +//! ```norun //! use rand_core::block::{BlockRngCore, BlockRng}; //! //! struct MyRngCore; //! //! impl BlockRngCore for MyRngCore { -//! type Item = u32; //! type Results = [u32; 16]; //! //! fn generate(&mut self, results: &mut Self::Results) { @@ -37,7 +35,7 @@ //! } //! //! impl SeedableRng for MyRngCore { -//! type Seed = [u8; 32]; +//! type Seed = unimplemented!(); //! fn from_seed(seed: Self::Seed) -> Self { //! unimplemented!() //! } @@ -46,19 +44,17 @@ //! // optionally, also implement CryptoRng for MyRngCore //! //! // Final RNG. -//! let mut rng = BlockRng::::seed_from_u64(0); -//! println!("First value: {}", rng.next_u32()); +//! type MyRng = BlockRng; //! ``` //! //! [`BlockRngCore`]: crate::block::BlockRngCore //! [`fill_bytes`]: RngCore::fill_bytes -use crate::impls::{fill_via_u32_chunks, fill_via_u64_chunks}; -use crate::{CryptoRng, Error, RngCore, SeedableRng}; use core::convert::AsRef; -use core::fmt; -#[cfg(feature = "serde1")] -use serde::{Deserialize, Serialize}; +use core::{fmt, ptr}; +#[cfg(feature="serde1")] use serde::{Serialize, Deserialize}; +use crate::{RngCore, CryptoRng, SeedableRng, Error}; +use crate::impls::{fill_via_u32_chunks, fill_via_u64_chunks}; /// A trait for RNGs which do not generate random numbers individually, but in /// blocks (typically `[u32; N]`). This technique is commonly used by @@ -77,6 +73,7 @@ fn generate(&mut self, results: &mut Self::Results); } + /// A wrapper type implementing [`RngCore`] for some type implementing /// [`BlockRngCore`] with `u32` array buffer; i.e. this can be used to implement /// a full RNG from just a `generate` function. @@ -113,13 +110,7 @@ /// [`fill_bytes`]: RngCore::fill_bytes /// [`try_fill_bytes`]: RngCore::try_fill_bytes #[derive(Clone)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] -#[cfg_attr( - feature = "serde1", - serde( - bound = "for<'x> R: Serialize + Deserialize<'x> + Sized, for<'x> R::Results: Serialize + Deserialize<'x>" - ) -)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] pub struct BlockRng { results: R::Results, index: usize, @@ -131,10 +122,10 @@ impl fmt::Debug for BlockRng { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.debug_struct("BlockRng") - .field("core", &self.core) - .field("result_len", &self.results.as_ref().len()) - .field("index", &self.index) - .finish() + .field("core", &self.core) + .field("result_len", &self.results.as_ref().len()) + .field("index", &self.index) + .finish() } } @@ -142,7 +133,7 @@ /// Create a new `BlockRng` from an existing RNG implementing /// `BlockRngCore`. Results will be generated on first use. #[inline] - pub fn new(core: R) -> BlockRng { + pub fn new(core: R) -> BlockRng{ let results_empty = R::Results::default(); BlockRng { core, @@ -178,9 +169,8 @@ } } -impl> RngCore for BlockRng -where - ::Results: AsRef<[u32]> + AsMut<[u32]>, +impl> RngCore for BlockRng +where ::Results: AsRef<[u32]> + AsMut<[u32]> { #[inline] fn next_u32(&mut self) -> u32 { @@ -196,14 +186,22 @@ #[inline] fn next_u64(&mut self) -> u64 { let read_u64 = |results: &[u32], index| { - let data = &results[index..=index + 1]; - u64::from(data[1]) << 32 | u64::from(data[0]) + if cfg!(any(target_endian = "little")) { + // requires little-endian CPU + #[allow(clippy::cast_ptr_alignment)] // false positive + let ptr: *const u64 = results[index..=index+1].as_ptr() as *const u64; + unsafe { ptr::read_unaligned(ptr) } + } else { + let x = u64::from(results[index]); + let y = u64::from(results[index + 1]); + (y << 32) | x + } }; let len = self.results.as_ref().len(); let index = self.index; - if index < len - 1 { + if index < len-1 { self.index += 2; // Read an u64 from the current index read_u64(self.results.as_ref(), index) @@ -211,7 +209,7 @@ self.generate_and_set(2); read_u64(self.results.as_ref(), 0) } else { - let x = u64::from(self.results.as_ref()[len - 1]); + let x = u64::from(self.results.as_ref()[len-1]); self.generate_and_set(1); let y = u64::from(self.results.as_ref()[0]); (y << 32) | x @@ -226,7 +224,8 @@ self.generate_and_set(0); } let (consumed_u32, filled_u8) = - fill_via_u32_chunks(&self.results.as_ref()[self.index..], &mut dest[read_len..]); + fill_via_u32_chunks(&self.results.as_ref()[self.index..], + &mut dest[read_len..]); self.index += consumed_u32; read_len += filled_u8; @@ -259,6 +258,8 @@ } } + + /// A wrapper type implementing [`RngCore`] for some type implementing /// [`BlockRngCore`] with `u64` array buffer; i.e. this can be used to implement /// a full RNG from just a `generate` function. @@ -282,7 +283,7 @@ /// [`fill_bytes`]: RngCore::fill_bytes /// [`try_fill_bytes`]: RngCore::try_fill_bytes #[derive(Clone)] -#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] pub struct BlockRng64 { results: R::Results, index: usize, @@ -295,11 +296,11 @@ impl fmt::Debug for BlockRng64 { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.debug_struct("BlockRng64") - .field("core", &self.core) - .field("result_len", &self.results.as_ref().len()) - .field("index", &self.index) - .field("half_used", &self.half_used) - .finish() + .field("core", &self.core) + .field("result_len", &self.results.as_ref().len()) + .field("index", &self.index) + .field("half_used", &self.half_used) + .finish() } } @@ -307,7 +308,7 @@ /// Create a new `BlockRng` from an existing RNG implementing /// `BlockRngCore`. Results will be generated on first use. #[inline] - pub fn new(core: R) -> BlockRng64 { + pub fn new(core: R) -> BlockRng64{ let results_empty = R::Results::default(); BlockRng64 { core, @@ -346,9 +347,8 @@ } } -impl> RngCore for BlockRng64 -where - ::Results: AsRef<[u64]> + AsMut<[u64]>, +impl> RngCore for BlockRng64 +where ::Results: AsRef<[u64]> + AsMut<[u64]> { #[inline] fn next_u32(&mut self) -> u32 { @@ -366,7 +366,8 @@ // Index as if this is a u32 slice. unsafe { - let results = &*(self.results.as_ref() as *const [u64] as *const [u32]); + let results = + &*(self.results.as_ref() as *const [u64] as *const [u32]); if cfg!(target_endian = "little") { *results.get_unchecked(index) } else { @@ -398,10 +399,9 @@ self.index = 0; } - let (consumed_u64, filled_u8) = fill_via_u64_chunks( - &self.results.as_ref()[self.index as usize..], - &mut dest[read_len..], - ); + let (consumed_u64, filled_u8) = + fill_via_u64_chunks(&self.results.as_ref()[self.index as usize..], + &mut dest[read_len..]); self.index += consumed_u64; read_len += filled_u8; diff -Nru cargo-0.58.0/vendor/rand_core/src/error.rs cargo-0.60.0ubuntu1/vendor/rand_core/src/error.rs --- cargo-0.58.0/vendor/rand_core/src/error.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core/src/error.rs 2022-04-20 13:48:09.000000000 +0000 @@ -11,7 +11,6 @@ use core::fmt; use core::num::NonZeroU32; -#[cfg(feature = "std")] use std::boxed::Box; /// Error type of random number generators /// @@ -19,64 +18,54 @@ /// possible implementations: with `std` a boxed `Error` trait object is stored, /// while with `no_std` we merely store an error code. pub struct Error { - #[cfg(feature = "std")] + #[cfg(feature="std")] inner: Box, - #[cfg(not(feature = "std"))] + #[cfg(not(feature="std"))] code: NonZeroU32, } impl Error { - /// Codes at or above this point can be used by users to define their own - /// custom errors. - /// - /// This has a fixed value of `(1 << 31) + (1 << 30) = 0xC000_0000`, - /// therefore the number of values available for custom codes is `1 << 30`. - /// - /// This is identical to [`getrandom::Error::CUSTOM_START`](https://docs.rs/getrandom/latest/getrandom/struct.Error.html#associatedconstant.CUSTOM_START). - pub const CUSTOM_START: u32 = (1 << 31) + (1 << 30); - /// Codes below this point represent OS Errors (i.e. positive i32 values). - /// Codes at or above this point, but below [`Error::CUSTOM_START`] are - /// reserved for use by the `rand` and `getrandom` crates. - /// - /// This is identical to [`getrandom::Error::INTERNAL_START`](https://docs.rs/getrandom/latest/getrandom/struct.Error.html#associatedconstant.INTERNAL_START). - pub const INTERNAL_START: u32 = 1 << 31; - /// Construct from any type supporting `std::error::Error` - /// + /// /// Available only when configured with `std`. - /// + /// /// See also `From`, which is available with and without `std`. - #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] + #[cfg(feature="std")] #[inline] pub fn new(err: E) -> Self - where - E: Into>, + where E: Into> { Error { inner: err.into() } } - + /// Reference the inner error (`std` only) - /// + /// /// When configured with `std`, this is a trivial operation and never /// panics. Without `std`, this method is simply unavailable. - #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] + #[cfg(feature="std")] #[inline] pub fn inner(&self) -> &(dyn std::error::Error + Send + Sync + 'static) { &*self.inner } - + /// Unwrap the inner error (`std` only) - /// + /// /// When configured with `std`, this is a trivial operation and never /// panics. Without `std`, this method is simply unavailable. - #[cfg(feature = "std")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] + #[cfg(feature="std")] #[inline] pub fn take_inner(self) -> Box { self.inner } + + /// Codes below this point represent OS Errors (i.e. positive i32 values). + /// Codes at or above this point, but below [`Error::CUSTOM_START`] are + /// reserved for use by the `rand` and `getrandom` crates. + pub const INTERNAL_START: u32 = 1 << 31; + + /// Codes at or above this point can be used by users to define their own + /// custom errors. + pub const CUSTOM_START: u32 = (1 << 31) + (1 << 30); /// Extract the raw OS error code (if this error came from the OS) /// @@ -85,31 +74,29 @@ /// error value can still be formatted via the `Diplay` implementation. #[inline] pub fn raw_os_error(&self) -> Option { - #[cfg(feature = "std")] - { + #[cfg(feature="std")] { if let Some(e) = self.inner.downcast_ref::() { return e.raw_os_error(); } } match self.code() { - Some(code) if u32::from(code) < Self::INTERNAL_START => Some(u32::from(code) as i32), + Some(code) if u32::from(code) < Self::INTERNAL_START => + Some(u32::from(code) as i32), _ => None, } } /// Retrieve the error code, if any. - /// + /// /// If this `Error` was constructed via `From`, then this method /// will return this `NonZeroU32` code (for `no_std` this is always the /// case). Otherwise, this method will return `None`. #[inline] pub fn code(&self) -> Option { - #[cfg(feature = "std")] - { + #[cfg(feature="std")] { self.inner.downcast_ref::().map(|c| c.0) } - #[cfg(not(feature = "std"))] - { + #[cfg(not(feature="std"))] { Some(self.code) } } @@ -117,16 +104,13 @@ impl fmt::Debug for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - #[cfg(feature = "std")] - { + #[cfg(feature="std")] { write!(f, "Error {{ inner: {:?} }}", self.inner) } - #[cfg(all(feature = "getrandom", not(feature = "std")))] - { + #[cfg(all(feature="getrandom", not(feature="std")))] { getrandom::Error::from(self.code).fmt(f) } - #[cfg(not(feature = "getrandom"))] - { + #[cfg(not(feature="getrandom"))] { write!(f, "Error {{ code: {} }}", self.code) } } @@ -134,16 +118,13 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - #[cfg(feature = "std")] - { + #[cfg(feature="std")] { write!(f, "{}", self.inner) } - #[cfg(all(feature = "getrandom", not(feature = "std")))] - { + #[cfg(all(feature="getrandom", not(feature="std")))] { getrandom::Error::from(self.code).fmt(f) } - #[cfg(not(feature = "getrandom"))] - { + #[cfg(not(feature="getrandom"))] { write!(f, "error code {}", self.code) } } @@ -152,37 +133,29 @@ impl From for Error { #[inline] fn from(code: NonZeroU32) -> Self { - #[cfg(feature = "std")] - { - Error { - inner: Box::new(ErrorCode(code)), - } + #[cfg(feature="std")] { + Error { inner: Box::new(ErrorCode(code)) } } - #[cfg(not(feature = "std"))] - { + #[cfg(not(feature="std"))] { Error { code } } } } -#[cfg(feature = "getrandom")] +#[cfg(feature="getrandom")] impl From for Error { #[inline] fn from(error: getrandom::Error) -> Self { - #[cfg(feature = "std")] - { - Error { - inner: Box::new(error), - } + #[cfg(feature="std")] { + Error { inner: Box::new(error) } } - #[cfg(not(feature = "std"))] - { + #[cfg(not(feature="std"))] { Error { code: error.code() } } } } -#[cfg(feature = "std")] +#[cfg(feature="std")] impl std::error::Error for Error { #[inline] fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { @@ -190,7 +163,7 @@ } } -#[cfg(feature = "std")] +#[cfg(feature="std")] impl From for std::io::Error { #[inline] fn from(error: Error) -> Self { @@ -202,27 +175,16 @@ } } -#[cfg(feature = "std")] +#[cfg(feature="std")] #[derive(Debug, Copy, Clone)] struct ErrorCode(NonZeroU32); -#[cfg(feature = "std")] +#[cfg(feature="std")] impl fmt::Display for ErrorCode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "error code {}", self.0) } } -#[cfg(feature = "std")] +#[cfg(feature="std")] impl std::error::Error for ErrorCode {} - -#[cfg(test)] -mod test { - #[cfg(feature = "getrandom")] - #[test] - fn test_error_codes() { - // Make sure the values are the same as in `getrandom`. - assert_eq!(super::Error::CUSTOM_START, getrandom::Error::CUSTOM_START); - assert_eq!(super::Error::INTERNAL_START, getrandom::Error::INTERNAL_START); - } -} diff -Nru cargo-0.58.0/vendor/rand_core/src/impls.rs cargo-0.60.0ubuntu1/vendor/rand_core/src/impls.rs --- cargo-0.58.0/vendor/rand_core/src/impls.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core/src/impls.rs 2022-04-20 13:48:09.000000000 +0000 @@ -17,8 +17,12 @@ //! to/from byte sequences, and since its purpose is reproducibility, //! non-reproducible sources (e.g. `OsRng`) need not bother with it. -use crate::RngCore; +use core::ptr::copy_nonoverlapping; +use core::slice; use core::cmp::min; +use core::mem::size_of; +use crate::RngCore; + /// Implement `next_u64` via `next_u32`, little-endian order. pub fn next_u64_via_u32(rng: &mut R) -> u64 { @@ -37,7 +41,7 @@ pub fn fill_bytes_via_next(rng: &mut R, dest: &mut [u8]) { let mut left = dest; while left.len() >= 8 { - let (l, r) = { left }.split_at_mut(8); + let (l, r) = {left}.split_at_mut(8); left = r; let chunk: [u8; 8] = rng.next_u64().to_le_bytes(); l.copy_from_slice(&chunk); @@ -52,36 +56,45 @@ } } +macro_rules! impl_uint_from_fill { + ($rng:expr, $ty:ty, $N:expr) => ({ + debug_assert!($N == size_of::<$ty>()); + + let mut int: $ty = 0; + unsafe { + let ptr = &mut int as *mut $ty as *mut u8; + let slice = slice::from_raw_parts_mut(ptr, $N); + $rng.fill_bytes(slice); + } + int + }); +} + macro_rules! fill_via_chunks { - ($src:expr, $dst:expr, $ty:ty) => {{ - const SIZE: usize = core::mem::size_of::<$ty>(); - let chunk_size_u8 = min($src.len() * SIZE, $dst.len()); - let chunk_size = (chunk_size_u8 + SIZE - 1) / SIZE; - - // The following can be replaced with safe code, but unfortunately it's - // ca. 8% slower. - if cfg!(target_endian = "little") { + ($src:expr, $dst:expr, $ty:ty, $size:expr) => ({ + let chunk_size_u8 = min($src.len() * $size, $dst.len()); + let chunk_size = (chunk_size_u8 + $size - 1) / $size; + if cfg!(target_endian="little") { unsafe { - core::ptr::copy_nonoverlapping( + copy_nonoverlapping( $src.as_ptr() as *const u8, $dst.as_mut_ptr(), chunk_size_u8); } } else { - for (&n, chunk) in $src.iter().zip($dst.chunks_mut(SIZE)) { + for (&n, chunk) in $src.iter().zip($dst.chunks_mut($size)) { let tmp = n.to_le(); let src_ptr = &tmp as *const $ty as *const u8; unsafe { - core::ptr::copy_nonoverlapping( - src_ptr, - chunk.as_mut_ptr(), - chunk.len()); + copy_nonoverlapping(src_ptr, + chunk.as_mut_ptr(), + chunk.len()); } } } (chunk_size, chunk_size_u8) - }}; + }); } /// Implement `fill_bytes` by reading chunks from the output buffer of a block @@ -115,7 +128,7 @@ /// } /// ``` pub fn fill_via_u32_chunks(src: &[u32], dest: &mut [u8]) -> (usize, usize) { - fill_via_chunks!(src, dest, u32) + fill_via_chunks!(src, dest, u32, 4) } /// Implement `fill_bytes` by reading chunks from the output buffer of a block @@ -129,56 +142,17 @@ /// /// See `fill_via_u32_chunks` for an example. pub fn fill_via_u64_chunks(src: &[u64], dest: &mut [u8]) -> (usize, usize) { - fill_via_chunks!(src, dest, u64) + fill_via_chunks!(src, dest, u64, 8) } /// Implement `next_u32` via `fill_bytes`, little-endian order. pub fn next_u32_via_fill(rng: &mut R) -> u32 { - let mut buf = [0; 4]; - rng.fill_bytes(&mut buf); - u32::from_le_bytes(buf) + impl_uint_from_fill!(rng, u32, 4) } /// Implement `next_u64` via `fill_bytes`, little-endian order. pub fn next_u64_via_fill(rng: &mut R) -> u64 { - let mut buf = [0; 8]; - rng.fill_bytes(&mut buf); - u64::from_le_bytes(buf) -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_fill_via_u32_chunks() { - let src = [1, 2, 3]; - let mut dst = [0u8; 11]; - assert_eq!(fill_via_u32_chunks(&src, &mut dst), (3, 11)); - assert_eq!(dst, [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0]); - - let mut dst = [0u8; 13]; - assert_eq!(fill_via_u32_chunks(&src, &mut dst), (3, 12)); - assert_eq!(dst, [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0]); - - let mut dst = [0u8; 5]; - assert_eq!(fill_via_u32_chunks(&src, &mut dst), (2, 5)); - assert_eq!(dst, [1, 0, 0, 0, 2]); - } - - #[test] - fn test_fill_via_u64_chunks() { - let src = [1, 2]; - let mut dst = [0u8; 11]; - assert_eq!(fill_via_u64_chunks(&src, &mut dst), (2, 11)); - assert_eq!(dst, [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0]); - - let mut dst = [0u8; 17]; - assert_eq!(fill_via_u64_chunks(&src, &mut dst), (2, 16)); - assert_eq!(dst, [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]); - - let mut dst = [0u8; 5]; - assert_eq!(fill_via_u64_chunks(&src, &mut dst), (1, 5)); - assert_eq!(dst, [1, 0, 0, 0, 0]); - } + impl_uint_from_fill!(rng, u64, 8) } + +// TODO: implement tests for the above diff -Nru cargo-0.58.0/vendor/rand_core/src/le.rs cargo-0.60.0ubuntu1/vendor/rand_core/src/le.rs --- cargo-0.58.0/vendor/rand_core/src/le.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core/src/le.rs 2022-04-20 13:48:09.000000000 +0000 @@ -7,49 +7,61 @@ // except according to those terms. //! Little-Endian utilities -//! +//! //! Little-Endian order has been chosen for internal usage; this makes some //! useful functions available. -use core::convert::TryInto; +use core::ptr; + +macro_rules! read_slice { + ($src:expr, $dst:expr, $size:expr, $which:ident) => {{ + assert_eq!($src.len(), $size * $dst.len()); + + unsafe { + ptr::copy_nonoverlapping( + $src.as_ptr(), + $dst.as_mut_ptr() as *mut u8, + $src.len()); + } + for v in $dst.iter_mut() { + *v = v.$which(); + } + }}; +} /// Reads unsigned 32 bit integers from `src` into `dst`. +/// Borrowed from the `byteorder` crate. #[inline] pub fn read_u32_into(src: &[u8], dst: &mut [u32]) { - assert!(src.len() >= 4 * dst.len()); - for (out, chunk) in dst.iter_mut().zip(src.chunks_exact(4)) { - *out = u32::from_le_bytes(chunk.try_into().unwrap()); - } + read_slice!(src, dst, 4, to_le); } /// Reads unsigned 64 bit integers from `src` into `dst`. +/// Borrowed from the `byteorder` crate. #[inline] pub fn read_u64_into(src: &[u8], dst: &mut [u64]) { - assert!(src.len() >= 8 * dst.len()); - for (out, chunk) in dst.iter_mut().zip(src.chunks_exact(8)) { - *out = u64::from_le_bytes(chunk.try_into().unwrap()); - } + read_slice!(src, dst, 8, to_le); } #[test] fn test_read() { let bytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - + let mut buf = [0u32; 4]; read_u32_into(&bytes, &mut buf); assert_eq!(buf[0], 0x04030201); assert_eq!(buf[3], 0x100F0E0D); - + let mut buf = [0u32; 3]; - read_u32_into(&bytes[1..13], &mut buf); // unaligned + read_u32_into(&bytes[1..13], &mut buf); // unaligned assert_eq!(buf[0], 0x05040302); assert_eq!(buf[2], 0x0D0C0B0A); - + let mut buf = [0u64; 2]; read_u64_into(&bytes, &mut buf); assert_eq!(buf[0], 0x0807060504030201); assert_eq!(buf[1], 0x100F0E0D0C0B0A09); - + let mut buf = [0u64; 1]; read_u64_into(&bytes[7..15], &mut buf); // unaligned assert_eq!(buf[0], 0x0F0E0D0C0B0A0908); diff -Nru cargo-0.58.0/vendor/rand_core/src/lib.rs cargo-0.60.0ubuntu1/vendor/rand_core/src/lib.rs --- cargo-0.58.0/vendor/rand_core/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -27,33 +27,35 @@ //! //! [`rand`]: https://docs.rs/rand -#![doc( - html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://rust-random.github.io/rand/" -)] +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] + #![deny(missing_docs)] #![deny(missing_debug_implementations)] #![doc(test(attr(allow(unused_variables), deny(warnings))))] -#![cfg_attr(doc_cfg, feature(doc_cfg))] -#![no_std] -use core::convert::AsMut; +#![allow(clippy::unreadable_literal)] + +#![cfg_attr(not(feature="std"), no_std)] + + use core::default::Default; +use core::convert::AsMut; +use core::ptr::copy_nonoverlapping; -#[cfg(feature = "std")] extern crate std; -#[cfg(feature = "alloc")] extern crate alloc; -#[cfg(feature = "alloc")] use alloc::boxed::Box; +#[cfg(all(feature="alloc", not(feature="std")))] extern crate alloc; +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::boxed::Box; pub use error::Error; -#[cfg(feature = "getrandom")] pub use os::OsRng; +#[cfg(feature="getrandom")] pub use os::OsRng; -pub mod block; mod error; +pub mod block; pub mod impls; pub mod le; -#[cfg(feature = "getrandom")] mod os; +#[cfg(feature="getrandom")] mod os; /// The core of a random number generator. @@ -67,26 +69,19 @@ /// optimal implementation of each is dependent on the type of generator. There /// is no required relationship between the output of each; e.g. many /// implementations of [`fill_bytes`] consume a whole number of `u32` or `u64` -/// values and drop any remaining unused bytes. The same can happen with the -/// [`next_u32`] and [`next_u64`] methods, implementations may discard some -/// random bits for efficiency. +/// values and drop any remaining unused bytes. /// /// The [`try_fill_bytes`] method is a variant of [`fill_bytes`] allowing error /// handling; it is not deemed sufficiently useful to add equivalents for /// [`next_u32`] or [`next_u64`] since the latter methods are almost always used /// with algorithmic generators (PRNGs), which are normally infallible. /// -/// Implementers should produce bits uniformly. Pathological RNGs (e.g. always -/// returning the same value, or never setting certain bits) can break rejection -/// sampling used by random distributions, and also break other RNGs when -/// seeding them via [`SeedableRng::from_rng`]. -/// /// Algorithmic generators implementing [`SeedableRng`] should normally have /// *portable, reproducible* output, i.e. fix Endianness when converting values /// to avoid platform differences, and avoid making any changes which affect /// output (except by communicating that the release has breaking changes). /// -/// Typically an RNG will implement only one of the methods available +/// Typically implementators will implement only one of the methods available /// in this trait directly, then use the helper functions from the /// [`impls`] module to implement the other methods. /// @@ -144,22 +139,24 @@ /// /// RNGs must implement at least one method from this trait directly. In /// the case this method is not implemented directly, it can be implemented - /// using `self.next_u64() as u32` or via [`impls::next_u32_via_fill`]. + /// using `self.next_u64() as u32` or via + /// [`fill_bytes`](impls::next_u32_via_fill). fn next_u32(&mut self) -> u32; /// Return the next random `u64`. /// /// RNGs must implement at least one method from this trait directly. In /// the case this method is not implemented directly, it can be implemented - /// via [`impls::next_u64_via_u32`] or via [`impls::next_u64_via_fill`]. + /// via [`next_u32`](impls::next_u64_via_u32) or via + /// [`fill_bytes`](impls::next_u64_via_fill). fn next_u64(&mut self) -> u64; /// Fill `dest` with random data. /// /// RNGs must implement at least one method from this trait directly. In /// the case this method is not implemented directly, it can be implemented - /// via [`impls::fill_bytes_via_next`] or - /// via [`RngCore::try_fill_bytes`]; if this generator can + /// via [`next_u*`](impls::fill_bytes_via_next) or + /// via [`try_fill_bytes`](RngCore::try_fill_bytes); if this generator can /// fail the implementation must choose how best to handle errors here /// (e.g. panic with a descriptive message or log a warning and retry a few /// times). @@ -177,10 +174,12 @@ /// by external (true) RNGs (e.g. `OsRng`) which can fail. It may be used /// directly to generate keys and to seed (infallible) PRNGs. /// - /// Other than error handling, this method is identical to [`RngCore::fill_bytes`]; + /// Other than error handling, this method is identical to [`fill_bytes`]; /// thus this may be implemented using `Ok(self.fill_bytes(dest))` or /// `fill_bytes` may be implemented with /// `self.try_fill_bytes(dest).unwrap()` or more specific error handling. + /// + /// [`fill_bytes`]: RngCore::fill_bytes fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>; } @@ -305,30 +304,24 @@ /// considered a value-breaking change. fn seed_from_u64(mut state: u64) -> Self { // We use PCG32 to generate a u32 sequence, and copy to the seed - fn pcg32(state: &mut u64) -> [u8; 4] { - const MUL: u64 = 6364136223846793005; - const INC: u64 = 11634580027462260723; + const MUL: u64 = 6364136223846793005; + const INC: u64 = 11634580027462260723; + let mut seed = Self::Seed::default(); + for chunk in seed.as_mut().chunks_mut(4) { // We advance the state first (to get away from the input value, // in case it has low Hamming Weight). - *state = state.wrapping_mul(MUL).wrapping_add(INC); - let state = *state; + state = state.wrapping_mul(MUL).wrapping_add(INC); // Use PCG output function with to_le to generate x: let xorshifted = (((state >> 18) ^ state) >> 27) as u32; let rot = (state >> 59) as u32; - let x = xorshifted.rotate_right(rot); - x.to_le_bytes() - } + let x = xorshifted.rotate_right(rot).to_le(); - let mut seed = Self::Seed::default(); - let mut iter = seed.as_mut().chunks_exact_mut(4); - for chunk in &mut iter { - chunk.copy_from_slice(&pcg32(&mut state)); - } - let rem = iter.into_remainder(); - if !rem.is_empty() { - rem.copy_from_slice(&pcg32(&mut state)[..rem.len()]); + unsafe { + let p = &x as *const u32 as *const u8; + copy_nonoverlapping(p, chunk.as_mut_ptr(), chunk.len()); + } } Self::from_seed(seed) @@ -358,6 +351,7 @@ /// (in prior versions this was not required). /// /// [`rand`]: https://docs.rs/rand + /// [`rand_os`]: https://docs.rs/rand_os fn from_rng(mut rng: R) -> Result { let mut seed = Self::Seed::default(); rng.try_fill_bytes(seed.as_mut())?; @@ -378,8 +372,7 @@ /// If [`getrandom`] is unable to provide secure entropy this method will panic. /// /// [`getrandom`]: https://docs.rs/getrandom - #[cfg(feature = "getrandom")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "getrandom")))] + #[cfg(feature="getrandom")] fn from_entropy() -> Self { let mut seed = Self::Seed::default(); if let Err(err) = getrandom::getrandom(seed.as_mut()) { @@ -417,7 +410,7 @@ // Implement `RngCore` for boxed references to an `RngCore`. // Force inlining all functions, so that it is up to the `RngCore` // implementation and the optimizer to decide on inlining. -#[cfg(feature = "alloc")] +#[cfg(feature="alloc")] impl RngCore for Box { #[inline(always)] fn next_u32(&mut self) -> u32 { @@ -440,7 +433,7 @@ } } -#[cfg(feature = "std")] +#[cfg(feature="std")] impl std::io::Read for dyn RngCore { fn read(&mut self, buf: &mut [u8]) -> Result { self.try_fill_bytes(buf)?; @@ -452,7 +445,7 @@ impl<'a, R: CryptoRng + ?Sized> CryptoRng for &'a mut R {} // Implement `CryptoRng` for boxed references to an `CryptoRng`. -#[cfg(feature = "alloc")] +#[cfg(feature="alloc")] impl CryptoRng for Box {} #[cfg(test)] @@ -464,7 +457,6 @@ struct SeedableNum(u64); impl SeedableRng for SeedableNum { type Seed = [u8; 8]; - fn from_seed(seed: Self::Seed) -> Self { let mut x = [0u64; 1]; le::read_u64_into(&seed, &mut x); @@ -485,12 +477,10 @@ // This is the binomial distribution B(64, 0.5), so chance of // weight < 20 is binocdf(19, 64, 0.5) = 7.8e-4, and same for // weight > 44. - assert!((20..=44).contains(&weight)); + assert!(weight >= 20 && weight <= 44); for (i2, r2) in results.iter().enumerate() { - if i1 == i2 { - continue; - } + if i1 == i2 { continue; } let diff_weight = (r1 ^ r2).count_ones(); assert!(diff_weight >= 20); } diff -Nru cargo-0.58.0/vendor/rand_core/src/os.rs cargo-0.60.0ubuntu1/vendor/rand_core/src/os.rs --- cargo-0.58.0/vendor/rand_core/src/os.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core/src/os.rs 2022-04-20 13:48:09.000000000 +0000 @@ -7,11 +7,12 @@ // except according to those terms. //! Interface to the random number generator of the operating system. +// Note: keep this code in sync with the rand_os crate! -use crate::{impls, CryptoRng, Error, RngCore}; use getrandom::getrandom; +use crate::{CryptoRng, RngCore, Error, impls}; -/// A random number generator that retrieves randomness from the +/// A random number generator that retrieves randomness from from the /// operating system. /// /// This is a zero-sized struct. It can be freely constructed with `OsRng`. @@ -43,7 +44,6 @@ /// ``` /// /// [getrandom]: https://crates.io/crates/getrandom -#[cfg_attr(doc_cfg, doc(cfg(feature = "getrandom")))] #[derive(Clone, Copy, Debug, Default)] pub struct OsRng; diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/.cargo-checksum.json --- cargo-0.58.0/vendor/rand_core-0.5.1/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -{"files":{},"package":"90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/Cargo.toml cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/Cargo.toml --- cargo-0.58.0/vendor/rand_core-0.5.1/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - -[package] -edition = "2018" -name = "rand_core" -version = "0.5.1" -authors = ["The Rand Project Developers", "The Rust Project Developers"] -description = "Core random number generator traits and tools for implementation.\n" -homepage = "https://crates.io/crates/rand_core" -documentation = "https://rust-random.github.io/rand/rand_core/" -readme = "README.md" -keywords = ["random", "rng"] -categories = ["algorithms", "no-std"] -license = "MIT OR Apache-2.0" -repository = "https://github.com/rust-random/rand" -[dependencies.getrandom] -version = "0.1" -optional = true - -[dependencies.serde] -version = "1" -features = ["derive"] -optional = true - -[features] -alloc = [] -serde1 = ["serde"] -std = ["alloc", "getrandom", "getrandom/std"] -[badges.appveyor] -repository = "rust-random/rand" - -[badges.travis-ci] -repository = "rust-random/rand" diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/CHANGELOG.md --- cargo-0.58.0/vendor/rand_core-0.5.1/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [0.5.1] - 2019-08-28 -- `OsRng` added to `rand_core` (#863) -- `Error::INTERNAL_START` and `Error::CUSTOM_START` constants (#864) -- `Error::raw_os_error` method (#864) -- `Debug` and `Display` formatting for `getrandom` error codes without `std` (#864) -### Changed -- `alloc` feature in `no_std` is available since Rust 1.36 (#856) -- Added `#[inline]` to `Error` conversion methods (#864) - -## [0.5.0] - 2019-06-06 -### Changed -- Enable testing with Miri and fix incorrect pointer usages (#779, #780, #781, #783, #784) -- Rewrite `Error` type and adjust API (#800) -- Adjust usage of `#[inline]` for `BlockRng` and `BlockRng64` - -## [0.4.0] - 2019-01-24 -### Changed -- Disable the `std` feature by default (#702) - -## [0.3.0] - 2018-09-24 -### Added -- Add `SeedableRng::seed_from_u64` for convenient seeding. (#537) - -## [0.2.1] - 2018-06-08 -### Added -- References to a `CryptoRng` now also implement `CryptoRng`. (#470) - -## [0.2.0] - 2018-05-21 -### Changed -- Enable the `std` feature by default. (#409) -- Remove `BlockRng{64}::inner` and `BlockRng::inner_mut`; instead making `core` public -- Change `BlockRngCore::Results` bound to also require `AsMut<[Self::Item]>`. (#419) -### Added -- Add `BlockRng{64}::index` and `BlockRng{64}::generate_and_set`. (#374, #419) -- Implement `std::io::Read` for RngCore. (#434) - -## [0.1.0] - 2018-04-17 -(Split out of the Rand crate, changes here are relative to rand 0.4.2.) -### Added -- `RngCore` and `SeedableRng` are now part of `rand_core`. (#288) -- Add modules to help implementing RNGs `impl` and `le`. (#209, #228) -- Add `Error` and `ErrorKind`. (#225) -- Add `CryptoRng` marker trait. (#273) -- Add `BlockRngCore` trait. (#281) -- Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325) -- Add `RngCore::try_fill_bytes`. (#225) -### Changed -- Revise the `SeedableRng` trait. (#233) -- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288) - -## [0.0.1] - 2017-09-14 (yanked) -Experimental version as part of the rand crate refactor. diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/COPYRIGHT cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/COPYRIGHT --- cargo-0.58.0/vendor/rand_core-0.5.1/COPYRIGHT 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/COPYRIGHT 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -Copyrights in the Rand project are retained by their contributors. No -copyright assignment is required to contribute to the Rand project. - -For full authorship information, see the version control history. - -Except as otherwise noted (below and/or in individual files), Rand is -licensed under the Apache License, Version 2.0 or - or the MIT license - or , at your option. - -The Rand project includes code from the Rust project -published under these same licenses. diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/LICENSE-APACHE cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/LICENSE-APACHE --- cargo-0.58.0/vendor/rand_core-0.5.1/LICENSE-APACHE 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/LICENSE-MIT cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/LICENSE-MIT --- cargo-0.58.0/vendor/rand_core-0.5.1/LICENSE-MIT 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -Copyright 2018 Developers of the Rand project -Copyright (c) 2014 The Rust Project Developers - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/README.md cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/README.md --- cargo-0.58.0/vendor/rand_core-0.5.1/README.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -# rand_core - -[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) -[![Latest version](https://img.shields.io/crates/v/rand_core.svg)](https://crates.io/crates/rand_core) -[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) -[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_core) -[![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core) -[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) - -Core traits and error types of the [rand] library, plus tools for implementing -RNGs. - -This crate is intended for use when implementing the core trait, `RngCore`; it -defines the core traits to be implemented as well as several small functions to -aid in their implementation and types required for error handling. - -The main [rand] crate re-exports most items defined in this crate, along with -tools to convert the integer samples generated by `RngCore` to many different -applications (including sampling from restricted ranges, conversion to floating -point, list permutations and secure initialisation of RNGs). Most users should -prefer to use the main [rand] crate. - -Links: - -- [API documentation (master)](https://rust-random.github.io/rand/rand_core) -- [API documentation (docs.rs)](https://docs.rs/rand_core) -- [Changelog](https://github.com/rust-random/rand/blob/master/rand_core/CHANGELOG.md) - -[rand]: https://crates.io/crates/rand - - -## Functionality - -The `rand_core` crate provides: - -- base random number generator traits -- error-reporting types -- functionality to aid implementation of RNGs - -The traits and error types are also available via `rand`. - -## Versions - -The current version is: -``` -rand_core = "0.5.0" -``` - -Rand libs have inter-dependencies and make use of the -[semver trick](https://github.com/dtolnay/semver-trick/) in order to make traits -compatible across crate versions. (This is especially important for `RngCore` -and `SeedableRng`.) A few crate releases are thus compatibility shims, -depending on the *next* lib version (e.g. `rand_core` versions `0.2.2` and -`0.3.1`). This means, for example, that `rand_core_0_4_0::SeedableRng` and -`rand_core_0_3_0::SeedableRng` are distinct, incompatible traits, which can -cause build errors. Usually, running `cargo update` is enough to fix any issues. - -## Crate Features - -`rand_core` supports `no_std` and `alloc`-only configurations, as well as full -`std` functionality. The differences between `no_std` and full `std` are small, -comprising `RngCore` support for `Box` types where `R: RngCore`, -`std::io::Read` support for types supporting `RngCore`, and -extensions to the `Error` type's functionality. - -The `std` feature is *not enabled by default*. This is primarily to avoid build -problems where one crate implicitly requires `rand_core` with `std` support and -another crate requires `rand` *without* `std` support. However, the `rand` crate -continues to enable `std` support by default, both for itself and `rand_core`. - -The `serde1` feature can be used to derive `Serialize` and `Deserialize` for RNG -implementations that use the `BlockRng` or `BlockRng64` wrappers. - - -# License - -`rand_core` is distributed under the terms of both the MIT license and the -Apache License (Version 2.0). - -See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and -[COPYRIGHT](COPYRIGHT) for details. diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/src/block.rs cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/block.rs --- cargo-0.58.0/vendor/rand_core-0.5.1/src/block.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/block.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,437 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The `BlockRngCore` trait and implementation helpers -//! -//! The [`BlockRngCore`] trait exists to assist in the implementation of RNGs -//! which generate a block of data in a cache instead of returning generated -//! values directly. -//! -//! Usage of this trait is optional, but provides two advantages: -//! implementations only need to concern themselves with generation of the -//! block, not the various [`RngCore`] methods (especially [`fill_bytes`], where -//! the optimal implementations are not trivial), and this allows -//! `ReseedingRng` (see [`rand`](https://docs.rs/rand) crate) perform periodic -//! reseeding with very low overhead. -//! -//! # Example -//! -//! ```norun -//! use rand_core::block::{BlockRngCore, BlockRng}; -//! -//! struct MyRngCore; -//! -//! impl BlockRngCore for MyRngCore { -//! type Results = [u32; 16]; -//! -//! fn generate(&mut self, results: &mut Self::Results) { -//! unimplemented!() -//! } -//! } -//! -//! impl SeedableRng for MyRngCore { -//! type Seed = unimplemented!(); -//! fn from_seed(seed: Self::Seed) -> Self { -//! unimplemented!() -//! } -//! } -//! -//! // optionally, also implement CryptoRng for MyRngCore -//! -//! // Final RNG. -//! type MyRng = BlockRng; -//! ``` -//! -//! [`BlockRngCore`]: crate::block::BlockRngCore -//! [`fill_bytes`]: RngCore::fill_bytes - -use core::convert::AsRef; -use core::{fmt, ptr}; -#[cfg(feature="serde1")] use serde::{Serialize, Deserialize}; -use crate::{RngCore, CryptoRng, SeedableRng, Error}; -use crate::impls::{fill_via_u32_chunks, fill_via_u64_chunks}; - -/// A trait for RNGs which do not generate random numbers individually, but in -/// blocks (typically `[u32; N]`). This technique is commonly used by -/// cryptographic RNGs to improve performance. -/// -/// See the [module][crate::block] documentation for details. -pub trait BlockRngCore { - /// Results element type, e.g. `u32`. - type Item; - - /// Results type. This is the 'block' an RNG implementing `BlockRngCore` - /// generates, which will usually be an array like `[u32; 16]`. - type Results: AsRef<[Self::Item]> + AsMut<[Self::Item]> + Default; - - /// Generate a new block of results. - fn generate(&mut self, results: &mut Self::Results); -} - - -/// A wrapper type implementing [`RngCore`] for some type implementing -/// [`BlockRngCore`] with `u32` array buffer; i.e. this can be used to implement -/// a full RNG from just a `generate` function. -/// -/// The `core` field may be accessed directly but the results buffer may not. -/// PRNG implementations can simply use a type alias -/// (`pub type MyRng = BlockRng;`) but might prefer to use a -/// wrapper type (`pub struct MyRng(BlockRng);`); the latter must -/// re-implement `RngCore` but hides the implementation details and allows -/// extra functionality to be defined on the RNG -/// (e.g. `impl MyRng { fn set_stream(...){...} }`). -/// -/// `BlockRng` has heavily optimized implementations of the [`RngCore`] methods -/// reading values from the results buffer, as well as -/// calling [`BlockRngCore::generate`] directly on the output array when -/// [`fill_bytes`] / [`try_fill_bytes`] is called on a large array. These methods -/// also handle the bookkeeping of when to generate a new batch of values. -/// -/// No whole generated `u32` values are thown away and all values are consumed -/// in-order. [`next_u32`] simply takes the next available `u32` value. -/// [`next_u64`] is implemented by combining two `u32` values, least -/// significant first. [`fill_bytes`] and [`try_fill_bytes`] consume a whole -/// number of `u32` values, converting each `u32` to a byte slice in -/// little-endian order. If the requested byte length is not a multiple of 4, -/// some bytes will be discarded. -/// -/// See also [`BlockRng64`] which uses `u64` array buffers. Currently there is -/// no direct support for other buffer types. -/// -/// For easy initialization `BlockRng` also implements [`SeedableRng`]. -/// -/// [`next_u32`]: RngCore::next_u32 -/// [`next_u64`]: RngCore::next_u64 -/// [`fill_bytes`]: RngCore::fill_bytes -/// [`try_fill_bytes`]: RngCore::try_fill_bytes -#[derive(Clone)] -#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] -pub struct BlockRng { - results: R::Results, - index: usize, - /// The *core* part of the RNG, implementing the `generate` function. - pub core: R, -} - -// Custom Debug implementation that does not expose the contents of `results`. -impl fmt::Debug for BlockRng { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_struct("BlockRng") - .field("core", &self.core) - .field("result_len", &self.results.as_ref().len()) - .field("index", &self.index) - .finish() - } -} - -impl BlockRng { - /// Create a new `BlockRng` from an existing RNG implementing - /// `BlockRngCore`. Results will be generated on first use. - #[inline] - pub fn new(core: R) -> BlockRng{ - let results_empty = R::Results::default(); - BlockRng { - core, - index: results_empty.as_ref().len(), - results: results_empty, - } - } - - /// Get the index into the result buffer. - /// - /// If this is equal to or larger than the size of the result buffer then - /// the buffer is "empty" and `generate()` must be called to produce new - /// results. - #[inline(always)] - pub fn index(&self) -> usize { - self.index - } - - /// Reset the number of available results. - /// This will force a new set of results to be generated on next use. - #[inline] - pub fn reset(&mut self) { - self.index = self.results.as_ref().len(); - } - - /// Generate a new set of results immediately, setting the index to the - /// given value. - #[inline] - pub fn generate_and_set(&mut self, index: usize) { - assert!(index < self.results.as_ref().len()); - self.core.generate(&mut self.results); - self.index = index; - } -} - -impl> RngCore for BlockRng -where ::Results: AsRef<[u32]> + AsMut<[u32]> -{ - #[inline] - fn next_u32(&mut self) -> u32 { - if self.index >= self.results.as_ref().len() { - self.generate_and_set(0); - } - - let value = self.results.as_ref()[self.index]; - self.index += 1; - value - } - - #[inline] - fn next_u64(&mut self) -> u64 { - let read_u64 = |results: &[u32], index| { - if cfg!(any(target_endian = "little")) { - // requires little-endian CPU - #[allow(clippy::cast_ptr_alignment)] // false positive - let ptr: *const u64 = results[index..=index+1].as_ptr() as *const u64; - unsafe { ptr::read_unaligned(ptr) } - } else { - let x = u64::from(results[index]); - let y = u64::from(results[index + 1]); - (y << 32) | x - } - }; - - let len = self.results.as_ref().len(); - - let index = self.index; - if index < len-1 { - self.index += 2; - // Read an u64 from the current index - read_u64(self.results.as_ref(), index) - } else if index >= len { - self.generate_and_set(2); - read_u64(self.results.as_ref(), 0) - } else { - let x = u64::from(self.results.as_ref()[len-1]); - self.generate_and_set(1); - let y = u64::from(self.results.as_ref()[0]); - (y << 32) | x - } - } - - #[inline] - fn fill_bytes(&mut self, dest: &mut [u8]) { - let mut read_len = 0; - while read_len < dest.len() { - if self.index >= self.results.as_ref().len() { - self.generate_and_set(0); - } - let (consumed_u32, filled_u8) = - fill_via_u32_chunks(&self.results.as_ref()[self.index..], - &mut dest[read_len..]); - - self.index += consumed_u32; - read_len += filled_u8; - } - } - - #[inline(always)] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.fill_bytes(dest); - Ok(()) - } -} - -impl SeedableRng for BlockRng { - type Seed = R::Seed; - - #[inline(always)] - fn from_seed(seed: Self::Seed) -> Self { - Self::new(R::from_seed(seed)) - } - - #[inline(always)] - fn seed_from_u64(seed: u64) -> Self { - Self::new(R::seed_from_u64(seed)) - } - - #[inline(always)] - fn from_rng(rng: S) -> Result { - Ok(Self::new(R::from_rng(rng)?)) - } -} - - - -/// A wrapper type implementing [`RngCore`] for some type implementing -/// [`BlockRngCore`] with `u64` array buffer; i.e. this can be used to implement -/// a full RNG from just a `generate` function. -/// -/// This is similar to [`BlockRng`], but specialized for algorithms that operate -/// on `u64` values. -/// -/// No whole generated `u64` values are thrown away and all values are consumed -/// in-order. [`next_u64`] simply takes the next available `u64` value. -/// [`next_u32`] is however a bit special: half of a `u64` is consumed, leaving -/// the other half in the buffer. If the next function called is [`next_u32`] -/// then the other half is then consumed, however both [`next_u64`] and -/// [`fill_bytes`] discard the rest of any half-consumed `u64`s when called. -/// -/// [`fill_bytes`] and [`try_fill_bytes`] consume a whole number of `u64` -/// values. If the requested length is not a multiple of 8, some bytes will be -/// discarded. -/// -/// [`next_u32`]: RngCore::next_u32 -/// [`next_u64`]: RngCore::next_u64 -/// [`fill_bytes`]: RngCore::fill_bytes -/// [`try_fill_bytes`]: RngCore::try_fill_bytes -#[derive(Clone)] -#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] -pub struct BlockRng64 { - results: R::Results, - index: usize, - half_used: bool, // true if only half of the previous result is used - /// The *core* part of the RNG, implementing the `generate` function. - pub core: R, -} - -// Custom Debug implementation that does not expose the contents of `results`. -impl fmt::Debug for BlockRng64 { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_struct("BlockRng64") - .field("core", &self.core) - .field("result_len", &self.results.as_ref().len()) - .field("index", &self.index) - .field("half_used", &self.half_used) - .finish() - } -} - -impl BlockRng64 { - /// Create a new `BlockRng` from an existing RNG implementing - /// `BlockRngCore`. Results will be generated on first use. - #[inline] - pub fn new(core: R) -> BlockRng64{ - let results_empty = R::Results::default(); - BlockRng64 { - core, - index: results_empty.as_ref().len(), - half_used: false, - results: results_empty, - } - } - - /// Get the index into the result buffer. - /// - /// If this is equal to or larger than the size of the result buffer then - /// the buffer is "empty" and `generate()` must be called to produce new - /// results. - #[inline(always)] - pub fn index(&self) -> usize { - self.index - } - - /// Reset the number of available results. - /// This will force a new set of results to be generated on next use. - #[inline] - pub fn reset(&mut self) { - self.index = self.results.as_ref().len(); - self.half_used = false; - } - - /// Generate a new set of results immediately, setting the index to the - /// given value. - #[inline] - pub fn generate_and_set(&mut self, index: usize) { - assert!(index < self.results.as_ref().len()); - self.core.generate(&mut self.results); - self.index = index; - self.half_used = false; - } -} - -impl> RngCore for BlockRng64 -where ::Results: AsRef<[u64]> + AsMut<[u64]> -{ - #[inline] - fn next_u32(&mut self) -> u32 { - let mut index = self.index * 2 - self.half_used as usize; - if index >= self.results.as_ref().len() * 2 { - self.core.generate(&mut self.results); - self.index = 0; - // `self.half_used` is by definition `false` - self.half_used = false; - index = 0; - } - - self.half_used = !self.half_used; - self.index += self.half_used as usize; - - // Index as if this is a u32 slice. - unsafe { - let results = - &*(self.results.as_ref() as *const [u64] as *const [u32]); - if cfg!(target_endian = "little") { - *results.get_unchecked(index) - } else { - *results.get_unchecked(index ^ 1) - } - } - } - - #[inline] - fn next_u64(&mut self) -> u64 { - if self.index >= self.results.as_ref().len() { - self.core.generate(&mut self.results); - self.index = 0; - } - - let value = self.results.as_ref()[self.index]; - self.index += 1; - self.half_used = false; - value - } - - #[inline] - fn fill_bytes(&mut self, dest: &mut [u8]) { - let mut read_len = 0; - self.half_used = false; - while read_len < dest.len() { - if self.index as usize >= self.results.as_ref().len() { - self.core.generate(&mut self.results); - self.index = 0; - } - - let (consumed_u64, filled_u8) = - fill_via_u64_chunks(&self.results.as_ref()[self.index as usize..], - &mut dest[read_len..]); - - self.index += consumed_u64; - read_len += filled_u8; - } - } - - #[inline(always)] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.fill_bytes(dest); - Ok(()) - } -} - -impl SeedableRng for BlockRng64 { - type Seed = R::Seed; - - #[inline(always)] - fn from_seed(seed: Self::Seed) -> Self { - Self::new(R::from_seed(seed)) - } - - #[inline(always)] - fn seed_from_u64(seed: u64) -> Self { - Self::new(R::seed_from_u64(seed)) - } - - #[inline(always)] - fn from_rng(rng: S) -> Result { - Ok(Self::new(R::from_rng(rng)?)) - } -} - -impl CryptoRng for BlockRng {} diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/src/error.rs cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/error.rs --- cargo-0.58.0/vendor/rand_core-0.5.1/src/error.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/error.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,190 +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. - -//! Error types - -use core::fmt; -use core::num::NonZeroU32; - - -/// Error type of random number generators -/// -/// In order to be compatible with `std` and `no_std`, this type has two -/// possible implementations: with `std` a boxed `Error` trait object is stored, -/// while with `no_std` we merely store an error code. -pub struct Error { - #[cfg(feature="std")] - inner: Box, - #[cfg(not(feature="std"))] - code: NonZeroU32, -} - -impl Error { - /// Construct from any type supporting `std::error::Error` - /// - /// Available only when configured with `std`. - /// - /// See also `From`, which is available with and without `std`. - #[cfg(feature="std")] - #[inline] - pub fn new(err: E) -> Self - where E: Into> - { - Error { inner: err.into() } - } - - /// Reference the inner error (`std` only) - /// - /// When configured with `std`, this is a trivial operation and never - /// panics. Without `std`, this method is simply unavailable. - #[cfg(feature="std")] - #[inline] - pub fn inner(&self) -> &(dyn std::error::Error + Send + Sync + 'static) { - &*self.inner - } - - /// Unwrap the inner error (`std` only) - /// - /// When configured with `std`, this is a trivial operation and never - /// panics. Without `std`, this method is simply unavailable. - #[cfg(feature="std")] - #[inline] - pub fn take_inner(self) -> Box { - self.inner - } - - /// Codes below this point represent OS Errors (i.e. positive i32 values). - /// Codes at or above this point, but below [`Error::CUSTOM_START`] are - /// reserved for use by the `rand` and `getrandom` crates. - pub const INTERNAL_START: u32 = 1 << 31; - - /// Codes at or above this point can be used by users to define their own - /// custom errors. - pub const CUSTOM_START: u32 = (1 << 31) + (1 << 30); - - /// Extract the raw OS error code (if this error came from the OS) - /// - /// This method is identical to `std::io::Error::raw_os_error()`, except - /// that it works in `no_std` contexts. If this method returns `None`, the - /// error value can still be formatted via the `Diplay` implementation. - #[inline] - pub fn raw_os_error(&self) -> Option { - #[cfg(feature="std")] { - if let Some(e) = self.inner.downcast_ref::() { - return e.raw_os_error(); - } - } - match self.code() { - Some(code) if u32::from(code) < Self::INTERNAL_START => - Some(u32::from(code) as i32), - _ => None, - } - } - - /// Retrieve the error code, if any. - /// - /// If this `Error` was constructed via `From`, then this method - /// will return this `NonZeroU32` code (for `no_std` this is always the - /// case). Otherwise, this method will return `None`. - #[inline] - pub fn code(&self) -> Option { - #[cfg(feature="std")] { - self.inner.downcast_ref::().map(|c| c.0) - } - #[cfg(not(feature="std"))] { - Some(self.code) - } - } -} - -impl fmt::Debug for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - #[cfg(feature="std")] { - write!(f, "Error {{ inner: {:?} }}", self.inner) - } - #[cfg(all(feature="getrandom", not(feature="std")))] { - getrandom::Error::from(self.code).fmt(f) - } - #[cfg(not(feature="getrandom"))] { - write!(f, "Error {{ code: {} }}", self.code) - } - } -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - #[cfg(feature="std")] { - write!(f, "{}", self.inner) - } - #[cfg(all(feature="getrandom", not(feature="std")))] { - getrandom::Error::from(self.code).fmt(f) - } - #[cfg(not(feature="getrandom"))] { - write!(f, "error code {}", self.code) - } - } -} - -impl From for Error { - #[inline] - fn from(code: NonZeroU32) -> Self { - #[cfg(feature="std")] { - Error { inner: Box::new(ErrorCode(code)) } - } - #[cfg(not(feature="std"))] { - Error { code } - } - } -} - -#[cfg(feature="getrandom")] -impl From for Error { - #[inline] - fn from(error: getrandom::Error) -> Self { - #[cfg(feature="std")] { - Error { inner: Box::new(error) } - } - #[cfg(not(feature="std"))] { - Error { code: error.code() } - } - } -} - -#[cfg(feature="std")] -impl std::error::Error for Error { - #[inline] - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - self.inner.source() - } -} - -#[cfg(feature="std")] -impl From for std::io::Error { - #[inline] - fn from(error: Error) -> Self { - if let Some(code) = error.raw_os_error() { - std::io::Error::from_raw_os_error(code) - } else { - std::io::Error::new(std::io::ErrorKind::Other, error) - } - } -} - -#[cfg(feature="std")] -#[derive(Debug, Copy, Clone)] -struct ErrorCode(NonZeroU32); - -#[cfg(feature="std")] -impl fmt::Display for ErrorCode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "error code {}", self.0) - } -} - -#[cfg(feature="std")] -impl std::error::Error for ErrorCode {} diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/src/impls.rs cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/impls.rs --- cargo-0.58.0/vendor/rand_core-0.5.1/src/impls.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/impls.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +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. - -//! Helper functions for implementing `RngCore` functions. -//! -//! For cross-platform reproducibility, these functions all use Little Endian: -//! least-significant part first. For example, `next_u64_via_u32` takes `u32` -//! values `x, y`, then outputs `(y << 32) | x`. To implement `next_u32` -//! from `next_u64` in little-endian order, one should use `next_u64() as u32`. -//! -//! Byte-swapping (like the std `to_le` functions) is only needed to convert -//! to/from byte sequences, and since its purpose is reproducibility, -//! non-reproducible sources (e.g. `OsRng`) need not bother with it. - -use core::ptr::copy_nonoverlapping; -use core::slice; -use core::cmp::min; -use core::mem::size_of; -use crate::RngCore; - - -/// Implement `next_u64` via `next_u32`, little-endian order. -pub fn next_u64_via_u32(rng: &mut R) -> u64 { - // Use LE; we explicitly generate one value before the next. - let x = u64::from(rng.next_u32()); - let y = u64::from(rng.next_u32()); - (y << 32) | x -} - -/// Implement `fill_bytes` via `next_u64` and `next_u32`, little-endian order. -/// -/// The fastest way to fill a slice is usually to work as long as possible with -/// integers. That is why this method mostly uses `next_u64`, and only when -/// there are 4 or less bytes remaining at the end of the slice it uses -/// `next_u32` once. -pub fn fill_bytes_via_next(rng: &mut R, dest: &mut [u8]) { - let mut left = dest; - while left.len() >= 8 { - let (l, r) = {left}.split_at_mut(8); - left = r; - let chunk: [u8; 8] = rng.next_u64().to_le_bytes(); - l.copy_from_slice(&chunk); - } - let n = left.len(); - if n > 4 { - let chunk: [u8; 8] = rng.next_u64().to_le_bytes(); - left.copy_from_slice(&chunk[..n]); - } else if n > 0 { - let chunk: [u8; 4] = rng.next_u32().to_le_bytes(); - left.copy_from_slice(&chunk[..n]); - } -} - -macro_rules! impl_uint_from_fill { - ($rng:expr, $ty:ty, $N:expr) => ({ - debug_assert!($N == size_of::<$ty>()); - - let mut int: $ty = 0; - unsafe { - let ptr = &mut int as *mut $ty as *mut u8; - let slice = slice::from_raw_parts_mut(ptr, $N); - $rng.fill_bytes(slice); - } - int - }); -} - -macro_rules! fill_via_chunks { - ($src:expr, $dst:expr, $ty:ty, $size:expr) => ({ - let chunk_size_u8 = min($src.len() * $size, $dst.len()); - let chunk_size = (chunk_size_u8 + $size - 1) / $size; - if cfg!(target_endian="little") { - unsafe { - copy_nonoverlapping( - $src.as_ptr() as *const u8, - $dst.as_mut_ptr(), - chunk_size_u8); - } - } else { - for (&n, chunk) in $src.iter().zip($dst.chunks_mut($size)) { - let tmp = n.to_le(); - let src_ptr = &tmp as *const $ty as *const u8; - unsafe { - copy_nonoverlapping(src_ptr, - chunk.as_mut_ptr(), - chunk.len()); - } - } - } - - (chunk_size, chunk_size_u8) - }); -} - -/// Implement `fill_bytes` by reading chunks from the output buffer of a block -/// based RNG. -/// -/// The return values are `(consumed_u32, filled_u8)`. -/// -/// `filled_u8` is the number of filled bytes in `dest`, which may be less than -/// the length of `dest`. -/// `consumed_u32` is the number of words consumed from `src`, which is the same -/// as `filled_u8 / 4` rounded up. -/// -/// # Example -/// (from `IsaacRng`) -/// -/// ```ignore -/// fn fill_bytes(&mut self, dest: &mut [u8]) { -/// let mut read_len = 0; -/// while read_len < dest.len() { -/// if self.index >= self.rsl.len() { -/// self.isaac(); -/// } -/// -/// let (consumed_u32, filled_u8) = -/// impls::fill_via_u32_chunks(&mut self.rsl[self.index..], -/// &mut dest[read_len..]); -/// -/// self.index += consumed_u32; -/// read_len += filled_u8; -/// } -/// } -/// ``` -pub fn fill_via_u32_chunks(src: &[u32], dest: &mut [u8]) -> (usize, usize) { - fill_via_chunks!(src, dest, u32, 4) -} - -/// Implement `fill_bytes` by reading chunks from the output buffer of a block -/// based RNG. -/// -/// The return values are `(consumed_u64, filled_u8)`. -/// `filled_u8` is the number of filled bytes in `dest`, which may be less than -/// the length of `dest`. -/// `consumed_u64` is the number of words consumed from `src`, which is the same -/// as `filled_u8 / 8` rounded up. -/// -/// See `fill_via_u32_chunks` for an example. -pub fn fill_via_u64_chunks(src: &[u64], dest: &mut [u8]) -> (usize, usize) { - fill_via_chunks!(src, dest, u64, 8) -} - -/// Implement `next_u32` via `fill_bytes`, little-endian order. -pub fn next_u32_via_fill(rng: &mut R) -> u32 { - impl_uint_from_fill!(rng, u32, 4) -} - -/// Implement `next_u64` via `fill_bytes`, little-endian order. -pub fn next_u64_via_fill(rng: &mut R) -> u64 { - impl_uint_from_fill!(rng, u64, 8) -} - -// TODO: implement tests for the above diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/src/le.rs cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/le.rs --- cargo-0.58.0/vendor/rand_core-0.5.1/src/le.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/le.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +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. - -//! Little-Endian utilities -//! -//! Little-Endian order has been chosen for internal usage; this makes some -//! useful functions available. - -use core::ptr; - -macro_rules! read_slice { - ($src:expr, $dst:expr, $size:expr, $which:ident) => {{ - assert_eq!($src.len(), $size * $dst.len()); - - unsafe { - ptr::copy_nonoverlapping( - $src.as_ptr(), - $dst.as_mut_ptr() as *mut u8, - $src.len()); - } - for v in $dst.iter_mut() { - *v = v.$which(); - } - }}; -} - -/// Reads unsigned 32 bit integers from `src` into `dst`. -/// Borrowed from the `byteorder` crate. -#[inline] -pub fn read_u32_into(src: &[u8], dst: &mut [u32]) { - read_slice!(src, dst, 4, to_le); -} - -/// Reads unsigned 64 bit integers from `src` into `dst`. -/// Borrowed from the `byteorder` crate. -#[inline] -pub fn read_u64_into(src: &[u8], dst: &mut [u64]) { - read_slice!(src, dst, 8, to_le); -} - -#[test] -fn test_read() { - let bytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - - let mut buf = [0u32; 4]; - read_u32_into(&bytes, &mut buf); - assert_eq!(buf[0], 0x04030201); - assert_eq!(buf[3], 0x100F0E0D); - - let mut buf = [0u32; 3]; - read_u32_into(&bytes[1..13], &mut buf); // unaligned - assert_eq!(buf[0], 0x05040302); - assert_eq!(buf[2], 0x0D0C0B0A); - - let mut buf = [0u64; 2]; - read_u64_into(&bytes, &mut buf); - assert_eq!(buf[0], 0x0807060504030201); - assert_eq!(buf[1], 0x100F0E0D0C0B0A09); - - let mut buf = [0u64; 1]; - read_u64_into(&bytes[7..15], &mut buf); // unaligned - assert_eq!(buf[0], 0x0F0E0D0C0B0A0908); -} diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/src/lib.rs cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/lib.rs --- cargo-0.58.0/vendor/rand_core-0.5.1/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,492 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2017-2018 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Random number generation traits -//! -//! This crate is mainly of interest to crates publishing implementations of -//! [`RngCore`]. Other users are encouraged to use the [`rand`] crate instead -//! which re-exports the main traits and error types. -//! -//! [`RngCore`] is the core trait implemented by algorithmic pseudo-random number -//! generators and external random-number sources. -//! -//! [`SeedableRng`] is an extension trait for construction from fixed seeds and -//! other random number generators. -//! -//! [`Error`] is provided for error-handling. It is safe to use in `no_std` -//! environments. -//! -//! The [`impls`] and [`le`] sub-modules include a few small functions to assist -//! implementation of [`RngCore`]. -//! -//! [`rand`]: https://docs.rs/rand - -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://rust-random.github.io/rand/")] - -#![deny(missing_docs)] -#![deny(missing_debug_implementations)] -#![doc(test(attr(allow(unused_variables), deny(warnings))))] - -#![allow(clippy::unreadable_literal)] - -#![cfg_attr(not(feature="std"), no_std)] - - -use core::default::Default; -use core::convert::AsMut; -use core::ptr::copy_nonoverlapping; - -#[cfg(all(feature="alloc", not(feature="std")))] extern crate alloc; -#[cfg(all(feature="alloc", not(feature="std")))] use alloc::boxed::Box; - -pub use error::Error; -#[cfg(feature="getrandom")] pub use os::OsRng; - - -mod error; -pub mod block; -pub mod impls; -pub mod le; -#[cfg(feature="getrandom")] mod os; - - -/// The core of a random number generator. -/// -/// This trait encapsulates the low-level functionality common to all -/// generators, and is the "back end", to be implemented by generators. -/// End users should normally use the `Rng` trait from the [`rand`] crate, -/// which is automatically implemented for every type implementing `RngCore`. -/// -/// Three different methods for generating random data are provided since the -/// optimal implementation of each is dependent on the type of generator. There -/// is no required relationship between the output of each; e.g. many -/// implementations of [`fill_bytes`] consume a whole number of `u32` or `u64` -/// values and drop any remaining unused bytes. -/// -/// The [`try_fill_bytes`] method is a variant of [`fill_bytes`] allowing error -/// handling; it is not deemed sufficiently useful to add equivalents for -/// [`next_u32`] or [`next_u64`] since the latter methods are almost always used -/// with algorithmic generators (PRNGs), which are normally infallible. -/// -/// Algorithmic generators implementing [`SeedableRng`] should normally have -/// *portable, reproducible* output, i.e. fix Endianness when converting values -/// to avoid platform differences, and avoid making any changes which affect -/// output (except by communicating that the release has breaking changes). -/// -/// Typically implementators will implement only one of the methods available -/// in this trait directly, then use the helper functions from the -/// [`impls`] module to implement the other methods. -/// -/// It is recommended that implementations also implement: -/// -/// - `Debug` with a custom implementation which *does not* print any internal -/// state (at least, [`CryptoRng`]s should not risk leaking state through -/// `Debug`). -/// - `Serialize` and `Deserialize` (from Serde), preferably making Serde -/// support optional at the crate level in PRNG libs. -/// - `Clone`, if possible. -/// - *never* implement `Copy` (accidental copies may cause repeated values). -/// - *do not* implement `Default` for pseudorandom generators, but instead -/// implement [`SeedableRng`], to guide users towards proper seeding. -/// External / hardware RNGs can choose to implement `Default`. -/// - `Eq` and `PartialEq` could be implemented, but are probably not useful. -/// -/// # Example -/// -/// A simple example, obviously not generating very *random* output: -/// -/// ``` -/// #![allow(dead_code)] -/// use rand_core::{RngCore, Error, impls}; -/// -/// struct CountingRng(u64); -/// -/// impl RngCore for CountingRng { -/// fn next_u32(&mut self) -> u32 { -/// self.next_u64() as u32 -/// } -/// -/// fn next_u64(&mut self) -> u64 { -/// self.0 += 1; -/// self.0 -/// } -/// -/// fn fill_bytes(&mut self, dest: &mut [u8]) { -/// impls::fill_bytes_via_next(self, dest) -/// } -/// -/// fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { -/// Ok(self.fill_bytes(dest)) -/// } -/// } -/// ``` -/// -/// [`rand`]: https://docs.rs/rand -/// [`try_fill_bytes`]: RngCore::try_fill_bytes -/// [`fill_bytes`]: RngCore::fill_bytes -/// [`next_u32`]: RngCore::next_u32 -/// [`next_u64`]: RngCore::next_u64 -pub trait RngCore { - /// Return the next random `u32`. - /// - /// RNGs must implement at least one method from this trait directly. In - /// the case this method is not implemented directly, it can be implemented - /// using `self.next_u64() as u32` or via - /// [`fill_bytes`](impls::next_u32_via_fill). - fn next_u32(&mut self) -> u32; - - /// Return the next random `u64`. - /// - /// RNGs must implement at least one method from this trait directly. In - /// the case this method is not implemented directly, it can be implemented - /// via [`next_u32`](impls::next_u64_via_u32) or via - /// [`fill_bytes`](impls::next_u64_via_fill). - fn next_u64(&mut self) -> u64; - - /// Fill `dest` with random data. - /// - /// RNGs must implement at least one method from this trait directly. In - /// the case this method is not implemented directly, it can be implemented - /// via [`next_u*`](impls::fill_bytes_via_next) or - /// via [`try_fill_bytes`](RngCore::try_fill_bytes); if this generator can - /// fail the implementation must choose how best to handle errors here - /// (e.g. panic with a descriptive message or log a warning and retry a few - /// times). - /// - /// This method should guarantee that `dest` is entirely filled - /// with new data, and may panic if this is impossible - /// (e.g. reading past the end of a file that is being used as the - /// source of randomness). - fn fill_bytes(&mut self, dest: &mut [u8]); - - /// Fill `dest` entirely with random data. - /// - /// This is the only method which allows an RNG to report errors while - /// generating random data thus making this the primary method implemented - /// by external (true) RNGs (e.g. `OsRng`) which can fail. It may be used - /// directly to generate keys and to seed (infallible) PRNGs. - /// - /// Other than error handling, this method is identical to [`fill_bytes`]; - /// thus this may be implemented using `Ok(self.fill_bytes(dest))` or - /// `fill_bytes` may be implemented with - /// `self.try_fill_bytes(dest).unwrap()` or more specific error handling. - /// - /// [`fill_bytes`]: RngCore::fill_bytes - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>; -} - -/// A marker trait used to indicate that an [`RngCore`] or [`BlockRngCore`] -/// implementation is supposed to be cryptographically secure. -/// -/// *Cryptographically secure generators*, also known as *CSPRNGs*, should -/// satisfy an additional properties over other generators: given the first -/// *k* bits of an algorithm's output -/// sequence, it should not be possible using polynomial-time algorithms to -/// predict the next bit with probability significantly greater than 50%. -/// -/// Some generators may satisfy an additional property, however this is not -/// required by this trait: if the CSPRNG's state is revealed, it should not be -/// computationally-feasible to reconstruct output prior to this. Some other -/// generators allow backwards-computation and are consided *reversible*. -/// -/// Note that this trait is provided for guidance only and cannot guarantee -/// suitability for cryptographic applications. In general it should only be -/// implemented for well-reviewed code implementing well-regarded algorithms. -/// -/// Note also that use of a `CryptoRng` does not protect against other -/// weaknesses such as seeding from a weak entropy source or leaking state. -/// -/// [`BlockRngCore`]: block::BlockRngCore -pub trait CryptoRng {} - -/// A random number generator that can be explicitly seeded. -/// -/// This trait encapsulates the low-level functionality common to all -/// pseudo-random number generators (PRNGs, or algorithmic generators). -/// -/// [`rand`]: https://docs.rs/rand -pub trait SeedableRng: Sized { - /// Seed type, which is restricted to types mutably-dereferencable as `u8` - /// arrays (we recommend `[u8; N]` for some `N`). - /// - /// It is recommended to seed PRNGs with a seed of at least circa 100 bits, - /// which means an array of `[u8; 12]` or greater to avoid picking RNGs with - /// partially overlapping periods. - /// - /// For cryptographic RNG's a seed of 256 bits is recommended, `[u8; 32]`. - /// - /// - /// # Implementing `SeedableRng` for RNGs with large seeds - /// - /// Note that the required traits `core::default::Default` and - /// `core::convert::AsMut` are not implemented for large arrays - /// `[u8; N]` with `N` > 32. To be able to implement the traits required by - /// `SeedableRng` for RNGs with such large seeds, the newtype pattern can be - /// used: - /// - /// ``` - /// use rand_core::SeedableRng; - /// - /// const N: usize = 64; - /// pub struct MyRngSeed(pub [u8; N]); - /// pub struct MyRng(MyRngSeed); - /// - /// impl Default for MyRngSeed { - /// fn default() -> MyRngSeed { - /// MyRngSeed([0; N]) - /// } - /// } - /// - /// impl AsMut<[u8]> for MyRngSeed { - /// fn as_mut(&mut self) -> &mut [u8] { - /// &mut self.0 - /// } - /// } - /// - /// impl SeedableRng for MyRng { - /// type Seed = MyRngSeed; - /// - /// fn from_seed(seed: MyRngSeed) -> MyRng { - /// MyRng(seed) - /// } - /// } - /// ``` - type Seed: Sized + Default + AsMut<[u8]>; - - /// Create a new PRNG using the given seed. - /// - /// PRNG implementations are allowed to assume that bits in the seed are - /// well distributed. That means usually that the number of one and zero - /// bits are roughly equal, and values like 0, 1 and (size - 1) are unlikely. - /// Note that many non-cryptographic PRNGs will show poor quality output - /// if this is not adhered to. If you wish to seed from simple numbers, use - /// `seed_from_u64` instead. - /// - /// All PRNG implementations should be reproducible unless otherwise noted: - /// given a fixed `seed`, the same sequence of output should be produced - /// on all runs, library versions and architectures (e.g. check endianness). - /// Any "value-breaking" changes to the generator should require bumping at - /// least the minor version and documentation of the change. - /// - /// It is not required that this function yield the same state as a - /// reference implementation of the PRNG given equivalent seed; if necessary - /// another constructor replicating behaviour from a reference - /// implementation can be added. - /// - /// PRNG implementations should make sure `from_seed` never panics. In the - /// case that some special values (like an all zero seed) are not viable - /// seeds it is preferable to map these to alternative constant value(s), - /// for example `0xBAD5EEDu32` or `0x0DDB1A5E5BAD5EEDu64` ("odd biases? bad - /// seed"). This is assuming only a small number of values must be rejected. - fn from_seed(seed: Self::Seed) -> Self; - - /// Create a new PRNG using a `u64` seed. - /// - /// This is a convenience-wrapper around `from_seed` to allow construction - /// of any `SeedableRng` from a simple `u64` value. It is designed such that - /// low Hamming Weight numbers like 0 and 1 can be used and should still - /// result in good, independent seeds to the PRNG which is returned. - /// - /// This **is not suitable for cryptography**, as should be clear given that - /// the input size is only 64 bits. - /// - /// Implementations for PRNGs *may* provide their own implementations of - /// this function, but the default implementation should be good enough for - /// all purposes. *Changing* the implementation of this function should be - /// considered a value-breaking change. - fn seed_from_u64(mut state: u64) -> Self { - // We use PCG32 to generate a u32 sequence, and copy to the seed - const MUL: u64 = 6364136223846793005; - const INC: u64 = 11634580027462260723; - - let mut seed = Self::Seed::default(); - for chunk in seed.as_mut().chunks_mut(4) { - // We advance the state first (to get away from the input value, - // in case it has low Hamming Weight). - state = state.wrapping_mul(MUL).wrapping_add(INC); - - // Use PCG output function with to_le to generate x: - let xorshifted = (((state >> 18) ^ state) >> 27) as u32; - let rot = (state >> 59) as u32; - let x = xorshifted.rotate_right(rot).to_le(); - - unsafe { - let p = &x as *const u32 as *const u8; - copy_nonoverlapping(p, chunk.as_mut_ptr(), chunk.len()); - } - } - - Self::from_seed(seed) - } - - /// Create a new PRNG seeded from another `Rng`. - /// - /// This may be useful when needing to rapidly seed many PRNGs from a master - /// PRNG, and to allow forking of PRNGs. It may be considered deterministic. - /// - /// The master PRNG should be at least as high quality as the child PRNGs. - /// When seeding non-cryptographic child PRNGs, we recommend using a - /// different algorithm for the master PRNG (ideally a CSPRNG) to avoid - /// correlations between the child PRNGs. If this is not possible (e.g. - /// forking using small non-crypto PRNGs) ensure that your PRNG has a good - /// mixing function on the output or consider use of a hash function with - /// `from_seed`. - /// - /// Note that seeding `XorShiftRng` from another `XorShiftRng` provides an - /// extreme example of what can go wrong: the new PRNG will be a clone - /// of the parent. - /// - /// PRNG implementations are allowed to assume that a good RNG is provided - /// for seeding, and that it is cryptographically secure when appropriate. - /// As of `rand` 0.7 / `rand_core` 0.5, implementations overriding this - /// method should ensure the implementation satisfies reproducibility - /// (in prior versions this was not required). - /// - /// [`rand`]: https://docs.rs/rand - /// [`rand_os`]: https://docs.rs/rand_os - fn from_rng(mut rng: R) -> Result { - let mut seed = Self::Seed::default(); - rng.try_fill_bytes(seed.as_mut())?; - Ok(Self::from_seed(seed)) - } - - /// Creates a new instance of the RNG seeded via [`getrandom`]. - /// - /// This method is the recommended way to construct non-deterministic PRNGs - /// since it is convenient and secure. - /// - /// In case the overhead of using [`getrandom`] to seed *many* PRNGs is an - /// issue, one may prefer to seed from a local PRNG, e.g. - /// `from_rng(thread_rng()).unwrap()`. - /// - /// # Panics - /// - /// If [`getrandom`] is unable to provide secure entropy this method will panic. - /// - /// [`getrandom`]: https://docs.rs/getrandom - #[cfg(feature="getrandom")] - fn from_entropy() -> Self { - let mut seed = Self::Seed::default(); - if let Err(err) = getrandom::getrandom(seed.as_mut()) { - panic!("from_entropy failed: {}", err); - } - Self::from_seed(seed) - } -} - -// Implement `RngCore` for references to an `RngCore`. -// Force inlining all functions, so that it is up to the `RngCore` -// implementation and the optimizer to decide on inlining. -impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R { - #[inline(always)] - fn next_u32(&mut self) -> u32 { - (**self).next_u32() - } - - #[inline(always)] - fn next_u64(&mut self) -> u64 { - (**self).next_u64() - } - - #[inline(always)] - fn fill_bytes(&mut self, dest: &mut [u8]) { - (**self).fill_bytes(dest) - } - - #[inline(always)] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - (**self).try_fill_bytes(dest) - } -} - -// Implement `RngCore` for boxed references to an `RngCore`. -// Force inlining all functions, so that it is up to the `RngCore` -// implementation and the optimizer to decide on inlining. -#[cfg(feature="alloc")] -impl RngCore for Box { - #[inline(always)] - fn next_u32(&mut self) -> u32 { - (**self).next_u32() - } - - #[inline(always)] - fn next_u64(&mut self) -> u64 { - (**self).next_u64() - } - - #[inline(always)] - fn fill_bytes(&mut self, dest: &mut [u8]) { - (**self).fill_bytes(dest) - } - - #[inline(always)] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - (**self).try_fill_bytes(dest) - } -} - -#[cfg(feature="std")] -impl std::io::Read for dyn RngCore { - fn read(&mut self, buf: &mut [u8]) -> Result { - self.try_fill_bytes(buf)?; - Ok(buf.len()) - } -} - -// Implement `CryptoRng` for references to an `CryptoRng`. -impl<'a, R: CryptoRng + ?Sized> CryptoRng for &'a mut R {} - -// Implement `CryptoRng` for boxed references to an `CryptoRng`. -#[cfg(feature="alloc")] -impl CryptoRng for Box {} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_seed_from_u64() { - struct SeedableNum(u64); - impl SeedableRng for SeedableNum { - type Seed = [u8; 8]; - fn from_seed(seed: Self::Seed) -> Self { - let mut x = [0u64; 1]; - le::read_u64_into(&seed, &mut x); - SeedableNum(x[0]) - } - } - - const N: usize = 8; - const SEEDS: [u64; N] = [0u64, 1, 2, 3, 4, 8, 16, -1i64 as u64]; - let mut results = [0u64; N]; - for (i, seed) in SEEDS.iter().enumerate() { - let SeedableNum(x) = SeedableNum::seed_from_u64(*seed); - results[i] = x; - } - - for (i1, r1) in results.iter().enumerate() { - let weight = r1.count_ones(); - // This is the binomial distribution B(64, 0.5), so chance of - // weight < 20 is binocdf(19, 64, 0.5) = 7.8e-4, and same for - // weight > 44. - assert!(weight >= 20 && weight <= 44); - - for (i2, r2) in results.iter().enumerate() { - if i1 == i2 { continue; } - let diff_weight = (r1 ^ r2).count_ones(); - assert!(diff_weight >= 20); - } - } - - // value-breakage test: - assert_eq!(results[0], 5029875928683246316); - } -} diff -Nru cargo-0.58.0/vendor/rand_core-0.5.1/src/os.rs cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/os.rs --- cargo-0.58.0/vendor/rand_core-0.5.1/src/os.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_core-0.5.1/src/os.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -// Copyright 2019 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Interface to the random number generator of the operating system. -// Note: keep this code in sync with the rand_os crate! - -use getrandom::getrandom; -use crate::{CryptoRng, RngCore, Error, impls}; - -/// A random number generator that retrieves randomness from from the -/// operating system. -/// -/// This is a zero-sized struct. It can be freely constructed with `OsRng`. -/// -/// The implementation is provided by the [getrandom] crate. Refer to -/// [getrandom] documentation for details. -/// -/// This struct is only available when specifying the crate feature `getrandom` -/// or `std`. When using the `rand` lib, it is also available as `rand::rngs::OsRng`. -/// -/// # Blocking and error handling -/// -/// It is possible that when used during early boot the first call to `OsRng` -/// will block until the system's RNG is initialised. It is also possible -/// (though highly unlikely) for `OsRng` to fail on some platforms, most -/// likely due to system mis-configuration. -/// -/// After the first successful call, it is highly unlikely that failures or -/// significant delays will occur (although performance should be expected to -/// be much slower than a user-space PRNG). -/// -/// # Usage example -/// ``` -/// use rand_core::{RngCore, OsRng}; -/// -/// let mut key = [0u8; 16]; -/// OsRng.fill_bytes(&mut key); -/// let random_u64 = OsRng.next_u64(); -/// ``` -/// -/// [getrandom]: https://crates.io/crates/getrandom -#[derive(Clone, Copy, Debug, Default)] -pub struct OsRng; - -impl CryptoRng for OsRng {} - -impl RngCore for OsRng { - fn next_u32(&mut self) -> u32 { - impls::next_u32_via_fill(self) - } - - fn next_u64(&mut self) -> u64 { - impls::next_u64_via_fill(self) - } - - fn fill_bytes(&mut self, dest: &mut [u8]) { - if let Err(e) = self.try_fill_bytes(dest) { - panic!("Error: {}", e); - } - } - - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - getrandom(dest)?; - Ok(()) - } -} - -#[test] -fn test_os_rng() { - let x = OsRng.next_u64(); - let y = OsRng.next_u64(); - assert!(x != 0); - assert!(x != y); -} - -#[test] -fn test_construction() { - let mut rng = OsRng::default(); - assert!(rng.next_u64() != 0); -} diff -Nru cargo-0.58.0/vendor/rand_hc/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/rand_hc/.cargo-checksum.json --- cargo-0.58.0/vendor/rand_hc/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_hc/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -{"files":{},"package":"d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/rand_hc/Cargo.toml cargo-0.60.0ubuntu1/vendor/rand_hc/Cargo.toml --- cargo-0.58.0/vendor/rand_hc/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_hc/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - -[package] -edition = "2018" -name = "rand_hc" -version = "0.3.1" -authors = ["The Rand Project Developers"] -description = "HC128 random number generator\n" -homepage = "https://rust-random.github.io/book" -documentation = "https://docs.rs/rand_hc" -readme = "README.md" -keywords = ["random", "rng", "hc128"] -categories = ["algorithms", "no-std"] -license = "MIT OR Apache-2.0" -repository = "https://github.com/rust-random/rand" -[dependencies.rand_core] -version = "0.6.0" diff -Nru cargo-0.58.0/vendor/rand_hc/CHANGELOG.md cargo-0.60.0ubuntu1/vendor/rand_hc/CHANGELOG.md --- cargo-0.58.0/vendor/rand_hc/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_hc/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [0.3.1] - 2021-06-15 -- Adjust crate links - -## [0.3.0] - 2020-12-08 -- Bump `rand_core` version to 0.6.0 -- Bump MSRV to 1.36 (#1011) -- impl PartialEq+Eq for Hc128Rng and Hc128Core (#979) -- Drop some unsafe code, fixing an unsound internal function (#960) - -## [0.2.0] - 2019-06-12 -- Bump minor crate version since rand_core bump is a breaking change -- Switch to Edition 2018 - -## [0.1.1] - 2019-06-06 - yanked -- Bump `rand_core` version -- Adjust usage of `#[inline]` - -## [0.1.0] - 2018-10-17 -- Pulled out of the Rand crate diff -Nru cargo-0.58.0/vendor/rand_hc/COPYRIGHT cargo-0.60.0ubuntu1/vendor/rand_hc/COPYRIGHT --- cargo-0.58.0/vendor/rand_hc/COPYRIGHT 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_hc/COPYRIGHT 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -Copyrights in the Rand project are retained by their contributors. No -copyright assignment is required to contribute to the Rand project. - -For full authorship information, see the version control history. - -Except as otherwise noted (below and/or in individual files), Rand is -licensed under the Apache License, Version 2.0 or - or the MIT license - or , at your option. - -The Rand project includes code from the Rust project -published under these same licenses. diff -Nru cargo-0.58.0/vendor/rand_hc/LICENSE-APACHE cargo-0.60.0ubuntu1/vendor/rand_hc/LICENSE-APACHE --- cargo-0.58.0/vendor/rand_hc/LICENSE-APACHE 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_hc/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff -Nru cargo-0.58.0/vendor/rand_hc/LICENSE-MIT cargo-0.60.0ubuntu1/vendor/rand_hc/LICENSE-MIT --- cargo-0.58.0/vendor/rand_hc/LICENSE-MIT 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_hc/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -Copyright 2018 Developers of the Rand project - -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.58.0/vendor/rand_hc/README.md cargo-0.60.0ubuntu1/vendor/rand_hc/README.md --- cargo-0.58.0/vendor/rand_hc/README.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_hc/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -# rand_hc - -[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rand/actions) -[![Latest version](https://img.shields.io/crates/v/rand_hc.svg)](https://crates.io/crates/rand_hc) -[[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) -[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_hc) -[![API](https://docs.rs/rand_hc/badge.svg)](https://docs.rs/rand_hc) -[![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) - -A cryptographically secure random number generator that uses the HC-128 -algorithm. - -HC-128 is a stream cipher designed by Hongjun Wu[^1], that we use as an -RNG. It is selected as one of the "stream ciphers suitable for widespread -adoption" by eSTREAM[^2]. - -Links: - -- [API documentation (master)](https://rust-random.github.io/rand/rand_hc) -- [API documentation (docs.rs)](https://docs.rs/rand_hc) -- [Changelog](https://github.com/rust-random/rand/blob/master/rand_hc/CHANGELOG.md) - -[rand]: https://crates.io/crates/rand -[^1]: Hongjun Wu (2008). ["The Stream Cipher HC-128"]( - http://www.ecrypt.eu.org/stream/p3ciphers/hc/hc128_p3.pdf). - *The eSTREAM Finalists*, LNCS 4986, pp. 39–47, Springer-Verlag. - -[^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( - http://www.ecrypt.eu.org/stream/) - - -## Crate Features - -`rand_hc` is `no_std` compatible. It does not require any functionality -outside of the `core` lib, thus there are no features to configure. - - -# License - -`rand_hc` is distributed under the terms of both the MIT license and the -Apache License (Version 2.0). - -See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and -[COPYRIGHT](COPYRIGHT) for details. diff -Nru cargo-0.58.0/vendor/rand_hc/src/hc128.rs cargo-0.60.0ubuntu1/vendor/rand_hc/src/hc128.rs --- cargo-0.58.0/vendor/rand_hc/src/hc128.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_hc/src/hc128.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,519 +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. - -// Disable some noisy clippy lints. -#![allow(clippy::many_single_char_names)] -#![allow(clippy::identity_op)] -// Disable a lint that cannot be fixed without increasing the MSRV -#![allow(clippy::op_ref)] - -//! The HC-128 random number generator. - -use core::fmt; -use rand_core::block::{BlockRng, BlockRngCore}; -use rand_core::{le, CryptoRng, Error, RngCore, SeedableRng}; - -const SEED_WORDS: usize = 8; // 128 bit key followed by 128 bit iv - -/// A cryptographically secure random number generator that uses the HC-128 -/// algorithm. -/// -/// HC-128 is a stream cipher designed by Hongjun Wu[^1], that we use as an -/// RNG. It is selected as one of the "stream ciphers suitable for widespread -/// adoption" by eSTREAM[^2]. -/// -/// HC-128 is an array based RNG. In this it is similar to RC-4 and ISAAC before -/// it, but those have never been proven cryptographically secure (or have even -/// been significantly compromised, as in the case of RC-4[^5]). -/// -/// Because HC-128 works with simple indexing into a large array and with a few -/// operations that parallelize well, it has very good performance. The size of -/// the array it needs, 4kb, can however be a disadvantage. -/// -/// This implementation is not based on the version of HC-128 submitted to the -/// eSTREAM contest, but on a later version by the author with a few small -/// improvements from December 15, 2009[^3]. -/// -/// HC-128 has no known weaknesses that are easier to exploit than doing a -/// brute-force search of 2128. A very comprehensive analysis of the -/// current state of known attacks / weaknesses of HC-128 is given in *Some -/// Results On Analysis And Implementation Of HC-128 Stream Cipher*[^4]. -/// -/// The average cycle length is expected to be -/// 21024*32+10-1 = 232777. -/// We support seeding with a 256-bit array, which matches the 128-bit key -/// concatenated with a 128-bit IV from the stream cipher. -/// -/// This implementation uses an output buffer of sixteen `u32` words, and uses -/// [`BlockRng`] to implement the [`RngCore`] methods. -/// -/// ## References -/// [^1]: Hongjun Wu (2008). ["The Stream Cipher HC-128"]( -/// http://www.ecrypt.eu.org/stream/p3ciphers/hc/hc128_p3.pdf). -/// *The eSTREAM Finalists*, LNCS 4986, pp. 39–47, Springer-Verlag. -/// -/// [^2]: [eSTREAM: the ECRYPT Stream Cipher Project]( -/// http://www.ecrypt.eu.org/stream/) -/// -/// [^3]: Hongjun Wu, [Stream Ciphers HC-128 and HC-256]( -/// https://www.ntu.edu.sg/home/wuhj/research/hc/index.html) -/// -/// [^4]: Shashwat Raizada (January 2015),["Some Results On Analysis And -/// Implementation Of HC-128 Stream Cipher"]( -/// http://library.isical.ac.in:8080/jspui/bitstream/123456789/6636/1/TH431.pdf). -/// -/// [^5]: Internet Engineering Task Force (February 2015), -/// ["Prohibiting RC4 Cipher Suites"](https://tools.ietf.org/html/rfc7465). -#[derive(Clone, Debug)] -pub struct Hc128Rng(BlockRng); - -impl RngCore for Hc128Rng { - #[inline] - fn next_u32(&mut self) -> u32 { - self.0.next_u32() - } - - #[inline] - fn next_u64(&mut self) -> u64 { - self.0.next_u64() - } - - #[inline] - fn fill_bytes(&mut self, dest: &mut [u8]) { - self.0.fill_bytes(dest) - } - - #[inline] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.0.try_fill_bytes(dest) - } -} - -impl SeedableRng for Hc128Rng { - type Seed = ::Seed; - - #[inline] - fn from_seed(seed: Self::Seed) -> Self { - Hc128Rng(BlockRng::::from_seed(seed)) - } - - #[inline] - fn from_rng(rng: R) -> Result { - BlockRng::::from_rng(rng).map(Hc128Rng) - } -} - -impl CryptoRng for Hc128Rng {} - -impl PartialEq for Hc128Rng { - fn eq(&self, rhs: &Self) -> bool { - self.0.core == rhs.0.core && self.0.index() == rhs.0.index() - } -} -impl Eq for Hc128Rng {} - -/// The core of `Hc128Rng`, used with `BlockRng`. -#[derive(Clone)] -pub struct Hc128Core { - t: [u32; 1024], - counter1024: usize, -} - -// Custom Debug implementation that does not expose the internal state -impl fmt::Debug for Hc128Core { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "Hc128Core {{}}") - } -} - -impl BlockRngCore for Hc128Core { - type Item = u32; - type Results = [u32; 16]; - - fn generate(&mut self, results: &mut Self::Results) { - assert!(self.counter1024 % 16 == 0); - - let cc = self.counter1024 % 512; - let dd = (cc + 16) % 512; - let ee = cc.wrapping_sub(16) % 512; - // These asserts let the compiler optimize out the bounds checks. - // Some of them may be superflous, and that's fine: - // they'll be optimized out if that's the case. - assert!(ee + 15 < 512); - assert!(cc + 15 < 512); - assert!(dd < 512); - - if self.counter1024 & 512 == 0 { - // P block - results[0] = self.step_p(cc+0, cc+1, ee+13, ee+6, ee+4); - results[1] = self.step_p(cc+1, cc+2, ee+14, ee+7, ee+5); - results[2] = self.step_p(cc+2, cc+3, ee+15, ee+8, ee+6); - results[3] = self.step_p(cc+3, cc+4, cc+0, ee+9, ee+7); - results[4] = self.step_p(cc+4, cc+5, cc+1, ee+10, ee+8); - results[5] = self.step_p(cc+5, cc+6, cc+2, ee+11, ee+9); - results[6] = self.step_p(cc+6, cc+7, cc+3, ee+12, ee+10); - results[7] = self.step_p(cc+7, cc+8, cc+4, ee+13, ee+11); - results[8] = self.step_p(cc+8, cc+9, cc+5, ee+14, ee+12); - results[9] = self.step_p(cc+9, cc+10, cc+6, ee+15, ee+13); - results[10] = self.step_p(cc+10, cc+11, cc+7, cc+0, ee+14); - results[11] = self.step_p(cc+11, cc+12, cc+8, cc+1, ee+15); - results[12] = self.step_p(cc+12, cc+13, cc+9, cc+2, cc+0); - results[13] = self.step_p(cc+13, cc+14, cc+10, cc+3, cc+1); - results[14] = self.step_p(cc+14, cc+15, cc+11, cc+4, cc+2); - results[15] = self.step_p(cc+15, dd+0, cc+12, cc+5, cc+3); - } else { - // Q block - results[0] = self.step_q(cc+0, cc+1, ee+13, ee+6, ee+4); - results[1] = self.step_q(cc+1, cc+2, ee+14, ee+7, ee+5); - results[2] = self.step_q(cc+2, cc+3, ee+15, ee+8, ee+6); - results[3] = self.step_q(cc+3, cc+4, cc+0, ee+9, ee+7); - results[4] = self.step_q(cc+4, cc+5, cc+1, ee+10, ee+8); - results[5] = self.step_q(cc+5, cc+6, cc+2, ee+11, ee+9); - results[6] = self.step_q(cc+6, cc+7, cc+3, ee+12, ee+10); - results[7] = self.step_q(cc+7, cc+8, cc+4, ee+13, ee+11); - results[8] = self.step_q(cc+8, cc+9, cc+5, ee+14, ee+12); - results[9] = self.step_q(cc+9, cc+10, cc+6, ee+15, ee+13); - results[10] = self.step_q(cc+10, cc+11, cc+7, cc+0, ee+14); - results[11] = self.step_q(cc+11, cc+12, cc+8, cc+1, ee+15); - results[12] = self.step_q(cc+12, cc+13, cc+9, cc+2, cc+0); - results[13] = self.step_q(cc+13, cc+14, cc+10, cc+3, cc+1); - results[14] = self.step_q(cc+14, cc+15, cc+11, cc+4, cc+2); - results[15] = self.step_q(cc+15, dd+0, cc+12, cc+5, cc+3); - } - self.counter1024 = self.counter1024.wrapping_add(16); - } -} - -impl Hc128Core { - // One step of HC-128, update P and generate 32 bits keystream - #[inline(always)] - fn step_p(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) -> u32 { - let (p, q) = self.t.split_at_mut(512); - let temp0 = p[i511].rotate_right(23); - let temp1 = p[i3].rotate_right(10); - let temp2 = p[i10].rotate_right(8); - p[i] = p[i] - .wrapping_add(temp2) - .wrapping_add(temp0 ^ temp1); - let temp3 = { - // The h1 function in HC-128 - let a = p[i12] as u8; - let c = (p[i12] >> 16) as u8; - q[a as usize].wrapping_add(q[256 + c as usize]) - }; - temp3 ^ p[i] - } - - // One step of HC-128, update Q and generate 32 bits keystream - // Similar to `step_p`, but `p` and `q` are swapped, and the rotates are to - // the left instead of to the right. - #[inline(always)] - fn step_q(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) -> u32 { - let (p, q) = self.t.split_at_mut(512); - let temp0 = q[i511].rotate_left(23); - let temp1 = q[i3].rotate_left(10); - let temp2 = q[i10].rotate_left(8); - q[i] = q - [i] - .wrapping_add(temp2) - .wrapping_add(temp0 ^ temp1); - let temp3 = { - // The h2 function in HC-128 - let a = q[i12] as u8; - let c = (q[i12] >> 16) as u8; - p[a as usize].wrapping_add(p[256 + c as usize]) - }; - temp3 ^ q[i] - } - - fn sixteen_steps(&mut self) { - assert!(self.counter1024 % 16 == 0); - - let cc = self.counter1024 % 512; - let dd = (cc + 16) % 512; - let ee = cc.wrapping_sub(16) % 512; - // These asserts let the compiler optimize out the bounds checks. - // Some of them may be superflous, and that's fine: - // they'll be optimized out if that's the case. - assert!(ee + 15 < 512); - assert!(cc + 15 < 512); - assert!(dd < 512); - - if self.counter1024 < 512 { - // P block - self.t[cc+0] = self.step_p(cc+0, cc+1, ee+13, ee+6, ee+4); - self.t[cc+1] = self.step_p(cc+1, cc+2, ee+14, ee+7, ee+5); - self.t[cc+2] = self.step_p(cc+2, cc+3, ee+15, ee+8, ee+6); - self.t[cc+3] = self.step_p(cc+3, cc+4, cc+0, ee+9, ee+7); - self.t[cc+4] = self.step_p(cc+4, cc+5, cc+1, ee+10, ee+8); - self.t[cc+5] = self.step_p(cc+5, cc+6, cc+2, ee+11, ee+9); - self.t[cc+6] = self.step_p(cc+6, cc+7, cc+3, ee+12, ee+10); - self.t[cc+7] = self.step_p(cc+7, cc+8, cc+4, ee+13, ee+11); - self.t[cc+8] = self.step_p(cc+8, cc+9, cc+5, ee+14, ee+12); - self.t[cc+9] = self.step_p(cc+9, cc+10, cc+6, ee+15, ee+13); - self.t[cc+10] = self.step_p(cc+10, cc+11, cc+7, cc+0, ee+14); - self.t[cc+11] = self.step_p(cc+11, cc+12, cc+8, cc+1, ee+15); - self.t[cc+12] = self.step_p(cc+12, cc+13, cc+9, cc+2, cc+0); - self.t[cc+13] = self.step_p(cc+13, cc+14, cc+10, cc+3, cc+1); - self.t[cc+14] = self.step_p(cc+14, cc+15, cc+11, cc+4, cc+2); - self.t[cc+15] = self.step_p(cc+15, dd+0, cc+12, cc+5, cc+3); - } else { - // Q block - self.t[cc+512+0] = self.step_q(cc+0, cc+1, ee+13, ee+6, ee+4); - self.t[cc+512+1] = self.step_q(cc+1, cc+2, ee+14, ee+7, ee+5); - self.t[cc+512+2] = self.step_q(cc+2, cc+3, ee+15, ee+8, ee+6); - self.t[cc+512+3] = self.step_q(cc+3, cc+4, cc+0, ee+9, ee+7); - self.t[cc+512+4] = self.step_q(cc+4, cc+5, cc+1, ee+10, ee+8); - self.t[cc+512+5] = self.step_q(cc+5, cc+6, cc+2, ee+11, ee+9); - self.t[cc+512+6] = self.step_q(cc+6, cc+7, cc+3, ee+12, ee+10); - self.t[cc+512+7] = self.step_q(cc+7, cc+8, cc+4, ee+13, ee+11); - self.t[cc+512+8] = self.step_q(cc+8, cc+9, cc+5, ee+14, ee+12); - self.t[cc+512+9] = self.step_q(cc+9, cc+10, cc+6, ee+15, ee+13); - self.t[cc+512+10] = self.step_q(cc+10, cc+11, cc+7, cc+0, ee+14); - self.t[cc+512+11] = self.step_q(cc+11, cc+12, cc+8, cc+1, ee+15); - self.t[cc+512+12] = self.step_q(cc+12, cc+13, cc+9, cc+2, cc+0); - self.t[cc+512+13] = self.step_q(cc+13, cc+14, cc+10, cc+3, cc+1); - self.t[cc+512+14] = self.step_q(cc+14, cc+15, cc+11, cc+4, cc+2); - self.t[cc+512+15] = self.step_q(cc+15, dd+0, cc+12, cc+5, cc+3); - } - self.counter1024 += 16; - } - - // Initialize an HC-128 random number generator. The seed has to be - // 256 bits in length (`[u32; 8]`), matching the 128 bit `key` followed by - // 128 bit `iv` when HC-128 where to be used as a stream cipher. - #[inline(always)] // single use: SeedableRng::from_seed - fn init(seed: [u32; SEED_WORDS]) -> Self { - #[inline] - fn f1(x: u32) -> u32 { - x.rotate_right(7) ^ x.rotate_right(18) ^ (x >> 3) - } - - #[inline] - fn f2(x: u32) -> u32 { - x.rotate_right(17) ^ x.rotate_right(19) ^ (x >> 10) - } - - let mut t = [0u32; 1024]; - - // Expand the key and iv into P and Q - let (key, iv) = seed.split_at(4); - t[..4].copy_from_slice(key); - t[4..8].copy_from_slice(key); - t[8..12].copy_from_slice(iv); - t[12..16].copy_from_slice(iv); - - // Generate the 256 intermediate values W[16] ... W[256+16-1], and - // copy the last 16 generated values to the start op P. - for i in 16..256 + 16 { - t[i] = f2(t[i - 2]) - .wrapping_add(t[i - 7]) - .wrapping_add(f1(t[i - 15])) - .wrapping_add(t[i - 16]) - .wrapping_add(i as u32); - } - { - let (p1, p2) = t.split_at_mut(256); - p1[0..16].copy_from_slice(&p2[0..16]); - } - - // Generate both the P and Q tables - for i in 16..1024 { - t[i] = f2(t[i - 2]) - .wrapping_add(t[i - 7]) - .wrapping_add(f1(t[i - 15])) - .wrapping_add(t[i - 16]) - .wrapping_add(256 + i as u32); - } - - let mut core = Self { t, counter1024: 0 }; - - // run the cipher 1024 steps - for _ in 0..64 { - core.sixteen_steps() - } - core.counter1024 = 0; - core - } -} - -impl SeedableRng for Hc128Core { - type Seed = [u8; SEED_WORDS * 4]; - - /// Create an HC-128 random number generator with a seed. The seed has to be - /// 256 bits in length, matching the 128 bit `key` followed by 128 bit `iv` - /// when HC-128 where to be used as a stream cipher. - fn from_seed(seed: Self::Seed) -> Self { - let mut seed_u32 = [0u32; SEED_WORDS]; - le::read_u32_into(&seed, &mut seed_u32); - Self::init(seed_u32) - } -} - -impl CryptoRng for Hc128Core {} - -// Custom PartialEq implementation as it can't currently be derived from an array of size 1024 -impl PartialEq for Hc128Core { - fn eq(&self, rhs: &Self) -> bool { - &self.t[..] == &rhs.t[..] && self.counter1024 == rhs.counter1024 - } -} -impl Eq for Hc128Core {} - -#[cfg(test)] -mod test { - use super::Hc128Rng; - use ::rand_core::{RngCore, SeedableRng}; - - #[test] - // Test vector 1 from the paper "The Stream Cipher HC-128" - fn test_hc128_true_values_a() { - #[rustfmt::skip] - let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv - let mut rng = Hc128Rng::from_seed(seed); - - let mut results = [0u32; 16]; - for i in results.iter_mut() { - *i = rng.next_u32(); - } - #[rustfmt::skip] - let expected = [0x73150082, 0x3bfd03a0, 0xfb2fd77f, 0xaa63af0e, - 0xde122fc6, 0xa7dc29b6, 0x62a68527, 0x8b75ec68, - 0x9036db1e, 0x81896005, 0x00ade078, 0x491fbf9a, - 0x1cdc3013, 0x6c3d6e24, 0x90f664b2, 0x9cd57102]; - assert_eq!(results, expected); - } - - #[test] - // Test vector 2 from the paper "The Stream Cipher HC-128" - fn test_hc128_true_values_b() { - #[rustfmt::skip] - let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key - 1,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv - let mut rng = Hc128Rng::from_seed(seed); - - let mut results = [0u32; 16]; - for i in results.iter_mut() { - *i = rng.next_u32(); - } - #[rustfmt::skip] - let expected = [0xc01893d5, 0xb7dbe958, 0x8f65ec98, 0x64176604, - 0x36fc6724, 0xc82c6eec, 0x1b1c38a7, 0xc9b42a95, - 0x323ef123, 0x0a6a908b, 0xce757b68, 0x9f14f7bb, - 0xe4cde011, 0xaeb5173f, 0x89608c94, 0xb5cf46ca]; - assert_eq!(results, expected); - } - - #[test] - // Test vector 3 from the paper "The Stream Cipher HC-128" - fn test_hc128_true_values_c() { - #[rustfmt::skip] - let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv - let mut rng = Hc128Rng::from_seed(seed); - - let mut results = [0u32; 16]; - for i in results.iter_mut() { - *i = rng.next_u32(); - } - #[rustfmt::skip] - let expected = [0x518251a4, 0x04b4930a, 0xb02af931, 0x0639f032, - 0xbcb4a47a, 0x5722480b, 0x2bf99f72, 0xcdc0e566, - 0x310f0c56, 0xd3cc83e8, 0x663db8ef, 0x62dfe07f, - 0x593e1790, 0xc5ceaa9c, 0xab03806f, 0xc9a6e5a0]; - assert_eq!(results, expected); - } - - #[test] - fn test_hc128_true_values_u64() { - #[rustfmt::skip] - let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv - let mut rng = Hc128Rng::from_seed(seed); - - let mut results = [0u64; 8]; - for i in results.iter_mut() { - *i = rng.next_u64(); - } - #[rustfmt::skip] - let expected = [0x3bfd03a073150082, 0xaa63af0efb2fd77f, - 0xa7dc29b6de122fc6, 0x8b75ec6862a68527, - 0x818960059036db1e, 0x491fbf9a00ade078, - 0x6c3d6e241cdc3013, 0x9cd5710290f664b2]; - assert_eq!(results, expected); - - // The RNG operates in a P block of 512 results and next a Q block. - // After skipping 2*800 u32 results we end up somewhere in the Q block - // of the second round - for _ in 0..800 { - rng.next_u64(); - } - - for i in results.iter_mut() { - *i = rng.next_u64(); - } - #[rustfmt::skip] - let expected = [0xd8c4d6ca84d0fc10, 0xf16a5d91dc66e8e7, - 0xd800de5bc37a8653, 0x7bae1f88c0dfbb4c, - 0x3bfe1f374e6d4d14, 0x424b55676be3fa06, - 0xe3a1e8758cbff579, 0x417f7198c5652bcd]; - assert_eq!(results, expected); - } - - #[test] - fn test_hc128_true_values_bytes() { - #[rustfmt::skip] - let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv - let mut rng = Hc128Rng::from_seed(seed); - #[rustfmt::skip] - let expected = [0x31, 0xf9, 0x2a, 0xb0, 0x32, 0xf0, 0x39, 0x06, - 0x7a, 0xa4, 0xb4, 0xbc, 0x0b, 0x48, 0x22, 0x57, - 0x72, 0x9f, 0xf9, 0x2b, 0x66, 0xe5, 0xc0, 0xcd, - 0x56, 0x0c, 0x0f, 0x31, 0xe8, 0x83, 0xcc, 0xd3, - 0xef, 0xb8, 0x3d, 0x66, 0x7f, 0xe0, 0xdf, 0x62, - 0x90, 0x17, 0x3e, 0x59, 0x9c, 0xaa, 0xce, 0xc5, - 0x6f, 0x80, 0x03, 0xab, 0xa0, 0xe5, 0xa6, 0xc9, - 0x60, 0x95, 0x84, 0x7a, 0xa5, 0x68, 0x5a, 0x84, - 0xea, 0xd5, 0xf3, 0xea, 0x73, 0xa9, 0xad, 0x01, - 0x79, 0x7d, 0xbe, 0x9f, 0xea, 0xe3, 0xf9, 0x74, - 0x0e, 0xda, 0x2f, 0xa0, 0xe4, 0x7b, 0x4b, 0x1b, - 0xdd, 0x17, 0x69, 0x4a, 0xfe, 0x9f, 0x56, 0x95, - 0xad, 0x83, 0x6b, 0x9d, 0x60, 0xa1, 0x99, 0x96, - 0x90, 0x00, 0x66, 0x7f, 0xfa, 0x7e, 0x65, 0xe9, - 0xac, 0x8b, 0x92, 0x34, 0x77, 0xb4, 0x23, 0xd0, - 0xb9, 0xab, 0xb1, 0x47, 0x7d, 0x4a, 0x13, 0x0a]; - - // Pick a somewhat large buffer so we can test filling with the - // remainder from `state.results`, directly filling the buffer, and - // filling the remainder of the buffer. - let mut buffer = [0u8; 16 * 4 * 2]; - // Consume a value so that we have a remainder. - assert!(rng.next_u64() == 0x04b4930a518251a4); - rng.fill_bytes(&mut buffer); - - // [u8; 128] doesn't implement PartialEq - assert_eq!(buffer.len(), expected.len()); - for (b, e) in buffer.iter().zip(expected.iter()) { - assert_eq!(b, e); - } - } - - #[test] - fn test_hc128_clone() { - #[rustfmt::skip] - let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv - let mut rng1 = Hc128Rng::from_seed(seed); - let mut rng2 = rng1.clone(); - for _ in 0..16 { - assert_eq!(rng1.next_u32(), rng2.next_u32()); - } - } -} diff -Nru cargo-0.58.0/vendor/rand_hc/src/lib.rs cargo-0.60.0ubuntu1/vendor/rand_hc/src/lib.rs --- cargo-0.58.0/vendor/rand_hc/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/rand_hc/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The HC128 random number generator. - -#![doc( - html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://rust-random.github.io/rand/" -)] -#![deny(missing_docs)] -#![deny(missing_debug_implementations)] -#![doc(test(attr(allow(unused_variables), deny(warnings))))] -#![no_std] - -mod hc128; - -pub use hc128::{Hc128Core, Hc128Rng}; diff -Nru cargo-0.58.0/vendor/redox_syscall/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/redox_syscall/.cargo-checksum.json --- cargo-0.58.0/vendor/redox_syscall/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"} \ No newline at end of file +{"files":{},"package":"62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/redox_syscall/Cargo.toml cargo-0.60.0ubuntu1/vendor/redox_syscall/Cargo.toml --- cargo-0.58.0/vendor/redox_syscall/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "redox_syscall" -version = "0.2.10" +version = "0.2.13" authors = ["Jeremy Soller "] description = "A Rust library to access raw Redox system calls" documentation = "https://docs.rs/redox_syscall" @@ -21,5 +21,6 @@ [lib] name = "syscall" + [dependencies.bitflags] version = "1.1.0" diff -Nru cargo-0.58.0/vendor/redox_syscall/debian/patches/no-nightly.patch cargo-0.60.0ubuntu1/vendor/redox_syscall/debian/patches/no-nightly.patch --- cargo-0.58.0/vendor/redox_syscall/debian/patches/no-nightly.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/debian/patches/no-nightly.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,43 @@ +diff --git a/build.rs b/build.rs +new file mode 100644 +index 0000000..ca906fa +--- /dev/null ++++ b/build.rs +@@ -0,0 +1,9 @@ ++use std::env; ++ ++pub fn main() { ++ if let Ok(os) = env::var("CARGO_CFG_TARGET_OS") { ++ if os == "redox" { ++ println!("cargo:rustc-cfg=nightly"); ++ } ++ } ++} +diff --git a/src/lib.rs b/src/lib.rs +index 6b8d130..42526f0 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -1,5 +1,5 @@ +-#![feature(llvm_asm)] +-#![feature(const_fn)] ++#![cfg_attr(nightly, feature(llvm_asm))] ++#![cfg_attr(nightly, feature(const_fn))] + #![cfg_attr(not(test), no_std)] + + #[cfg(test)] +@@ -10,6 +10,7 @@ pub use self::call::*; + pub use self::data::*; + pub use self::error::*; + pub use self::flag::*; ++#[cfg(target_os = "redox")] + pub use self::io::*; + pub use self::number::*; + pub use self::scheme::*; +@@ -47,6 +48,7 @@ pub mod error; + pub mod flag; + + /// Functions for low level hardware control ++#[cfg(target_os = "redox")] + pub mod io; + + /// Call numbers used by each system call diff -Nru cargo-0.58.0/vendor/redox_syscall/src/arch/aarch64.rs cargo-0.60.0ubuntu1/vendor/redox_syscall/src/arch/aarch64.rs --- cargo-0.58.0/vendor/redox_syscall/src/arch/aarch64.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/src/arch/aarch64.rs 2022-04-20 13:48:09.000000000 +0000 @@ -9,7 +9,7 @@ pub unsafe fn $name($a: usize, $($b: usize, $($c: usize, $($d: usize, $($e: usize, $($f: usize)?)?)?)?)?) -> Result { let ret: usize; - asm!( + core::arch::asm!( "svc 0", in("x8") $a, $( diff -Nru cargo-0.58.0/vendor/redox_syscall/src/arch/arm.rs cargo-0.60.0ubuntu1/vendor/redox_syscall/src/arch/arm.rs --- cargo-0.58.0/vendor/redox_syscall/src/arch/arm.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/src/arch/arm.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -use super::error::{Error, Result}; - -pub unsafe fn syscall0(mut a: usize) -> Result { - llvm_asm!("swi $$0" - : "={r0}"(a) - : "{r7}"(a) - : "memory" - : "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall1(mut a: usize, b: usize) -> Result { - llvm_asm!("swi $$0" - : "={r0}"(a) - : "{r7}"(a), "{r0}"(b) - : "memory" - : "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result { - llvm_asm!("swi $$0" - : "={r0}"(a) - : "{r7}"(a), "{r0}"(b), "{r1}"(c) - : "memory" - : "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result { - llvm_asm!("swi $$0" - : "={r0}"(a) - : "{r7}"(a), "{r0}"(b), "{r1}"(c), "{r2}"(d) - : "memory" - : "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result { - llvm_asm!("swi $$0" - : "={r0}"(a) - : "{r7}"(a), "{r0}"(b), "{r1}"(c), "{r2}"(d), "{r3}"(e) - : "memory" - : "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) - -> Result { - llvm_asm!("swi $$0" - : "={r0}"(a) - : "{r7}"(a), "{r0}"(b), "{r1}"(c), "{r2}"(d), "{r3}"(e), "{r4}"(f) - : "memory" - : "volatile"); - - Error::demux(a) -} diff -Nru cargo-0.58.0/vendor/redox_syscall/src/arch/x86_64.rs cargo-0.60.0ubuntu1/vendor/redox_syscall/src/arch/x86_64.rs --- cargo-0.58.0/vendor/redox_syscall/src/arch/x86_64.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/src/arch/x86_64.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,4 +1,5 @@ use core::{mem, slice}; +use core::arch::asm; use core::ops::{Deref, DerefMut}; use super::error::{Error, Result}; diff -Nru cargo-0.58.0/vendor/redox_syscall/src/arch/x86.rs cargo-0.60.0ubuntu1/vendor/redox_syscall/src/arch/x86.rs --- cargo-0.58.0/vendor/redox_syscall/src/arch/x86.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/src/arch/x86.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -use super::error::{Error, Result}; - -pub unsafe fn syscall0(mut a: usize) -> Result { - llvm_asm!("int 0x80" - : "={eax}"(a) - : "{eax}"(a) - : "memory" - : "intel", "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall1(mut a: usize, b: usize) -> Result { - llvm_asm!("int 0x80" - : "={eax}"(a) - : "{eax}"(a), "{ebx}"(b) - : "memory" - : "intel", "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result { - llvm_asm!("int 0x80" - : "={eax}"(a) - : "{eax}"(a), "{ebx}"(b), "{ecx}"(c) - : "memory" - : "intel", "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result { - llvm_asm!("int 0x80" - : "={eax}"(a) - : "{eax}"(a), "{ebx}"(b), "{ecx}"(c), "{edx}"(d) - : "memory" - : "intel", "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result { - llvm_asm!("int 0x80" - : "={eax}"(a) - : "{eax}"(a), "{ebx}"(b), "{ecx}"(c), "{edx}"(d), "{esi}"(e) - : "memory" - : "intel", "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) - -> Result { - llvm_asm!("int 0x80" - : "={eax}"(a) - : "{eax}"(a), "{ebx}"(b), "{ecx}"(c), "{edx}"(d), "{esi}"(e), "{edi}"(f) - : "memory" - : "intel", "volatile"); - - Error::demux(a) -} diff -Nru cargo-0.58.0/vendor/redox_syscall/src/daemon.rs cargo-0.60.0ubuntu1/vendor/redox_syscall/src/daemon.rs --- cargo-0.58.0/vendor/redox_syscall/src/daemon.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/src/daemon.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,62 @@ +use core::convert::Infallible; + +use super::{ + clone, + CloneFlags, + close, + EIO, + Error, + exit, + pipe2, + read, + Result, + write, +}; + +#[must_use = "Daemon::ready must be called"] +pub struct Daemon { + write_pipe: usize, +} + +impl Daemon { + pub fn new Infallible>(f: F) -> Result { + let mut pipes = [0; 2]; + pipe2(&mut pipes, 0)?; + + let [read_pipe, write_pipe] = pipes; + + if unsafe { clone(CloneFlags::empty())? } == 0 { + let _ = close(read_pipe); + + f(Daemon { + write_pipe, + }); + // TODO: Replace Infallible with the never type once it is stabilized. + unreachable!(); + } else { + let _ = close(write_pipe); + + let mut data = [0]; + let res = read(read_pipe, &mut data); + let _ = close(read_pipe); + + if res? == 1 { + exit(data[0] as usize)?; + unreachable!(); + } else { + Err(Error::new(EIO)) + } + } + } + + pub fn ready(self) -> Result<()> { + let res = write(self.write_pipe, &[0]); + let _ = close(self.write_pipe); + + if res? == 1 { + Ok(()) + } else { + Err(Error::new(EIO)) + } + } +} diff -Nru cargo-0.58.0/vendor/redox_syscall/src/io/mmio.rs cargo-0.60.0ubuntu1/vendor/redox_syscall/src/io/mmio.rs --- cargo-0.58.0/vendor/redox_syscall/src/io/mmio.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/src/io/mmio.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,4 +1,4 @@ -use core::ptr::{read_volatile, write_volatile}; +use core::ptr::{read_volatile, write_volatile, addr_of, addr_of_mut}; use core::mem::MaybeUninit; use core::ops::{BitAnd, BitOr, Not}; @@ -36,10 +36,10 @@ type Value = T; fn read(&self) -> T { - unsafe { read_volatile(self.value.as_ptr()) } + unsafe { read_volatile(addr_of!(self.value).cast::()) } } fn write(&mut self, value: T) { - unsafe { write_volatile(self.value.as_mut_ptr(), value) }; + unsafe { write_volatile(addr_of_mut!(self.value).cast::(), value) }; } } diff -Nru cargo-0.58.0/vendor/redox_syscall/src/io/mod.rs cargo-0.60.0ubuntu1/vendor/redox_syscall/src/io/mod.rs --- cargo-0.58.0/vendor/redox_syscall/src/io/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/src/io/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -3,9 +3,13 @@ pub use self::dma::*; pub use self::io::*; pub use self::mmio::*; + +#[cfg(target_arch = "x86_64")] pub use self::pio::*; mod dma; mod io; mod mmio; + +#[cfg(target_arch = "x86_64")] mod pio; diff -Nru cargo-0.58.0/vendor/redox_syscall/src/io/pio.rs cargo-0.60.0ubuntu1/vendor/redox_syscall/src/io/pio.rs --- cargo-0.58.0/vendor/redox_syscall/src/io/pio.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/src/io/pio.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,4 @@ +use core::arch::asm; use core::marker::PhantomData; use super::io::Io; @@ -13,7 +14,7 @@ /// Create a PIO from a given port pub const fn new(port: u16) -> Self { Pio:: { - port: port, + port, value: PhantomData, } } @@ -28,7 +29,7 @@ fn read(&self) -> u8 { let value: u8; unsafe { - llvm_asm!("in $0, $1" : "={al}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile"); + asm!("in al, dx", in("dx") self.port, out("al") value, options(nostack, nomem, preserves_flags)); } value } @@ -37,7 +38,7 @@ #[inline(always)] fn write(&mut self, value: u8) { unsafe { - llvm_asm!("out $1, $0" : : "{al}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile"); + asm!("out dx, al", in("dx") self.port, in("al") value, options(nostack, nomem, preserves_flags)); } } } @@ -51,7 +52,7 @@ fn read(&self) -> u16 { let value: u16; unsafe { - llvm_asm!("in $0, $1" : "={ax}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile"); + asm!("in ax, dx", in("dx") self.port, out("ax") value, options(nostack, nomem, preserves_flags)); } value } @@ -60,7 +61,7 @@ #[inline(always)] fn write(&mut self, value: u16) { unsafe { - llvm_asm!("out $1, $0" : : "{ax}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile"); + asm!("out dx, ax", in("dx") self.port, in("ax") value, options(nostack, nomem, preserves_flags)); } } } @@ -74,7 +75,7 @@ fn read(&self) -> u32 { let value: u32; unsafe { - llvm_asm!("in $0, $1" : "={eax}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile"); + asm!("in eax, dx", in("dx") self.port, out("eax") value, options(nostack, nomem, preserves_flags)); } value } @@ -83,7 +84,7 @@ #[inline(always)] fn write(&mut self, value: u32) { unsafe { - llvm_asm!("out $1, $0" : : "{eax}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile"); + asm!("out dx, eax", in("dx") self.port, in("eax") value, options(nostack, nomem, preserves_flags)); } } } diff -Nru cargo-0.58.0/vendor/redox_syscall/src/lib.rs cargo-0.60.0ubuntu1/vendor/redox_syscall/src/lib.rs --- cargo-0.58.0/vendor/redox_syscall/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/redox_syscall/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,5 +1,3 @@ -#![feature(asm)] -#![feature(llvm_asm)] #![cfg_attr(not(test), no_std)] #[cfg(test)] @@ -7,6 +5,7 @@ pub use self::arch::*; pub use self::call::*; +pub use self::daemon::*; pub use self::data::*; pub use self::error::*; pub use self::flag::*; @@ -15,7 +14,7 @@ pub use self::scheme::*; #[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "arm"))] -#[path="arch/arm.rs"] +#[path="arch/nonredox.rs"] mod arch; #[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "aarch64"))] @@ -27,7 +26,7 @@ mod arch; #[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "x86"))] -#[path="arch/x86.rs"] +#[path="arch/nonredox.rs"] mod arch; #[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "x86_64"))] @@ -44,6 +43,9 @@ /// Complex structures that are used for some system calls pub mod data; +/// Wrapper to make daemons easier to write +pub mod daemon; + /// All errors that can be generated by a system call pub mod error; diff -Nru cargo-0.58.0/vendor/regex/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/regex/.cargo-checksum.json --- cargo-0.58.0/vendor/regex/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/regex/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"} \ No newline at end of file +{"files":{},"package":"1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/regex/Cargo.lock cargo-0.60.0ubuntu1/vendor/regex/Cargo.lock --- cargo-0.58.0/vendor/regex/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/regex/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -36,9 +36,9 @@ [[package]] name = "libc" -version = "0.2.80" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "memchr" @@ -75,7 +75,7 @@ [[package]] name = "regex" -version = "1.5.4" +version = "1.5.5" dependencies = [ "aho-corasick", "lazy_static", diff -Nru cargo-0.58.0/vendor/regex/Cargo.toml cargo-0.60.0ubuntu1/vendor/regex/Cargo.toml --- cargo-0.58.0/vendor/regex/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/regex/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -3,27 +3,33 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "regex" -version = "1.5.4" +version = "1.5.5" authors = ["The Rust Project Developers"] -exclude = ["/scripts/*", "/.github/*"] +exclude = [ + "/scripts/*", + "/.github/*", +] autotests = false -description = "An implementation of regular expressions for Rust. This implementation uses\nfinite automata and guarantees linear time matching on all inputs.\n" +description = """ +An implementation of regular expressions for Rust. This implementation uses +finite automata and guarantees linear time matching on all inputs. +""" homepage = "https://github.com/rust-lang/regex" documentation = "https://docs.rs/regex" readme = "README.md" categories = ["text-processing"] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/regex" + [profile.bench] debug = true @@ -72,8 +78,9 @@ [[test]] name = "crates-regex" path = "tests/test_crates_regex.rs" + [dependencies.aho-corasick] -version = "0.7.18" +version = "0.7" optional = true [dependencies.memchr] @@ -83,28 +90,54 @@ [dependencies.regex-syntax] version = "0.6.25" default-features = false + [dev-dependencies.lazy_static] version = "1" [dev-dependencies.quickcheck] -version = "1.0.3" +version = "1" default-features = false [dev-dependencies.rand] -version = "0.8.3" -features = ["getrandom", "small_rng"] +version = "0.7" +features = [ + "getrandom", + "small_rng", +] default-features = false [features] -default = ["std", "perf", "unicode", "regex-syntax/default"] +default = [ + "std", + "perf", + "unicode", + "regex-syntax/default", +] pattern = [] -perf = ["perf-cache", "perf-dfa", "perf-inline", "perf-literal"] +perf = [ + "perf-cache", + "perf-dfa", + "perf-inline", + "perf-literal", +] perf-cache = [] perf-dfa = [] perf-inline = [] -perf-literal = ["aho-corasick", "memchr"] +perf-literal = [ + "aho-corasick", + "memchr", +] std = [] -unicode = ["unicode-age", "unicode-bool", "unicode-case", "unicode-gencat", "unicode-perl", "unicode-script", "unicode-segment", "regex-syntax/unicode"] +unicode = [ + "unicode-age", + "unicode-bool", + "unicode-case", + "unicode-gencat", + "unicode-perl", + "unicode-script", + "unicode-segment", + "regex-syntax/unicode", +] unicode-age = ["regex-syntax/unicode-age"] unicode-bool = ["regex-syntax/unicode-bool"] unicode-case = ["regex-syntax/unicode-case"] diff -Nru cargo-0.58.0/vendor/regex/debian/patches/relax-test-dep.diff cargo-0.60.0ubuntu1/vendor/regex/debian/patches/relax-test-dep.diff --- cargo-0.58.0/vendor/regex/debian/patches/relax-test-dep.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/regex/debian/patches/relax-test-dep.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,27 @@ +Index: regex/Cargo.toml +=================================================================== +--- regex.orig/Cargo.toml ++++ regex/Cargo.toml +@@ -80,7 +80,7 @@ name = "crates-regex" + path = "tests/test_crates_regex.rs" + + [dependencies.aho-corasick] +-version = "0.7.18" ++version = "0.7" + optional = true + + [dependencies.memchr] +@@ -95,11 +95,11 @@ default-features = false + version = "1" + + [dev-dependencies.quickcheck] +-version = "1.0.3" ++version = "1" + default-features = false + + [dev-dependencies.rand] +-version = "0.8.3" ++version = "0.7" + features = [ + "getrandom", + "small_rng", diff -Nru cargo-0.58.0/vendor/regex/debian/patches/series cargo-0.60.0ubuntu1/vendor/regex/debian/patches/series --- cargo-0.58.0/vendor/regex/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/regex/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1 @@ +relax-test-dep.diff diff -Nru cargo-0.58.0/vendor/regex/README.md cargo-0.60.0ubuntu1/vendor/regex/README.md --- cargo-0.58.0/vendor/regex/README.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/regex/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -8,7 +8,7 @@ by [RE2](https://github.com/google/re2). [![Build status](https://github.com/rust-lang/regex/workflows/ci/badge.svg)](https://github.com/rust-lang/regex/actions) -[![](https://meritbadge.herokuapp.com/regex)](https://crates.io/crates/regex) +[![Crates.io](https://img.shields.io/crates/v/regex.svg)](https://crates.io/crates/regex) [![Rust](https://img.shields.io/badge/rust-1.41.1%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/regex) ### Documentation diff -Nru cargo-0.58.0/vendor/regex/src/compile.rs cargo-0.60.0ubuntu1/vendor/regex/src/compile.rs --- cargo-0.58.0/vendor/regex/src/compile.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/regex/src/compile.rs 2022-04-20 13:48:09.000000000 +0000 @@ -38,6 +38,16 @@ suffix_cache: SuffixCache, utf8_seqs: Option, byte_classes: ByteClassSet, + // This keeps track of extra bytes allocated while compiling the regex + // program. Currently, this corresponds to two things. First is the heap + // memory allocated by Unicode character classes ('InstRanges'). Second is + // a "fake" amount of memory used by empty sub-expressions, so that enough + // empty sub-expressions will ultimately trigger the compiler to bail + // because of a size limit restriction. (That empty sub-expressions don't + // add to heap memory usage is more-or-less an implementation detail.) In + // the second case, if we don't bail, then an excessively large repetition + // on an empty sub-expression can result in the compiler using a very large + // amount of CPU time. extra_inst_bytes: usize, } @@ -260,7 +270,7 @@ self.check_size()?; match *expr.kind() { - Empty => Ok(None), + Empty => self.c_empty(), Literal(hir::Literal::Unicode(c)) => self.c_char(c), Literal(hir::Literal::Byte(b)) => { assert!(self.compiled.uses_bytes()); @@ -378,6 +388,19 @@ } } + fn c_empty(&mut self) -> ResultOrEmpty { + // See: https://github.com/rust-lang/regex/security/advisories/GHSA-m5pq-gvj9-9vr8 + // See: CVE-2022-24713 + // + // Since 'empty' sub-expressions don't increase the size of + // the actual compiled object, we "fake" an increase in its + // size so that our 'check_size_limit' routine will eventually + // stop compilation if there are too many empty sub-expressions + // (e.g., via a large repetition). + self.extra_inst_bytes += std::mem::size_of::(); + Ok(None) + } + fn c_capture(&mut self, first_slot: usize, expr: &Hir) -> ResultOrEmpty { if self.num_exprs > 1 || self.compiled.is_dfa { // Don't ever compile Save instructions for regex sets because @@ -496,7 +519,7 @@ let mut exprs = exprs.into_iter(); let Patch { mut hole, entry } = loop { match exprs.next() { - None => return Ok(None), + None => return self.c_empty(), Some(e) => { if let Some(p) = self.c(e)? { break p; diff -Nru cargo-0.58.0/vendor/regex/src/dfa.rs cargo-0.60.0ubuntu1/vendor/regex/src/dfa.rs --- cargo-0.58.0/vendor/regex/src/dfa.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/regex/src/dfa.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1353,7 +1353,6 @@ match self.cache.trans.next(si, self.byte_class(b)) { STATE_UNKNOWN => self.exec_byte(qcur, qnext, si, b), STATE_QUIT => None, - STATE_DEAD => Some(STATE_DEAD), nsi => Some(nsi), } } @@ -1387,7 +1386,6 @@ }; match self.cache.start_states[flagi] { STATE_UNKNOWN => {} - STATE_DEAD => return Some(STATE_DEAD), si => return Some(si), } q.clear(); diff -Nru cargo-0.58.0/vendor/regex/src/re_unicode.rs cargo-0.60.0ubuntu1/vendor/regex/src/re_unicode.rs --- cargo-0.58.0/vendor/regex/src/re_unicode.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/regex/src/re_unicode.rs 2022-04-20 13:48:09.000000000 +0000 @@ -538,7 +538,7 @@ mut rep: R, ) -> Cow<'t, str> { // If we know that the replacement doesn't have any capture expansions, - // then we can fast path. The fast path can make a tremendous + // then we can use the fast path. The fast path can make a tremendous // difference: // // 1) We use `find_iter` instead of `captures_iter`. Not asking for diff -Nru cargo-0.58.0/vendor/regex/tests/test_default.rs cargo-0.60.0ubuntu1/vendor/regex/tests/test_default.rs --- cargo-0.58.0/vendor/regex/tests/test_default.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/regex/tests/test_default.rs 2022-04-20 13:48:09.000000000 +0000 @@ -150,3 +150,73 @@ assert_eq!(16, size_of::()); assert_eq!(16, size_of::()); } + +// See: https://github.com/rust-lang/regex/security/advisories/GHSA-m5pq-gvj9-9vr8 +// See: CVE-2022-24713 +// +// We test that our regex compiler will correctly return a "too big" error when +// we try to use a very large repetition on an *empty* sub-expression. +// +// At the time this test was written, the regex compiler does not represent +// empty sub-expressions with any bytecode instructions. In effect, it's an +// "optimization" to leave them out, since they would otherwise correspond +// to an unconditional JUMP in the regex bytecode (i.e., an unconditional +// epsilon transition in the NFA graph). Therefore, an empty sub-expression +// represents an interesting case for the compiler's size limits. Since it +// doesn't actually contribute any additional memory to the compiled regex +// instructions, the size limit machinery never detects it. Instead, it just +// dumbly tries to compile the empty sub-expression N times, where N is the +// repetition size. +// +// When N is very large, this will cause the compiler to essentially spin and +// do nothing for a decently large amount of time. It causes the regex to take +// quite a bit of time to compile, despite the concrete syntax of the regex +// being quite small. +// +// The degree to which this is actually a problem is somewhat of a judgment +// call. Some regexes simply take a long time to compile. But in general, you +// should be able to reasonably control this by setting lower or higher size +// limits on the compiled object size. But this mitigation doesn't work at all +// for this case. +// +// This particular test is somewhat narrow. It merely checks that regex +// compilation will, at some point, return a "too big" error. Before the +// fix landed, this test would eventually fail because the regex would be +// successfully compiled (after enough time elapsed). So while this test +// doesn't check that we exit in a reasonable amount of time, it does at least +// check that we are properly returning an error at some point. +#[test] +fn big_empty_regex_fails() { + use regex::Regex; + + let result = Regex::new("(?:){4294967295}"); + assert!(result.is_err()); +} + +// Below is a "billion laughs" variant of the previous test case. +#[test] +fn big_empty_reps_chain_regex_fails() { + use regex::Regex; + + let result = Regex::new("(?:){64}{64}{64}{64}{64}{64}"); + assert!(result.is_err()); +} + +// Below is another situation where a zero-length sub-expression can be +// introduced. +#[test] +fn big_zero_reps_regex_fails() { + use regex::Regex; + + let result = Regex::new(r"x{0}{4294967295}"); + assert!(result.is_err()); +} + +// Testing another case for completeness. +#[test] +fn empty_alt_regex_fails() { + use regex::Regex; + + let result = Regex::new(r"(?:|){4294967295}"); + assert!(result.is_err()); +} diff -Nru cargo-0.58.0/vendor/semver/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/semver/.cargo-checksum.json --- cargo-0.58.0/vendor/semver/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/semver/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012"} \ No newline at end of file +{"files":{},"package":"d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/semver/Cargo.toml cargo-0.60.0ubuntu1/vendor/semver/Cargo.toml --- cargo-0.58.0/vendor/semver/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/semver/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -11,17 +11,23 @@ [package] edition = "2018" +rust-version = "1.31" name = "semver" -version = "1.0.4" +version = "1.0.7" authors = ["David Tolnay "] description = "Parser and evaluator for Cargo's flavor of Semantic Versioning" documentation = "https://docs.rs/semver" readme = "README.md" license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/semver" + [package.metadata.docs.rs] -rustdoc-args = ["--cfg", "doc_cfg"] targets = ["x86_64-unknown-linux-gnu"] +rustdoc-args = [ + "--cfg", + "doc_cfg", +] + [dependencies.serde] version = "1.0" optional = true diff -Nru cargo-0.58.0/vendor/semver/README.md cargo-0.60.0ubuntu1/vendor/semver/README.md --- cargo-0.58.0/vendor/semver/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/semver/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -3,7 +3,7 @@ [github](https://github.com/dtolnay/semver) [crates.io](https://crates.io/crates/semver) -[docs.rs](https://docs.rs/semver/1.0.0) +[docs.rs](https://docs.rs/semver) [build status](https://github.com/dtolnay/semver/actions?query=branch%3Amaster) A parser and evaluator for Cargo's flavor of Semantic Versioning. diff -Nru cargo-0.58.0/vendor/semver/src/error.rs cargo-0.60.0ubuntu1/vendor/semver/src/error.rs --- cargo-0.58.0/vendor/semver/src/error.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/semver/src/error.rs 2022-04-20 13:48:09.000000000 +0000 @@ -10,6 +10,7 @@ Overflow(Position), EmptySegment(Position), IllegalCharacter(Position), + WildcardNotTheOnlyComparator(char), UnexpectedAfterWildcard, ExcessiveComparators, } @@ -36,15 +37,26 @@ ErrorKind::UnexpectedChar(pos, ch) => { write!( formatter, - "unexpected character {:?} while parsing {}", - ch, pos, + "unexpected character {} while parsing {}", + QuotedChar(*ch), + pos, ) } ErrorKind::UnexpectedCharAfter(pos, ch) => { - write!(formatter, "unexpected character {:?} after {}", ch, pos) + write!( + formatter, + "unexpected character {} after {}", + QuotedChar(*ch), + pos, + ) } ErrorKind::ExpectedCommaFound(pos, ch) => { - write!(formatter, "expected comma after {}, found {:?}", pos, ch) + write!( + formatter, + "expected comma after {}, found {}", + pos, + QuotedChar(*ch), + ) } ErrorKind::LeadingZero(pos) => { write!(formatter, "invalid leading zero in {}", pos) @@ -58,6 +70,13 @@ ErrorKind::IllegalCharacter(pos) => { write!(formatter, "unexpected character in {}", pos) } + ErrorKind::WildcardNotTheOnlyComparator(ch) => { + write!( + formatter, + "wildcard req ({}) must be the only comparator in the version req", + ch, + ) + } ErrorKind::UnexpectedAfterWildcard => { formatter.write_str("unexpected character after wildcard in version req") } @@ -88,3 +107,18 @@ Ok(()) } } + +struct QuotedChar(char); + +impl Display for QuotedChar { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + // Standard library versions prior to https://github.com/rust-lang/rust/pull/95345 + // print character 0 as '\u{0}'. We prefer '\0' to keep error messages + // the same across all supported Rust versions. + if self.0 == '\0' { + formatter.write_str("'\\0'") + } else { + write!(formatter, "{:?}", self.0) + } + } +} diff -Nru cargo-0.58.0/vendor/semver/src/lib.rs cargo-0.60.0ubuntu1/vendor/semver/src/lib.rs --- cargo-0.58.0/vendor/semver/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/semver/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -60,7 +60,7 @@ //! //! [Specifying Dependencies]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html -#![doc(html_root_url = "https://docs.rs/semver/1.0.4")] +#![doc(html_root_url = "https://docs.rs/semver/1.0.7")] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![cfg_attr(all(not(feature = "std"), not(no_alloc_crate)), no_std)] #![cfg_attr(not(no_unsafe_op_in_unsafe_fn_lint), deny(unsafe_op_in_unsafe_fn))] @@ -71,6 +71,7 @@ clippy::cast_possible_truncation, clippy::doc_markdown, clippy::items_after_statements, + clippy::manual_map, clippy::match_bool, clippy::missing_errors_doc, clippy::must_use_candidate, @@ -183,7 +184,8 @@ /// - Whitespace is permitted around commas and around operators. Whitespace is /// not permitted within a partial version, i.e. anywhere between the major /// version number and its minor, patch, pre-release, or build metadata. -#[derive(Default, Clone, Eq, PartialEq, Hash, Debug)] +#[derive(Clone, Eq, PartialEq, Hash, Debug)] +#[cfg_attr(no_const_vec_new, derive(Default))] pub struct VersionReq { pub comparators: Vec, } @@ -476,6 +478,14 @@ } } +/// The default VersionReq is the same as [`VersionReq::STAR`]. +#[cfg(not(no_const_vec_new))] +impl Default for VersionReq { + fn default() -> Self { + VersionReq::STAR + } +} + impl Comparator { pub fn parse(text: &str) -> Result { Comparator::from_str(text) diff -Nru cargo-0.58.0/vendor/semver/src/parse.rs cargo-0.60.0ubuntu1/vendor/semver/src/parse.rs --- cargo-0.58.0/vendor/semver/src/parse.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/semver/src/parse.rs 2022-04-20 13:48:09.000000000 +0000 @@ -82,14 +82,17 @@ fn from_str(text: &str) -> Result { let text = text.trim_start_matches(' '); - if let Some(text) = wildcard(text) { - if text.trim_start_matches(' ').is_empty() { + if let Some((ch, text)) = wildcard(text) { + let rest = text.trim_start_matches(' '); + if rest.is_empty() { #[cfg(not(no_const_vec_new))] return Ok(VersionReq::STAR); #[cfg(no_const_vec_new)] // rustc <1.39 return Ok(VersionReq { comparators: Vec::new(), }); + } else if rest.starts_with(',') { + return Err(Error::new(ErrorKind::WildcardNotTheOnlyComparator(ch))); } else { return Err(Error::new(ErrorKind::UnexpectedAfterWildcard)); } @@ -181,13 +184,13 @@ } } -fn wildcard(input: &str) -> Option<&str> { +fn wildcard(input: &str) -> Option<(char, &str)> { if let Some(rest) = input.strip_prefix('*') { - Some(rest) + Some(('*', rest)) } else if let Some(rest) = input.strip_prefix('x') { - Some(rest) + Some(('x', rest)) } else if let Some(rest) = input.strip_prefix('X') { - Some(rest) + Some(('X', rest)) } else { None } @@ -293,7 +296,7 @@ let (minor, text) = if let Some(text) = text.strip_prefix('.') { pos = Position::Minor; - if let Some(text) = wildcard(text) { + if let Some((_, text)) = wildcard(text) { has_wildcard = true; if default_op { op = Op::Wildcard; @@ -309,7 +312,7 @@ let (patch, text) = if let Some(text) = text.strip_prefix('.') { pos = Position::Patch; - if let Some(text) = wildcard(text) { + if let Some((_, text)) = wildcard(text) { if default_op { op = Op::Wildcard; } @@ -362,7 +365,18 @@ } fn version_req(input: &str, out: &mut Vec, depth: usize) -> Result { - let (comparator, pos, text) = comparator(input)?; + let (comparator, pos, text) = match comparator(input) { + Ok(success) => success, + Err(mut error) => { + if let Some((ch, mut rest)) = wildcard(input) { + rest = rest.trim_start_matches(' '); + if rest.is_empty() || rest.starts_with(',') { + error.kind = ErrorKind::WildcardNotTheOnlyComparator(ch); + } + } + return Err(error); + } + }; if text.is_empty() { out.reserve_exact(depth + 1); diff -Nru cargo-0.58.0/vendor/semver/tests/node/mod.rs cargo-0.60.0ubuntu1/vendor/semver/tests/node/mod.rs --- cargo-0.58.0/vendor/semver/tests/node/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/semver/tests/node/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -4,7 +4,7 @@ use std::fmt::{self, Display}; use std::process::Command; -#[derive(Eq, PartialEq, Hash, Debug)] +#[derive(Default, Eq, PartialEq, Hash, Debug)] pub(super) struct VersionReq(semver::VersionReq); impl VersionReq { diff -Nru cargo-0.58.0/vendor/semver/tests/test_identifier.rs cargo-0.60.0ubuntu1/vendor/semver/tests/test_identifier.rs --- cargo-0.58.0/vendor/semver/tests/test_identifier.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/semver/tests/test_identifier.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,10 @@ +#![allow( + clippy::eq_op, + clippy::needless_pass_by_value, + clippy::toplevel_ref_arg, + clippy::wildcard_imports +)] + mod util; use crate::util::*; diff -Nru cargo-0.58.0/vendor/semver/tests/test_version_req.rs cargo-0.60.0ubuntu1/vendor/semver/tests/test_version_req.rs --- cargo-0.58.0/vendor/semver/tests/test_version_req.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/semver/tests/test_version_req.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,10 @@ +#![allow( + clippy::missing_panics_doc, + clippy::shadow_unrelated, + clippy::toplevel_ref_arg, + clippy::wildcard_imports +)] + mod node; mod util; @@ -27,7 +34,7 @@ } #[test] -fn test_default() { +fn test_basic() { let ref r = req("1.0.0"); assert_to_string(r, "^1.0.0"); assert_match_all(r, &["1.0.0", "1.1.0", "1.0.1"]); @@ -35,6 +42,13 @@ } #[test] +#[cfg(not(no_const_vec_new))] +fn test_default() { + let ref r = VersionReq::default(); + assert_eq!(r, &VersionReq::STAR); +} + +#[test] fn test_exact() { let ref r = req("=1.0.0"); assert_to_string(r, "=1.0.0"); @@ -322,7 +336,7 @@ let err = req_err("\0"); assert_to_string( err, - "unexpected character '\\u{0}' while parsing major version number", + "unexpected character '\\0' while parsing major version number", ); let err = req_err(">= >= 0.0.2"); @@ -389,7 +403,7 @@ } #[test] -fn test_parsing_pre_and_build_metadata_see_issue_217() { +fn test_leading_digit_in_pre_and_build() { for op in &["=", ">", ">=", "<", "<=", "~", "^"] { // digit then alpha req(&format!("{} 1.2.3-1a", op)); @@ -406,3 +420,24 @@ req(&format!("{} 1.2.3-1a-1a+1a-1a-1a", op)); } } + +#[test] +fn test_wildcard_and_another() { + let err = req_err("*, 0.20.0-any"); + assert_to_string( + err, + "wildcard req (*) must be the only comparator in the version req", + ); + + let err = req_err("0.20.0-any, *"); + assert_to_string( + err, + "wildcard req (*) must be the only comparator in the version req", + ); + + let err = req_err("0.20.0-any, *, 1.0"); + assert_to_string( + err, + "wildcard req (*) must be the only comparator in the version req", + ); +} diff -Nru cargo-0.58.0/vendor/semver/tests/test_version.rs cargo-0.60.0ubuntu1/vendor/semver/tests/test_version.rs --- cargo-0.58.0/vendor/semver/tests/test_version.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/semver/tests/test_version.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,9 @@ +#![allow( + clippy::nonminimal_bool, + clippy::too_many_lines, + clippy::wildcard_imports +)] + mod util; use crate::util::*; diff -Nru cargo-0.58.0/vendor/serde/build.rs cargo-0.60.0ubuntu1/vendor/serde/build.rs --- cargo-0.58.0/vendor/serde/build.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -17,37 +17,38 @@ // std::collections::Bound was stabilized in Rust 1.17 // but it was moved to core::ops later in Rust 1.26: // https://doc.rust-lang.org/core/ops/enum.Bound.html - if minor >= 26 { - println!("cargo:rustc-cfg=ops_bound"); - } else if minor >= 17 && cfg!(feature = "std") { - println!("cargo:rustc-cfg=collections_bound"); + if minor < 26 { + println!("cargo:rustc-cfg=no_ops_bound"); + if minor < 17 { + println!("cargo:rustc-cfg=no_collections_bound"); + } } // core::cmp::Reverse stabilized in Rust 1.19: // https://doc.rust-lang.org/stable/core/cmp/struct.Reverse.html - if minor >= 19 { - println!("cargo:rustc-cfg=core_reverse"); + if minor < 19 { + println!("cargo:rustc-cfg=no_core_reverse"); } // CString::into_boxed_c_str and PathBuf::into_boxed_path stabilized in Rust 1.20: // https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str // https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.into_boxed_path - if minor >= 20 { - println!("cargo:rustc-cfg=de_boxed_c_str"); - println!("cargo:rustc-cfg=de_boxed_path"); + if minor < 20 { + println!("cargo:rustc-cfg=no_de_boxed_c_str"); + println!("cargo:rustc-cfg=no_de_boxed_path"); } // From> for Rc / Arc stabilized in Rust 1.21: // https://doc.rust-lang.org/std/rc/struct.Rc.html#impl-From> // https://doc.rust-lang.org/std/sync/struct.Arc.html#impl-From> - if minor >= 21 { - println!("cargo:rustc-cfg=de_rc_dst"); + if minor < 21 { + println!("cargo:rustc-cfg=no_de_rc_dst"); } // Duration available in core since Rust 1.25: // https://blog.rust-lang.org/2018/03/29/Rust-1.25.html#library-stabilizations - if minor >= 25 { - println!("cargo:rustc-cfg=core_duration"); + if minor < 25 { + println!("cargo:rustc-cfg=no_core_duration"); } // 128-bit integers stabilized in Rust 1.26: @@ -56,56 +57,56 @@ // Disabled on Emscripten targets before Rust 1.40 since // Emscripten did not support 128-bit integers until Rust 1.40 // (https://github.com/rust-lang/rust/pull/65251) - if minor >= 26 && (!emscripten || minor >= 40) { - println!("cargo:rustc-cfg=integer128"); + if minor < 26 || emscripten && minor < 40 { + println!("cargo:rustc-cfg=no_integer128"); } // Inclusive ranges methods stabilized in Rust 1.27: // https://github.com/rust-lang/rust/pull/50758 // Also Iterator::try_for_each: // https://blog.rust-lang.org/2018/06/21/Rust-1.27.html#library-stabilizations - if minor >= 27 { - println!("cargo:rustc-cfg=range_inclusive"); - println!("cargo:rustc-cfg=iterator_try_fold"); + if minor < 27 { + println!("cargo:rustc-cfg=no_range_inclusive"); + println!("cargo:rustc-cfg=no_iterator_try_fold"); } // Non-zero integers stabilized in Rust 1.28: // https://blog.rust-lang.org/2018/08/02/Rust-1.28.html#library-stabilizations - if minor >= 28 { - println!("cargo:rustc-cfg=num_nonzero"); + if minor < 28 { + println!("cargo:rustc-cfg=no_num_nonzero"); } // Current minimum supported version of serde_derive crate is Rust 1.31. - if minor >= 31 { - println!("cargo:rustc-cfg=serde_derive"); + if minor < 31 { + println!("cargo:rustc-cfg=no_serde_derive"); } // TryFrom, Atomic types, non-zero signed integers, and SystemTime::checked_add // stabilized in Rust 1.34: // https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto // https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#library-stabilizations - if minor >= 34 { - println!("cargo:rustc-cfg=core_try_from"); - println!("cargo:rustc-cfg=num_nonzero_signed"); - println!("cargo:rustc-cfg=systemtime_checked_add"); - - // Whitelist of archs that support std::sync::atomic module. Ideally we - // would use #[cfg(target_has_atomic = "...")] but it is not stable yet. - // Instead this is based on rustc's compiler/rustc_target/src/spec/*.rs. - let has_atomic64 = target.starts_with("x86_64") - || target.starts_with("i686") - || target.starts_with("aarch64") - || target.starts_with("powerpc64") - || target.starts_with("sparc64") - || target.starts_with("mips64el") - || target.starts_with("riscv64"); - let has_atomic32 = has_atomic64 || emscripten; - if has_atomic64 { - println!("cargo:rustc-cfg=std_atomic64"); - } - if has_atomic32 { - println!("cargo:rustc-cfg=std_atomic"); - } + if minor < 34 { + println!("cargo:rustc-cfg=no_core_try_from"); + println!("cargo:rustc-cfg=no_num_nonzero_signed"); + println!("cargo:rustc-cfg=no_systemtime_checked_add"); + } + + // Whitelist of archs that support std::sync::atomic module. Ideally we + // would use #[cfg(target_has_atomic = "...")] but it is not stable yet. + // Instead this is based on rustc's compiler/rustc_target/src/spec/*.rs. + let has_atomic64 = target.starts_with("x86_64") + || target.starts_with("i686") + || target.starts_with("aarch64") + || target.starts_with("powerpc64") + || target.starts_with("sparc64") + || target.starts_with("mips64el") + || target.starts_with("riscv64"); + let has_atomic32 = has_atomic64 || emscripten; + if minor < 34 || !has_atomic64 { + println!("cargo:rustc-cfg=no_std_atomic64"); + } + if minor < 34 || !has_atomic32 { + println!("cargo:rustc-cfg=no_std_atomic"); } } diff -Nru cargo-0.58.0/vendor/serde/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/serde/.cargo-checksum.json --- cargo-0.58.0/vendor/serde/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a"} \ No newline at end of file +{"files":{},"package":"ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/serde/Cargo.toml cargo-0.60.0ubuntu1/vendor/serde/Cargo.toml --- cargo-0.58.0/vendor/serde/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] rust-version = "1.15" name = "serde" -version = "1.0.133" +version = "1.0.136" authors = ["Erick Tryzelaar ", "David Tolnay "] build = "build.rs" include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] @@ -30,7 +30,7 @@ [package.metadata.playground] features = ["derive", "rc"] [dependencies.serde_derive] -version = "=1.0.133" +version = "=1.0.136" optional = true [dev-dependencies.serde_derive] version = "1.0" diff -Nru cargo-0.58.0/vendor/serde/crates-io.md cargo-0.60.0ubuntu1/vendor/serde/crates-io.md --- cargo-0.58.0/vendor/serde/crates-io.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/crates-io.md 2022-04-20 13:48:09.000000000 +0000 @@ -45,17 +45,20 @@ Serde is one of the most widely used Rust libraries so any place that Rustaceans congregate will be able to help you out. For chat, consider trying the -[#general] or [#beginners] channels of the unofficial community Discord, the -[#rust-usage] channel of the official Rust Project Discord, or the -[#general][zulip] stream in Zulip. For asynchronous, consider the [\[rust\] tag -on StackOverflow][stackoverflow], the [/r/rust] subreddit which has a pinned -weekly easy questions post, or the Rust [Discourse forum][discourse]. It's -acceptable to file a support issue in this repo but they tend not to get as many -eyes as any of the above and may get closed without a response after some time. +[#rust-questions] or [#rust-beginners] channels of the unofficial community +Discord (invite: , the [#rust-usage] or +[#beginners] channels of the official Rust Project Discord (invite: +), or the [#general][zulip] stream in Zulip. For +asynchronous, consider the [\[rust\] tag on StackOverflow][stackoverflow], the +[/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust +[Discourse forum][discourse]. It's acceptable to file a support issue in this +repo but they tend not to get as many eyes as any of the above and may get +closed without a response after some time. -[#general]: https://discord.com/channels/273534239310479360/274215136414400513 -[#beginners]: https://discord.com/channels/273534239310479360/273541522815713281 +[#rust-questions]: https://discord.com/channels/273534239310479360/274215136414400513 +[#rust-beginners]: https://discord.com/channels/273534239310479360/273541522815713281 [#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848 +[#beginners]: https://discord.com/channels/442252698964721669/448238009733742612 [zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general [stackoverflow]: https://stackoverflow.com/questions/tagged/rust [/r/rust]: https://www.reddit.com/r/rust diff -Nru cargo-0.58.0/vendor/serde/README.md cargo-0.60.0ubuntu1/vendor/serde/README.md --- cargo-0.58.0/vendor/serde/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -77,17 +77,20 @@ Serde is one of the most widely used Rust libraries so any place that Rustaceans congregate will be able to help you out. For chat, consider trying the -[#general] or [#beginners] channels of the unofficial community Discord, the -[#rust-usage] channel of the official Rust Project Discord, or the -[#general][zulip] stream in Zulip. For asynchronous, consider the [\[rust\] tag -on StackOverflow][stackoverflow], the [/r/rust] subreddit which has a pinned -weekly easy questions post, or the Rust [Discourse forum][discourse]. It's -acceptable to file a support issue in this repo but they tend not to get as many -eyes as any of the above and may get closed without a response after some time. +[#rust-questions] or [#rust-beginners] channels of the unofficial community +Discord (invite: ), the [#rust-usage] or +[#beginners] channels of the official Rust Project Discord (invite: +), or the [#general][zulip] stream in Zulip. For +asynchronous, consider the [\[rust\] tag on StackOverflow][stackoverflow], the +[/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust +[Discourse forum][discourse]. It's acceptable to file a support issue in this +repo but they tend not to get as many eyes as any of the above and may get +closed without a response after some time. -[#general]: https://discord.com/channels/273534239310479360/274215136414400513 -[#beginners]: https://discord.com/channels/273534239310479360/273541522815713281 +[#rust-questions]: https://discord.com/channels/273534239310479360/274215136414400513 +[#rust-beginners]: https://discord.com/channels/273534239310479360/273541522815713281 [#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848 +[#beginners]: https://discord.com/channels/442252698964721669/448238009733742612 [zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general [stackoverflow]: https://stackoverflow.com/questions/tagged/rust [/r/rust]: https://www.reddit.com/r/rust diff -Nru cargo-0.58.0/vendor/serde/src/de/format.rs cargo-0.60.0ubuntu1/vendor/serde/src/de/format.rs --- cargo-0.58.0/vendor/serde/src/de/format.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/src/de/format.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,30 @@ +use lib::fmt::{self, Write}; +use lib::str; + +pub struct Buf<'a> { + bytes: &'a mut [u8], + offset: usize, +} + +impl<'a> Buf<'a> { + pub fn new(bytes: &'a mut [u8]) -> Self { + Buf { bytes, offset: 0 } + } + + pub fn as_str(&self) -> &str { + let slice = &self.bytes[..self.offset]; + unsafe { str::from_utf8_unchecked(slice) } + } +} + +impl<'a> Write for Buf<'a> { + fn write_str(&mut self, s: &str) -> fmt::Result { + if self.offset + s.len() > self.bytes.len() { + Err(fmt::Error) + } else { + self.bytes[self.offset..self.offset + s.len()].copy_from_slice(s.as_bytes()); + self.offset += s.len(); + Ok(()) + } + } +} diff -Nru cargo-0.58.0/vendor/serde/src/de/impls.rs cargo-0.60.0ubuntu1/vendor/serde/src/de/impls.rs --- cargo-0.58.0/vendor/serde/src/de/impls.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/src/de/impls.rs 2022-04-20 13:48:09.000000000 +0000 @@ -4,7 +4,7 @@ Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess, Visitor, }; -#[cfg(any(core_duration, feature = "std", feature = "alloc"))] +#[cfg(any(feature = "std", feature = "alloc", not(no_core_duration)))] use de::MapAccess; use seed::InPlaceSeed; @@ -81,8 +81,34 @@ //////////////////////////////////////////////////////////////////////////////// macro_rules! impl_deserialize_num { - ($ty:ident, $deserialize:ident $($methods:tt)*) => { - impl<'de> Deserialize<'de> for $ty { + ($primitive:ident, $nonzero:ident $(cfg($($cfg:tt)*))*, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => { + impl_deserialize_num!($primitive, $deserialize $($method!($($val : $visit)*);)*); + + #[cfg(all(not(no_num_nonzero), $($($cfg)*)*))] + impl<'de> Deserialize<'de> for num::$nonzero { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct NonZeroVisitor; + + impl<'de> Visitor<'de> for NonZeroVisitor { + type Value = num::$nonzero; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str(concat!("a nonzero ", stringify!($primitive))) + } + + $($($method!(nonzero $primitive $val : $visit);)*)* + } + + deserializer.$deserialize(NonZeroVisitor) + } + } + }; + + ($primitive:ident, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => { + impl<'de> Deserialize<'de> for $primitive { #[inline] fn deserialize(deserializer: D) -> Result where @@ -91,13 +117,13 @@ struct PrimitiveVisitor; impl<'de> Visitor<'de> for PrimitiveVisitor { - type Value = $ty; + type Value = $primitive; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str(stringify!($ty)) + formatter.write_str(stringify!($primitive)) } - $($methods)* + $($($method!($val : $visit);)*)* } deserializer.$deserialize(PrimitiveVisitor) @@ -116,85 +142,149 @@ Ok(v) } }; + + (nonzero $primitive:ident $ty:ident : $visit:ident) => { + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + if let Some(nonzero) = Self::Value::new(v) { + Ok(nonzero) + } else { + Err(Error::invalid_value(Unexpected::Unsigned(0), &self)) + } + } + }; } macro_rules! num_as_self { - ($($ty:ident : $visit:ident)*) => { - $( - #[inline] - fn $visit(self, v: $ty) -> Result - where - E: Error, - { - Ok(v as Self::Value) + ($ty:ident : $visit:ident) => { + #[inline] + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + Ok(v as Self::Value) + } + }; + + (nonzero $primitive:ident $ty:ident : $visit:ident) => { + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + if let Some(nonzero) = Self::Value::new(v as $primitive) { + Ok(nonzero) + } else { + Err(Error::invalid_value(Unexpected::Unsigned(0), &self)) } - )* + } }; } macro_rules! int_to_int { - ($($ty:ident : $visit:ident)*) => { - $( - #[inline] - fn $visit(self, v: $ty) -> Result - where - E: Error, + ($ty:ident : $visit:ident) => { + #[inline] + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + if Self::Value::min_value() as i64 <= v as i64 + && v as i64 <= Self::Value::max_value() as i64 { - if Self::Value::min_value() as i64 <= v as i64 && v as i64 <= Self::Value::max_value() as i64 { - Ok(v as Self::Value) - } else { - Err(Error::invalid_value(Unexpected::Signed(v as i64), &self)) + Ok(v as Self::Value) + } else { + Err(Error::invalid_value(Unexpected::Signed(v as i64), &self)) + } + } + }; + + (nonzero $primitive:ident $ty:ident : $visit:ident) => { + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + if $primitive::min_value() as i64 <= v as i64 + && v as i64 <= $primitive::max_value() as i64 + { + if let Some(nonzero) = Self::Value::new(v as $primitive) { + return Ok(nonzero); } } - )* + Err(Error::invalid_value(Unexpected::Signed(v as i64), &self)) + } }; } macro_rules! int_to_uint { - ($($ty:ident : $visit:ident)*) => { - $( - #[inline] - fn $visit(self, v: $ty) -> Result - where - E: Error, - { - if 0 <= v && v as u64 <= Self::Value::max_value() as u64 { - Ok(v as Self::Value) - } else { - Err(Error::invalid_value(Unexpected::Signed(v as i64), &self)) + ($ty:ident : $visit:ident) => { + #[inline] + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + if 0 <= v && v as u64 <= Self::Value::max_value() as u64 { + Ok(v as Self::Value) + } else { + Err(Error::invalid_value(Unexpected::Signed(v as i64), &self)) + } + } + }; + + (nonzero $primitive:ident $ty:ident : $visit:ident) => { + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + if 0 < v && v as u64 <= $primitive::max_value() as u64 { + if let Some(nonzero) = Self::Value::new(v as $primitive) { + return Ok(nonzero); } } - )* + Err(Error::invalid_value(Unexpected::Signed(v as i64), &self)) + } }; } macro_rules! uint_to_self { - ($($ty:ident : $visit:ident)*) => { - $( - #[inline] - fn $visit(self, v: $ty) -> Result - where - E: Error, - { - if v as u64 <= Self::Value::max_value() as u64 { - Ok(v as Self::Value) - } else { - Err(Error::invalid_value(Unexpected::Unsigned(v as u64), &self)) + ($ty:ident : $visit:ident) => { + #[inline] + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + if v as u64 <= Self::Value::max_value() as u64 { + Ok(v as Self::Value) + } else { + Err(Error::invalid_value(Unexpected::Unsigned(v as u64), &self)) + } + } + }; + + (nonzero $primitive:ident $ty:ident : $visit:ident) => { + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + if v as u64 <= $primitive::max_value() as u64 { + if let Some(nonzero) = Self::Value::new(v as $primitive) { + return Ok(nonzero); } } - )* + Err(Error::invalid_value(Unexpected::Unsigned(v as u64), &self)) + } }; } impl_deserialize_num! { - i8, deserialize_i8 + i8, NonZeroI8 cfg(not(no_num_nonzero_signed)), deserialize_i8 num_self!(i8:visit_i8); int_to_int!(i16:visit_i16 i32:visit_i32 i64:visit_i64); uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); } impl_deserialize_num! { - i16, deserialize_i16 + i16, NonZeroI16 cfg(not(no_num_nonzero_signed)), deserialize_i16 num_self!(i16:visit_i16); num_as_self!(i8:visit_i8); int_to_int!(i32:visit_i32 i64:visit_i64); @@ -202,7 +292,7 @@ } impl_deserialize_num! { - i32, deserialize_i32 + i32, NonZeroI32 cfg(not(no_num_nonzero_signed)), deserialize_i32 num_self!(i32:visit_i32); num_as_self!(i8:visit_i8 i16:visit_i16); int_to_int!(i64:visit_i64); @@ -210,28 +300,28 @@ } impl_deserialize_num! { - i64, deserialize_i64 + i64, NonZeroI64 cfg(not(no_num_nonzero_signed)), deserialize_i64 num_self!(i64:visit_i64); num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32); uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); } impl_deserialize_num! { - isize, deserialize_i64 + isize, NonZeroIsize cfg(not(no_num_nonzero_signed)), deserialize_i64 num_as_self!(i8:visit_i8 i16:visit_i16); int_to_int!(i32:visit_i32 i64:visit_i64); uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); } impl_deserialize_num! { - u8, deserialize_u8 + u8, NonZeroU8, deserialize_u8 num_self!(u8:visit_u8); int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); uint_to_self!(u16:visit_u16 u32:visit_u32 u64:visit_u64); } impl_deserialize_num! { - u16, deserialize_u16 + u16, NonZeroU16, deserialize_u16 num_self!(u16:visit_u16); num_as_self!(u8:visit_u8); int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); @@ -239,7 +329,7 @@ } impl_deserialize_num! { - u32, deserialize_u32 + u32, NonZeroU32, deserialize_u32 num_self!(u32:visit_u32); num_as_self!(u8:visit_u8 u16:visit_u16); int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); @@ -247,14 +337,14 @@ } impl_deserialize_num! { - u64, deserialize_u64 + u64, NonZeroU64, deserialize_u64 num_self!(u64:visit_u64); num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32); int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); } impl_deserialize_num! { - usize, deserialize_u64 + usize, NonZeroUsize, deserialize_u64 num_as_self!(u8:visit_u8 u16:visit_u16); int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); uint_to_self!(u32:visit_u32 u64:visit_u64); @@ -277,42 +367,62 @@ } serde_if_integer128! { + macro_rules! num_128 { + ($ty:ident : $visit:ident) => { + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + if v as i128 >= Self::Value::min_value() as i128 + && v as u128 <= Self::Value::max_value() as u128 + { + Ok(v as Self::Value) + } else { + Err(Error::invalid_value( + Unexpected::Other(stringify!($ty)), + &self, + )) + } + } + }; + + (nonzero $primitive:ident $ty:ident : $visit:ident) => { + fn $visit(self, v: $ty) -> Result + where + E: Error, + { + if v as i128 >= $primitive::min_value() as i128 + && v as u128 <= $primitive::max_value() as u128 + { + if let Some(nonzero) = Self::Value::new(v as $primitive) { + Ok(nonzero) + } else { + Err(Error::invalid_value(Unexpected::Unsigned(0), &self)) + } + } else { + Err(Error::invalid_value( + Unexpected::Other(stringify!($ty)), + &self, + )) + } + } + }; + } + impl_deserialize_num! { - i128, deserialize_i128 + i128, NonZeroI128 cfg(not(no_num_nonzero_signed)), deserialize_i128 num_self!(i128:visit_i128); num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); - - #[inline] - fn visit_u128(self, v: u128) -> Result - where - E: Error, - { - if v <= i128::max_value() as u128 { - Ok(v as i128) - } else { - Err(Error::invalid_value(Unexpected::Other("u128"), &self)) - } - } + num_128!(u128:visit_u128); } impl_deserialize_num! { - u128, deserialize_u128 + u128, NonZeroU128, deserialize_u128 num_self!(u128:visit_u128); num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64); int_to_uint!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64); - - #[inline] - fn visit_i128(self, v: i128) -> Result - where - E: Error, - { - if 0 <= v { - Ok(v as u128) - } else { - Err(Error::invalid_value(Unexpected::Other("i128"), &self)) - } - } + num_128!(i128:visit_i128); } } @@ -637,10 +747,10 @@ } } -#[cfg(all(feature = "std", de_boxed_c_str))] +#[cfg(all(feature = "std", not(no_de_boxed_c_str)))] forwarded_impl!((), Box, CString::into_boxed_c_str); -#[cfg(core_reverse)] +#[cfg(not(no_core_reverse))] forwarded_impl!((T), Reverse, Reverse); //////////////////////////////////////////////////////////////////////////////// @@ -1604,7 +1714,7 @@ } } -#[cfg(all(feature = "std", de_boxed_path))] +#[cfg(all(feature = "std", not(no_de_boxed_path)))] forwarded_impl!((), Box, PathBuf::into_boxed_path); //////////////////////////////////////////////////////////////////////////////// @@ -1685,11 +1795,7 @@ #[cfg(any(feature = "std", feature = "alloc"))] forwarded_impl!((), Box, String::into_boxed_str); -#[cfg(all( - not(de_rc_dst), - feature = "rc", - any(feature = "std", feature = "alloc") -))] +#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] forwarded_impl! { /// This impl requires the [`"rc"`] Cargo feature of Serde. /// @@ -1701,11 +1807,7 @@ (T), Arc, Arc::new } -#[cfg(all( - not(de_rc_dst), - feature = "rc", - any(feature = "std", feature = "alloc") -))] +#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] forwarded_impl! { /// This impl requires the [`"rc"`] Cargo feature of Serde. /// @@ -1772,7 +1874,11 @@ //////////////////////////////////////////////////////////////////////////////// -#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] +#[cfg(all( + not(no_de_rc_dst), + feature = "rc", + any(feature = "std", feature = "alloc") +))] macro_rules! box_forwarded_impl { ( $(#[doc = $doc:tt])* @@ -1793,7 +1899,11 @@ }; } -#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] +#[cfg(all( + not(no_de_rc_dst), + feature = "rc", + any(feature = "std", feature = "alloc") +))] box_forwarded_impl! { /// This impl requires the [`"rc"`] Cargo feature of Serde. /// @@ -1805,7 +1915,11 @@ Rc } -#[cfg(all(de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] +#[cfg(all( + not(no_de_rc_dst), + feature = "rc", + any(feature = "std", feature = "alloc") +))] box_forwarded_impl! { /// This impl requires the [`"rc"`] Cargo feature of Serde. /// @@ -1849,7 +1963,7 @@ // secs: u64, // nanos: u32, // } -#[cfg(any(core_duration, feature = "std"))] +#[cfg(any(feature = "std", not(no_core_duration)))] impl<'de> Deserialize<'de> for Duration { fn deserialize(deserializer: D) -> Result where @@ -2127,11 +2241,11 @@ const FIELDS: &'static [&'static str] = &["secs_since_epoch", "nanos_since_epoch"]; let duration = try!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor)); - #[cfg(systemtime_checked_add)] + #[cfg(not(no_systemtime_checked_add))] let ret = UNIX_EPOCH .checked_add(duration) .ok_or_else(|| D::Error::custom("overflow deserializing SystemTime")); - #[cfg(not(systemtime_checked_add))] + #[cfg(no_systemtime_checked_add)] let ret = Ok(UNIX_EPOCH + duration); ret } @@ -2167,7 +2281,7 @@ } } -#[cfg(range_inclusive)] +#[cfg(not(no_range_inclusive))] impl<'de, Idx> Deserialize<'de> for RangeInclusive where Idx: Deserialize<'de>, @@ -2319,7 +2433,7 @@ //////////////////////////////////////////////////////////////////////////////// -#[cfg(any(ops_bound, collections_bound))] +#[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))] impl<'de, T> Deserialize<'de> for Bound where T: Deserialize<'de>, @@ -2427,58 +2541,6 @@ //////////////////////////////////////////////////////////////////////////////// -macro_rules! nonzero_integers { - ( $( $T: ident, )+ ) => { - $( - #[cfg(num_nonzero)] - impl<'de> Deserialize<'de> for num::$T { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let value = try!(Deserialize::deserialize(deserializer)); - match ::new(value) { - Some(nonzero) => Ok(nonzero), - None => Err(Error::custom("expected a non-zero value")), - } - } - } - )+ - }; -} - -nonzero_integers! { - NonZeroU8, - NonZeroU16, - NonZeroU32, - NonZeroU64, - NonZeroUsize, -} - -#[cfg(num_nonzero_signed)] -nonzero_integers! { - NonZeroI8, - NonZeroI16, - NonZeroI32, - NonZeroI64, - NonZeroIsize, -} - -// Currently 128-bit integers do not work on Emscripten targets so we need an -// additional `#[cfg]` -serde_if_integer128! { - nonzero_integers! { - NonZeroU128, - } - - #[cfg(num_nonzero_signed)] - nonzero_integers! { - NonZeroI128, - } -} - -//////////////////////////////////////////////////////////////////////////////// - impl<'de, T, E> Deserialize<'de> for Result where T: Deserialize<'de>, @@ -2599,7 +2661,7 @@ } } -#[cfg(all(feature = "std", std_atomic))] +#[cfg(all(feature = "std", not(no_std_atomic)))] macro_rules! atomic_impl { ($($ty:ident)*) => { $( @@ -2615,14 +2677,14 @@ }; } -#[cfg(all(feature = "std", std_atomic))] +#[cfg(all(feature = "std", not(no_std_atomic)))] atomic_impl! { AtomicBool AtomicI8 AtomicI16 AtomicI32 AtomicIsize AtomicU8 AtomicU16 AtomicU32 AtomicUsize } -#[cfg(all(feature = "std", std_atomic64))] +#[cfg(all(feature = "std", not(no_std_atomic64)))] atomic_impl! { AtomicI64 AtomicU64 } diff -Nru cargo-0.58.0/vendor/serde/src/de/mod.rs cargo-0.60.0ubuntu1/vendor/serde/src/de/mod.rs --- cargo-0.58.0/vendor/serde/src/de/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/src/de/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -118,6 +118,8 @@ pub mod value; +#[cfg(not(no_integer128))] +mod format; mod ignored_any; mod impls; mod utf8; @@ -1215,7 +1217,7 @@ } // Not public API. - #[cfg(all(serde_derive, any(feature = "std", feature = "alloc")))] + #[cfg(all(not(no_serde_derive), any(feature = "std", feature = "alloc")))] #[doc(hidden)] fn __deserialize_content( self, @@ -1366,8 +1368,10 @@ where E: Error, { - let _ = v; - Err(Error::invalid_type(Unexpected::Other("i128"), &self)) + let mut buf = [0u8; 58]; + let mut writer = format::Buf::new(&mut buf); + fmt::Write::write_fmt(&mut writer, format_args!("integer `{}` as i128", v)).unwrap(); + Err(Error::invalid_type(Unexpected::Other(writer.as_str()), &self)) } } @@ -1426,8 +1430,10 @@ where E: Error, { - let _ = v; - Err(Error::invalid_type(Unexpected::Other("u128"), &self)) + let mut buf = [0u8; 57]; + let mut writer = format::Buf::new(&mut buf); + fmt::Write::write_fmt(&mut writer, format_args!("integer `{}` as u128", v)).unwrap(); + Err(Error::invalid_type(Unexpected::Other(writer.as_str()), &self)) } } diff -Nru cargo-0.58.0/vendor/serde/src/integer128.rs cargo-0.60.0ubuntu1/vendor/serde/src/integer128.rs --- cargo-0.58.0/vendor/serde/src/integer128.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/src/integer128.rs 2022-04-20 13:48:09.000000000 +0000 @@ -66,7 +66,7 @@ /// ($($tt:tt)*) => {}; /// } /// ``` -#[cfg(integer128)] +#[cfg(not(no_integer128))] #[macro_export] macro_rules! serde_if_integer128 { ($($tt:tt)*) => { @@ -74,7 +74,7 @@ }; } -#[cfg(not(integer128))] +#[cfg(no_integer128)] #[macro_export] #[doc(hidden)] macro_rules! serde_if_integer128 { diff -Nru cargo-0.58.0/vendor/serde/src/lib.rs cargo-0.60.0ubuntu1/vendor/serde/src/lib.rs --- cargo-0.58.0/vendor/serde/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -84,7 +84,7 @@ //////////////////////////////////////////////////////////////////////////////// // Serde types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/serde/1.0.133")] +#![doc(html_root_url = "https://docs.rs/serde/1.0.136")] // Support using Serde without the standard library! #![cfg_attr(not(feature = "std"), no_std)] // Unstable functionality only if the user asks for it. For tracking and @@ -227,27 +227,27 @@ #[cfg(feature = "std")] pub use std::time::{SystemTime, UNIX_EPOCH}; - #[cfg(all(feature = "std", collections_bound))] + #[cfg(all(feature = "std", not(no_collections_bound), no_ops_bound))] pub use std::collections::Bound; - #[cfg(core_reverse)] + #[cfg(not(no_core_reverse))] pub use self::core::cmp::Reverse; - #[cfg(ops_bound)] + #[cfg(not(no_ops_bound))] pub use self::core::ops::Bound; - #[cfg(range_inclusive)] + #[cfg(not(no_range_inclusive))] pub use self::core::ops::RangeInclusive; - #[cfg(all(feature = "std", std_atomic))] + #[cfg(all(feature = "std", not(no_std_atomic)))] pub use std::sync::atomic::{ AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32, AtomicU8, AtomicUsize, Ordering, }; - #[cfg(all(feature = "std", std_atomic64))] + #[cfg(all(feature = "std", not(no_std_atomic64)))] pub use std::sync::atomic::{AtomicI64, AtomicU64}; - #[cfg(any(core_duration, feature = "std"))] + #[cfg(any(feature = "std", not(no_core_duration)))] pub use self::core::time::Duration; } @@ -296,7 +296,7 @@ #[doc(hidden)] pub use serde_derive::*; -#[cfg(all(serde_derive, any(feature = "std", feature = "alloc")))] +#[cfg(all(not(no_serde_derive), any(feature = "std", feature = "alloc")))] mod actually_private { pub struct T; } diff -Nru cargo-0.58.0/vendor/serde/src/private/mod.rs cargo-0.60.0ubuntu1/vendor/serde/src/private/mod.rs --- cargo-0.58.0/vendor/serde/src/private/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/src/private/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,6 +1,6 @@ -#[cfg(serde_derive)] +#[cfg(not(no_serde_derive))] pub mod de; -#[cfg(serde_derive)] +#[cfg(not(no_serde_derive))] pub mod ser; pub mod size_hint; @@ -22,7 +22,7 @@ #[cfg(any(feature = "alloc", feature = "std"))] pub use lib::{ToString, Vec}; -#[cfg(core_try_from)] +#[cfg(not(no_core_try_from))] pub use lib::convert::TryFrom; mod string { diff -Nru cargo-0.58.0/vendor/serde/src/ser/impls.rs cargo-0.60.0ubuntu1/vendor/serde/src/ser/impls.rs --- cargo-0.58.0/vendor/serde/src/ser/impls.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/src/ser/impls.rs 2022-04-20 13:48:09.000000000 +0000 @@ -239,7 +239,7 @@ //////////////////////////////////////////////////////////////////////////////// -#[cfg(range_inclusive)] +#[cfg(not(no_range_inclusive))] impl Serialize for RangeInclusive where Idx: Serialize, @@ -258,7 +258,7 @@ //////////////////////////////////////////////////////////////////////////////// -#[cfg(any(ops_bound, collections_bound))] +#[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))] impl Serialize for Bound where T: Serialize, @@ -467,7 +467,7 @@ macro_rules! nonzero_integers { ( $( $T: ident, )+ ) => { $( - #[cfg(num_nonzero)] + #[cfg(not(no_num_nonzero))] impl Serialize for num::$T { fn serialize(&self, serializer: S) -> Result where @@ -488,7 +488,7 @@ NonZeroUsize, } -#[cfg(num_nonzero_signed)] +#[cfg(not(no_num_nonzero_signed))] nonzero_integers! { NonZeroI8, NonZeroI16, @@ -504,7 +504,7 @@ NonZeroU128, } - #[cfg(num_nonzero_signed)] + #[cfg(not(no_num_nonzero_signed))] nonzero_integers! { NonZeroI128, } @@ -591,7 +591,7 @@ //////////////////////////////////////////////////////////////////////////////// -#[cfg(any(core_duration, feature = "std"))] +#[cfg(any(feature = "std", not(no_core_duration)))] impl Serialize for Duration { fn serialize(&self, serializer: S) -> Result where @@ -890,7 +890,7 @@ } } -#[cfg(core_reverse)] +#[cfg(not(no_core_reverse))] impl Serialize for Reverse where T: Serialize, @@ -906,7 +906,7 @@ //////////////////////////////////////////////////////////////////////////////// -#[cfg(all(feature = "std", std_atomic))] +#[cfg(all(feature = "std", not(no_std_atomic)))] macro_rules! atomic_impl { ($($ty:ident)*) => { $( @@ -923,14 +923,14 @@ } } -#[cfg(all(feature = "std", std_atomic))] +#[cfg(all(feature = "std", not(no_std_atomic)))] atomic_impl! { AtomicBool AtomicI8 AtomicI16 AtomicI32 AtomicIsize AtomicU8 AtomicU16 AtomicU32 AtomicUsize } -#[cfg(all(feature = "std", std_atomic64))] +#[cfg(all(feature = "std", not(no_std_atomic64)))] atomic_impl! { AtomicI64 AtomicU64 } diff -Nru cargo-0.58.0/vendor/serde/src/ser/mod.rs cargo-0.60.0ubuntu1/vendor/serde/src/ser/mod.rs --- cargo-0.58.0/vendor/serde/src/ser/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde/src/ser/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1280,13 +1280,13 @@ let iter = iter.into_iter(); let mut serializer = try!(self.serialize_seq(iterator_len_hint(&iter))); - #[cfg(iterator_try_fold)] + #[cfg(not(no_iterator_try_fold))] { let mut iter = iter; try!(iter.try_for_each(|item| serializer.serialize_element(&item))); } - #[cfg(not(iterator_try_fold))] + #[cfg(no_iterator_try_fold)] { for item in iter { try!(serializer.serialize_element(&item)); @@ -1331,13 +1331,13 @@ let iter = iter.into_iter(); let mut serializer = try!(self.serialize_map(iterator_len_hint(&iter))); - #[cfg(iterator_try_fold)] + #[cfg(not(no_iterator_try_fold))] { let mut iter = iter; try!(iter.try_for_each(|(key, value)| serializer.serialize_entry(&key, &value))); } - #[cfg(not(iterator_try_fold))] + #[cfg(no_iterator_try_fold)] { for (key, value) in iter { try!(serializer.serialize_entry(&key, &value)); diff -Nru cargo-0.58.0/vendor/serde_derive/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/serde_derive/.cargo-checksum.json --- cargo-0.58.0/vendor/serde_derive/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_derive/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537"} \ No newline at end of file +{"files":{},"package":"08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/serde_derive/Cargo.toml cargo-0.60.0ubuntu1/vendor/serde_derive/Cargo.toml --- cargo-0.58.0/vendor/serde_derive/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_derive/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] rust-version = "1.31" name = "serde_derive" -version = "1.0.133" +version = "1.0.136" authors = ["Erick Tryzelaar ", "David Tolnay "] include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]" diff -Nru cargo-0.58.0/vendor/serde_derive/crates-io.md cargo-0.60.0ubuntu1/vendor/serde_derive/crates-io.md --- cargo-0.58.0/vendor/serde_derive/crates-io.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_derive/crates-io.md 2022-04-20 13:48:09.000000000 +0000 @@ -45,17 +45,20 @@ Serde is one of the most widely used Rust libraries so any place that Rustaceans congregate will be able to help you out. For chat, consider trying the -[#general] or [#beginners] channels of the unofficial community Discord, the -[#rust-usage] channel of the official Rust Project Discord, or the -[#general][zulip] stream in Zulip. For asynchronous, consider the [\[rust\] tag -on StackOverflow][stackoverflow], the [/r/rust] subreddit which has a pinned -weekly easy questions post, or the Rust [Discourse forum][discourse]. It's -acceptable to file a support issue in this repo but they tend not to get as many -eyes as any of the above and may get closed without a response after some time. +[#rust-questions] or [#rust-beginners] channels of the unofficial community +Discord (invite: , the [#rust-usage] or +[#beginners] channels of the official Rust Project Discord (invite: +), or the [#general][zulip] stream in Zulip. For +asynchronous, consider the [\[rust\] tag on StackOverflow][stackoverflow], the +[/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust +[Discourse forum][discourse]. It's acceptable to file a support issue in this +repo but they tend not to get as many eyes as any of the above and may get +closed without a response after some time. -[#general]: https://discord.com/channels/273534239310479360/274215136414400513 -[#beginners]: https://discord.com/channels/273534239310479360/273541522815713281 +[#rust-questions]: https://discord.com/channels/273534239310479360/274215136414400513 +[#rust-beginners]: https://discord.com/channels/273534239310479360/273541522815713281 [#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848 +[#beginners]: https://discord.com/channels/442252698964721669/448238009733742612 [zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general [stackoverflow]: https://stackoverflow.com/questions/tagged/rust [/r/rust]: https://www.reddit.com/r/rust diff -Nru cargo-0.58.0/vendor/serde_derive/README.md cargo-0.60.0ubuntu1/vendor/serde_derive/README.md --- cargo-0.58.0/vendor/serde_derive/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_derive/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -77,17 +77,20 @@ Serde is one of the most widely used Rust libraries so any place that Rustaceans congregate will be able to help you out. For chat, consider trying the -[#general] or [#beginners] channels of the unofficial community Discord, the -[#rust-usage] channel of the official Rust Project Discord, or the -[#general][zulip] stream in Zulip. For asynchronous, consider the [\[rust\] tag -on StackOverflow][stackoverflow], the [/r/rust] subreddit which has a pinned -weekly easy questions post, or the Rust [Discourse forum][discourse]. It's -acceptable to file a support issue in this repo but they tend not to get as many -eyes as any of the above and may get closed without a response after some time. +[#rust-questions] or [#rust-beginners] channels of the unofficial community +Discord (invite: ), the [#rust-usage] or +[#beginners] channels of the official Rust Project Discord (invite: +), or the [#general][zulip] stream in Zulip. For +asynchronous, consider the [\[rust\] tag on StackOverflow][stackoverflow], the +[/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust +[Discourse forum][discourse]. It's acceptable to file a support issue in this +repo but they tend not to get as many eyes as any of the above and may get +closed without a response after some time. -[#general]: https://discord.com/channels/273534239310479360/274215136414400513 -[#beginners]: https://discord.com/channels/273534239310479360/273541522815713281 +[#rust-questions]: https://discord.com/channels/273534239310479360/274215136414400513 +[#rust-beginners]: https://discord.com/channels/273534239310479360/273541522815713281 [#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848 +[#beginners]: https://discord.com/channels/442252698964721669/448238009733742612 [zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general [stackoverflow]: https://stackoverflow.com/questions/tagged/rust [/r/rust]: https://www.reddit.com/r/rust diff -Nru cargo-0.58.0/vendor/serde_derive/src/lib.rs cargo-0.60.0ubuntu1/vendor/serde_derive/src/lib.rs --- cargo-0.58.0/vendor/serde_derive/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_derive/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -13,7 +13,7 @@ //! //! [https://serde.rs/derive.html]: https://serde.rs/derive.html -#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.133")] +#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.136")] #![allow(unknown_lints, bare_trait_objects)] // Ignored clippy lints #![allow( diff -Nru cargo-0.58.0/vendor/serde_json/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/serde_json/.cargo-checksum.json --- cargo-0.58.0/vendor/serde_json/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"c059c05b48c5c0067d4b4b2b4f0732dd65feb52daf7e0ea09cd87e7dadc1af79"} \ No newline at end of file +{"files":{},"package":"8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/serde_json/Cargo.toml cargo-0.60.0ubuntu1/vendor/serde_json/Cargo.toml --- cargo-0.58.0/vendor/serde_json/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -13,23 +13,37 @@ edition = "2018" rust-version = "1.36" name = "serde_json" -version = "1.0.75" -authors = ["Erick Tryzelaar ", "David Tolnay "] -include = ["build.rs", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] +version = "1.0.79" +authors = [ + "Erick Tryzelaar ", + "David Tolnay ", +] description = "A JSON serialization file format" documentation = "https://docs.serde.rs/serde_json/" readme = "README.md" -keywords = ["json", "serde", "serialization"] +keywords = [ + "json", + "serde", + "serialization", +] categories = ["encoding"] license = "MIT OR Apache-2.0" repository = "https://github.com/serde-rs/json" + [package.metadata.docs.rs] -features = ["raw_value", "unbounded_depth"] -rustdoc-args = ["--cfg", "docsrs"] +features = [ + "raw_value", + "unbounded_depth", +] targets = ["x86_64-unknown-linux-gnu"] +rustdoc-args = [ + "--cfg", + "docsrs", +] [package.metadata.playground] features = ["raw_value"] + [dependencies.indexmap] version = "1.5" optional = true @@ -43,9 +57,13 @@ [dependencies.serde] version = "1.0.100" default-features = false + [dev-dependencies.automod] version = "1.0" +[dev-dependencies.ref-cast] +version = "1.0" + [dev-dependencies.rustversion] version = "1.0" diff -Nru cargo-0.58.0/vendor/serde_json/CONTRIBUTING.md cargo-0.60.0ubuntu1/vendor/serde_json/CONTRIBUTING.md --- cargo-0.58.0/vendor/serde_json/CONTRIBUTING.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/CONTRIBUTING.md 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,46 @@ +# Contributing to Serde + +Serde welcomes contribution from everyone in the form of suggestions, bug +reports, pull requests, and feedback. This document gives some guidance if you +are thinking of helping us. + +## Submitting bug reports and feature requests + +Serde development is spread across lots of repositories. In general, prefer to +open issues against the main [serde-rs/serde] repository unless the topic is +clearly specific to JSON. + +[serde-rs/serde]: https://github.com/serde-rs/serde + +When reporting a bug or asking for help, please include enough details so that +the people helping you can reproduce the behavior you are seeing. For some tips +on how to approach this, read about how to produce a [Minimal, Complete, and +Verifiable example]. + +[Minimal, Complete, and Verifiable example]: https://stackoverflow.com/help/mcve + +When making a feature request, please make it clear what problem you intend to +solve with the feature, any ideas for how Serde could support solving that +problem, any possible alternatives, and any disadvantages. + +## Running the test suite + +We encourage you to check that the test suite passes locally before submitting a +pull request with your changes. If anything does not pass, typically it will be +easier to iterate and fix it locally than waiting for the CI servers to run +tests for you. + +The test suite requires a nightly compiler. + +```sh +# Run the full test suite, including doc test and compile-tests +cargo test +``` + +## Conduct + +In all Serde-related forums, we follow the [Rust Code of Conduct]. For +escalation or moderation issues please contact Erick (erick.tryzelaar@gmail.com) +instead of the Rust moderation team. + +[Rust Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct diff -Nru cargo-0.58.0/vendor/serde_json/README.md cargo-0.60.0ubuntu1/vendor/serde_json/README.md --- cargo-0.58.0/vendor/serde_json/README.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -330,17 +330,20 @@ Serde is one of the most widely used Rust libraries so any place that Rustaceans congregate will be able to help you out. For chat, consider trying the -[#general] or [#beginners] channels of the unofficial community Discord, the -[#rust-usage] channel of the official Rust Project Discord, or the -[#general][zulip] stream in Zulip. For asynchronous, consider the [\[rust\] tag -on StackOverflow][stackoverflow], the [/r/rust] subreddit which has a pinned -weekly easy questions post, or the Rust [Discourse forum][discourse]. It's -acceptable to file a support issue in this repo but they tend not to get as many -eyes as any of the above and may get closed without a response after some time. +[#rust-questions] or [#rust-beginners] channels of the unofficial community +Discord (invite: ), the [#rust-usage] or +[#beginners] channels of the official Rust Project Discord (invite: +), or the [#general][zulip] stream in Zulip. For +asynchronous, consider the [\[rust\] tag on StackOverflow][stackoverflow], the +[/r/rust] subreddit which has a pinned weekly easy questions post, or the Rust +[Discourse forum][discourse]. It's acceptable to file a support issue in this +repo but they tend not to get as many eyes as any of the above and may get +closed without a response after some time. -[#general]: https://discord.com/channels/273534239310479360/274215136414400513 -[#beginners]: https://discord.com/channels/273534239310479360/273541522815713281 +[#rust-questions]: https://discord.com/channels/273534239310479360/274215136414400513 +[#rust-beginners]: https://discord.com/channels/273534239310479360/273541522815713281 [#rust-usage]: https://discord.com/channels/442252698964721669/443150878111694848 +[#beginners]: https://discord.com/channels/442252698964721669/448238009733742612 [zulip]: https://rust-lang.zulipchat.com/#narrow/stream/122651-general [stackoverflow]: https://stackoverflow.com/questions/tagged/rust [/r/rust]: https://www.reddit.com/r/rust diff -Nru cargo-0.58.0/vendor/serde_json/src/de.rs cargo-0.60.0ubuntu1/vendor/serde_json/src/de.rs --- cargo-0.58.0/vendor/serde_json/src/de.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/src/de.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2184,10 +2184,18 @@ } #[inline] - fn deserialize_newtype_struct(self, _name: &'static str, visitor: V) -> Result + fn deserialize_newtype_struct(self, name: &'static str, visitor: V) -> Result where V: de::Visitor<'de>, { + #[cfg(feature = "raw_value")] + { + if name == crate::raw::TOKEN { + return self.de.deserialize_raw_value(visitor); + } + } + + let _ = name; visitor.visit_newtype_struct(self) } diff -Nru cargo-0.58.0/vendor/serde_json/src/lexical/math.rs cargo-0.60.0ubuntu1/vendor/serde_json/src/lexical/math.rs --- cargo-0.58.0/vendor/serde_json/src/lexical/math.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/src/lexical/math.rs 2022-04-20 13:48:09.000000000 +0000 @@ -594,7 +594,7 @@ // Iteratively add elements from y to x. let mut carry = false; - for (xi, yi) in (&mut x[xstart..]).iter_mut().zip(y.iter()) { + for (xi, yi) in x[xstart..].iter_mut().zip(y.iter()) { // Only one op of the two can overflow, since we added at max // Limb::max_value() + Limb::max_value(). Add the previous carry, // and store the current carry for the next. diff -Nru cargo-0.58.0/vendor/serde_json/src/lib.rs cargo-0.60.0ubuntu1/vendor/serde_json/src/lib.rs --- cargo-0.58.0/vendor/serde_json/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -300,7 +300,7 @@ //! [macro]: https://docs.serde.rs/serde_json/macro.json.html //! [`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core -#![doc(html_root_url = "https://docs.rs/serde_json/1.0.75")] +#![doc(html_root_url = "https://docs.rs/serde_json/1.0.79")] // Ignored clippy lints #![allow( clippy::collapsible_else_if, @@ -314,6 +314,8 @@ clippy::match_single_binding, clippy::needless_doctest_main, clippy::needless_late_init, + // clippy bug: https://github.com/rust-lang/rust-clippy/issues/8366 + clippy::ptr_arg, clippy::return_self_not_must_use, clippy::transmute_ptr_to_ptr, clippy::unnecessary_wraps, diff -Nru cargo-0.58.0/vendor/serde_json/src/raw.rs cargo-0.60.0ubuntu1/vendor/serde_json/src/raw.rs --- cargo-0.58.0/vendor/serde_json/src/raw.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/src/raw.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,4 +1,7 @@ use crate::error::Error; +use alloc::borrow::ToOwned; +use alloc::boxed::Box; +use alloc::string::String; use core::fmt::{self, Debug, Display}; use core::mem; use serde::de::value::BorrowedStrDeserializer; @@ -446,9 +449,10 @@ where E: de::Error, { - self.visit_string(s.to_owned()) + Ok(RawValue::from_owned(s.to_owned().into_boxed_str())) } + #[cfg(any(feature = "std", feature = "alloc"))] fn visit_string(self, s: String) -> Result where E: de::Error, diff -Nru cargo-0.58.0/vendor/serde_json/src/read.rs cargo-0.60.0ubuntu1/vendor/serde_json/src/read.rs --- cargo-0.58.0/vendor/serde_json/src/read.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/src/read.rs 2022-04-20 13:48:09.000000000 +0000 @@ -954,34 +954,15 @@ match ch { b'"' | b'\\' | b'/' | b'b' | b'f' | b'n' | b'r' | b't' => {} - b'u' => match tri!(read.decode_hex_escape()) { - 0xDC00..=0xDFFF => { - return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape); - } + b'u' => { + // At this point we don't care if the codepoint is valid. We just + // want to consume it. We don't actually know what is valid or not + // at this point, because that depends on if this string will + // ultimately be parsed into a string or a byte buffer in the "real" + // parse. - // Non-BMP characters are encoded as a sequence of - // two hex escapes, representing UTF-16 surrogates. - n1 @ 0xD800..=0xDBFF => { - if tri!(next_or_eof(read)) != b'\\' { - return error(read, ErrorCode::UnexpectedEndOfHexEscape); - } - if tri!(next_or_eof(read)) != b'u' { - return error(read, ErrorCode::UnexpectedEndOfHexEscape); - } - - let n2 = tri!(read.decode_hex_escape()); - if n2 < 0xDC00 || n2 > 0xDFFF { - return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape); - } - - let n = (((n1 - 0xD800) as u32) << 10 | (n2 - 0xDC00) as u32) + 0x1_0000; - if char::from_u32(n).is_none() { - return error(read, ErrorCode::InvalidUnicodeCodePoint); - } - } - - _ => {} - }, + tri!(read.decode_hex_escape()); + } _ => { return error(read, ErrorCode::InvalidEscape); } diff -Nru cargo-0.58.0/vendor/serde_json/src/ser.rs cargo-0.60.0ubuntu1/vendor/serde_json/src/ser.rs --- cargo-0.58.0/vendor/serde_json/src/ser.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/src/ser.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1548,6 +1548,13 @@ ) -> Result { Err(ser::Error::custom("expected RawValue")) } + + fn collect_str(self, value: &T) -> Result + where + T: ?Sized + Display, + { + self.serialize_str(&value.to_string()) + } } /// Represents a character escape code in a type-safe manner. diff -Nru cargo-0.58.0/vendor/serde_json/src/value/de.rs cargo-0.60.0ubuntu1/vendor/serde_json/src/value/de.rs --- cargo-0.58.0/vendor/serde_json/src/value/de.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/src/value/de.rs 2022-04-20 13:48:09.000000000 +0000 @@ -4,6 +4,8 @@ use crate::value::Value; use alloc::borrow::{Cow, ToOwned}; use alloc::string::String; +#[cfg(feature = "raw_value")] +use alloc::string::ToString; use alloc::vec::{self, Vec}; use core::fmt; use core::slice; diff -Nru cargo-0.58.0/vendor/serde_json/src/value/ser.rs cargo-0.60.0ubuntu1/vendor/serde_json/src/value/ser.rs --- cargo-0.58.0/vendor/serde_json/src/value/ser.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/src/value/ser.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1020,4 +1020,11 @@ ) -> Result { Err(invalid_raw_value()) } + + fn collect_str(self, value: &T) -> Result + where + T: ?Sized + Display, + { + self.serialize_str(&value.to_string()) + } } diff -Nru cargo-0.58.0/vendor/serde_json/tests/compiletest.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/compiletest.rs --- cargo-0.58.0/vendor/serde_json/tests/compiletest.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/compiletest.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,7 @@ +#[rustversion::attr(not(nightly), ignore)] +#[cfg_attr(miri, ignore)] +#[test] +fn ui() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/ui/*.rs"); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/debug.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/debug.rs --- cargo-0.58.0/vendor/serde_json/tests/debug.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/debug.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,68 @@ +use serde_json::{json, Number, Value}; + +#[test] +fn number() { + assert_eq!(format!("{:?}", Number::from(1)), "Number(1)"); + assert_eq!(format!("{:?}", Number::from(-1)), "Number(-1)"); + assert_eq!( + format!("{:?}", Number::from_f64(1.0).unwrap()), + "Number(1.0)" + ); +} + +#[test] +fn value_null() { + assert_eq!(format!("{:?}", json!(null)), "Null"); +} + +#[test] +fn value_bool() { + assert_eq!(format!("{:?}", json!(true)), "Bool(true)"); + assert_eq!(format!("{:?}", json!(false)), "Bool(false)"); +} + +#[test] +fn value_number() { + assert_eq!(format!("{:?}", json!(1)), "Number(1)"); + assert_eq!(format!("{:?}", json!(-1)), "Number(-1)"); + assert_eq!(format!("{:?}", json!(1.0)), "Number(1.0)"); +} + +#[test] +fn value_string() { + assert_eq!(format!("{:?}", json!("s")), "String(\"s\")"); +} + +#[test] +fn value_array() { + assert_eq!(format!("{:?}", json!([])), "Array([])"); +} + +#[test] +fn value_object() { + assert_eq!(format!("{:?}", json!({})), "Object({})"); +} + +#[test] +fn error() { + let err = serde_json::from_str::("{0}").unwrap_err(); + let expected = "Error(\"key must be a string\", line: 1, column: 2)"; + assert_eq!(format!("{:?}", err), expected); +} + +const INDENTED_EXPECTED: &str = r#"Object({ + "array": Array([ + Number( + 0, + ), + Number( + 1, + ), + ]), +})"#; + +#[test] +fn indented() { + let j = json!({ "array": [0, 1] }); + assert_eq!(format!("{:#?}", j), INDENTED_EXPECTED); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/lexical/algorithm.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/algorithm.rs --- cargo-0.58.0/vendor/serde_json/tests/lexical/algorithm.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/algorithm.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,110 @@ +// Adapted from https://github.com/Alexhuszagh/rust-lexical. + +use crate::lexical::algorithm::*; +use crate::lexical::num::Float; + +#[test] +fn float_fast_path_test() { + // valid + let mantissa = (1 << f32::MANTISSA_SIZE) - 1; + let (min_exp, max_exp) = f32::exponent_limit(); + for exp in min_exp..=max_exp { + let f = fast_path::(mantissa, exp); + assert!(f.is_some(), "should be valid {:?}.", (mantissa, exp)); + } + + // Check slightly above valid exponents + let f = fast_path::(123, 15); + assert_eq!(f, Some(1.23e+17)); + + // Exponent is 1 too high, pushes over the mantissa. + let f = fast_path::(123, 16); + assert!(f.is_none()); + + // Mantissa is too large, checked_mul should overflow. + let f = fast_path::(mantissa, 11); + assert!(f.is_none()); + + // invalid exponents + let (min_exp, max_exp) = f32::exponent_limit(); + let f = fast_path::(mantissa, min_exp - 1); + assert!(f.is_none(), "exponent under min_exp"); + + let f = fast_path::(mantissa, max_exp + 1); + assert!(f.is_none(), "exponent above max_exp"); +} + +#[test] +fn double_fast_path_test() { + // valid + let mantissa = (1 << f64::MANTISSA_SIZE) - 1; + let (min_exp, max_exp) = f64::exponent_limit(); + for exp in min_exp..=max_exp { + let f = fast_path::(mantissa, exp); + assert!(f.is_some(), "should be valid {:?}.", (mantissa, exp)); + } + + // invalid exponents + let (min_exp, max_exp) = f64::exponent_limit(); + let f = fast_path::(mantissa, min_exp - 1); + assert!(f.is_none(), "exponent under min_exp"); + + let f = fast_path::(mantissa, max_exp + 1); + assert!(f.is_none(), "exponent above max_exp"); + + assert_eq!( + Some(0.04628372940652459), + fast_path::(4628372940652459, -17) + ); + assert_eq!(None, fast_path::(26383446160308229, -272)); +} + +#[test] +fn moderate_path_test() { + let (f, valid) = moderate_path::(1234567890, -1, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 123456789.0); + + let (f, valid) = moderate_path::(1234567891, -1, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 123456789.1); + + let (f, valid) = moderate_path::(12345678912, -2, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 123456789.12); + + let (f, valid) = moderate_path::(123456789123, -3, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 123456789.123); + + let (f, valid) = moderate_path::(1234567891234, -4, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 123456789.1234); + + let (f, valid) = moderate_path::(12345678912345, -5, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 123456789.12345); + + let (f, valid) = moderate_path::(123456789123456, -6, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 123456789.123456); + + let (f, valid) = moderate_path::(1234567891234567, -7, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 123456789.1234567); + + let (f, valid) = moderate_path::(12345678912345679, -8, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 123456789.12345679); + + let (f, valid) = moderate_path::(4628372940652459, -17, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 0.04628372940652459); + + let (f, valid) = moderate_path::(26383446160308229, -272, false); + assert!(valid, "should be valid"); + assert_eq!(f.into_float::(), 2.6383446160308229e-256); + + let (_, valid) = moderate_path::(26383446160308230, -272, false); + assert!(!valid, "should be invalid"); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/lexical/exponent.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/exponent.rs --- cargo-0.58.0/vendor/serde_json/tests/lexical/exponent.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/exponent.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,54 @@ +// Adapted from https://github.com/Alexhuszagh/rust-lexical. + +use crate::lexical::exponent::*; + +#[test] +fn scientific_exponent_test() { + // 0 digits in the integer + assert_eq!(scientific_exponent(0, 0, 5), -6); + assert_eq!(scientific_exponent(10, 0, 5), 4); + assert_eq!(scientific_exponent(-10, 0, 5), -16); + + // >0 digits in the integer + assert_eq!(scientific_exponent(0, 1, 5), 0); + assert_eq!(scientific_exponent(0, 2, 5), 1); + assert_eq!(scientific_exponent(0, 2, 20), 1); + assert_eq!(scientific_exponent(10, 2, 20), 11); + assert_eq!(scientific_exponent(-10, 2, 20), -9); + + // Underflow + assert_eq!( + scientific_exponent(i32::min_value(), 0, 0), + i32::min_value() + ); + assert_eq!( + scientific_exponent(i32::min_value(), 0, 5), + i32::min_value() + ); + + // Overflow + assert_eq!( + scientific_exponent(i32::max_value(), 0, 0), + i32::max_value() - 1 + ); + assert_eq!( + scientific_exponent(i32::max_value(), 5, 0), + i32::max_value() + ); +} + +#[test] +fn mantissa_exponent_test() { + assert_eq!(mantissa_exponent(10, 5, 0), 5); + assert_eq!(mantissa_exponent(0, 5, 0), -5); + assert_eq!( + mantissa_exponent(i32::max_value(), 5, 0), + i32::max_value() - 5 + ); + assert_eq!(mantissa_exponent(i32::max_value(), 0, 5), i32::max_value()); + assert_eq!(mantissa_exponent(i32::min_value(), 5, 0), i32::min_value()); + assert_eq!( + mantissa_exponent(i32::min_value(), 0, 5), + i32::min_value() + 5 + ); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/lexical/float.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/float.rs --- cargo-0.58.0/vendor/serde_json/tests/lexical/float.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/float.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,581 @@ +// Adapted from https://github.com/Alexhuszagh/rust-lexical. + +use crate::lexical::float::ExtendedFloat; +use crate::lexical::rounding::round_nearest_tie_even; +use std::{f32, f64}; + +// NORMALIZE + +fn check_normalize(mant: u64, exp: i32, shift: u32, r_mant: u64, r_exp: i32) { + let mut x = ExtendedFloat { mant, exp }; + assert_eq!(x.normalize(), shift); + assert_eq!( + x, + ExtendedFloat { + mant: r_mant, + exp: r_exp + } + ); +} + +#[test] +fn normalize_test() { + // F32 + // 0 + check_normalize(0, 0, 0, 0, 0); + + // min value + check_normalize(1, -149, 63, 9223372036854775808, -212); + + // 1.0e-40 + check_normalize(71362, -149, 47, 10043308644012916736, -196); + + // 1.0e-20 + check_normalize(12379400, -90, 40, 13611294244890214400, -130); + + // 1.0 + check_normalize(8388608, -23, 40, 9223372036854775808, -63); + + // 1e20 + check_normalize(11368684, 43, 40, 12500000250510966784, 3); + + // max value + check_normalize(16777213, 104, 40, 18446740775174668288, 64); + + // F64 + + // min value + check_normalize(1, -1074, 63, 9223372036854775808, -1137); + + // 1.0e-250 + check_normalize(6448907850777164, -883, 11, 13207363278391631872, -894); + + // 1.0e-150 + check_normalize(7371020360979573, -551, 11, 15095849699286165504, -562); + + // 1.0e-45 + check_normalize(6427752177035961, -202, 11, 13164036458569648128, -213); + + // 1.0e-40 + check_normalize(4903985730770844, -185, 11, 10043362776618688512, -196); + + // 1.0e-20 + check_normalize(6646139978924579, -119, 11, 13611294676837537792, -130); + + // 1.0 + check_normalize(4503599627370496, -52, 11, 9223372036854775808, -63); + + // 1e20 + check_normalize(6103515625000000, 14, 11, 12500000000000000000, 3); + + // 1e40 + check_normalize(8271806125530277, 80, 11, 16940658945086007296, 69); + + // 1e150 + check_normalize(5503284107318959, 446, 11, 11270725851789228032, 435); + + // 1e250 + check_normalize(6290184345309700, 778, 11, 12882297539194265600, 767); + + // max value + check_normalize(9007199254740991, 971, 11, 18446744073709549568, 960); +} + +// ROUND + +fn check_round_to_f32(mant: u64, exp: i32, r_mant: u64, r_exp: i32) { + let mut x = ExtendedFloat { mant, exp }; + x.round_to_native::(round_nearest_tie_even); + assert_eq!( + x, + ExtendedFloat { + mant: r_mant, + exp: r_exp + } + ); +} + +#[test] +fn round_to_f32_test() { + // This is lossy, so some of these values are **slightly** rounded. + + // underflow + check_round_to_f32(9223372036854775808, -213, 0, -149); + + // min value + check_round_to_f32(9223372036854775808, -212, 1, -149); + + // 1.0e-40 + check_round_to_f32(10043308644012916736, -196, 71362, -149); + + // 1.0e-20 + check_round_to_f32(13611294244890214400, -130, 12379400, -90); + + // 1.0 + check_round_to_f32(9223372036854775808, -63, 8388608, -23); + + // 1e20 + check_round_to_f32(12500000250510966784, 3, 11368684, 43); + + // max value + check_round_to_f32(18446740775174668288, 64, 16777213, 104); + + // overflow + check_round_to_f32(18446740775174668288, 65, 16777213, 105); +} + +fn check_round_to_f64(mant: u64, exp: i32, r_mant: u64, r_exp: i32) { + let mut x = ExtendedFloat { mant, exp }; + x.round_to_native::(round_nearest_tie_even); + assert_eq!( + x, + ExtendedFloat { + mant: r_mant, + exp: r_exp + } + ); +} + +#[test] +fn round_to_f64_test() { + // This is lossy, so some of these values are **slightly** rounded. + + // underflow + check_round_to_f64(9223372036854775808, -1138, 0, -1074); + + // min value + check_round_to_f64(9223372036854775808, -1137, 1, -1074); + + // 1.0e-250 + check_round_to_f64(15095849699286165504, -562, 7371020360979573, -551); + + // 1.0e-150 + check_round_to_f64(15095849699286165504, -562, 7371020360979573, -551); + + // 1.0e-45 + check_round_to_f64(13164036458569648128, -213, 6427752177035961, -202); + + // 1.0e-40 + check_round_to_f64(10043362776618688512, -196, 4903985730770844, -185); + + // 1.0e-20 + check_round_to_f64(13611294676837537792, -130, 6646139978924579, -119); + + // 1.0 + check_round_to_f64(9223372036854775808, -63, 4503599627370496, -52); + + // 1e20 + check_round_to_f64(12500000000000000000, 3, 6103515625000000, 14); + + // 1e40 + check_round_to_f64(16940658945086007296, 69, 8271806125530277, 80); + + // 1e150 + check_round_to_f64(11270725851789228032, 435, 5503284107318959, 446); + + // 1e250 + check_round_to_f64(12882297539194265600, 767, 6290184345309700, 778); + + // max value + check_round_to_f64(18446744073709549568, 960, 9007199254740991, 971); + + // Bug fixes + // 1.2345e-308 + check_round_to_f64(10234494226754558294, -1086, 2498655817078750, -1074); +} + +fn assert_normalized_eq(mut x: ExtendedFloat, mut y: ExtendedFloat) { + x.normalize(); + y.normalize(); + assert_eq!(x, y); +} + +#[test] +fn from_float() { + let values: [f32; 26] = [ + 1e-40, 2e-40, 1e-35, 2e-35, 1e-30, 2e-30, 1e-25, 2e-25, 1e-20, 2e-20, 1e-15, 2e-15, 1e-10, + 2e-10, 1e-5, 2e-5, 1.0, 2.0, 1e5, 2e5, 1e10, 2e10, 1e15, 2e15, 1e20, 2e20, + ]; + for value in &values { + assert_normalized_eq( + ExtendedFloat::from_float(*value), + ExtendedFloat::from_float(*value as f64), + ); + } +} + +// TO + +// Sample of interesting numbers to check during standard test builds. +const INTEGERS: [u64; 32] = [ + 0, // 0x0 + 1, // 0x1 + 7, // 0x7 + 15, // 0xF + 112, // 0x70 + 119, // 0x77 + 127, // 0x7F + 240, // 0xF0 + 247, // 0xF7 + 255, // 0xFF + 2032, // 0x7F0 + 2039, // 0x7F7 + 2047, // 0x7FF + 4080, // 0xFF0 + 4087, // 0xFF7 + 4095, // 0xFFF + 65520, // 0xFFF0 + 65527, // 0xFFF7 + 65535, // 0xFFFF + 1048560, // 0xFFFF0 + 1048567, // 0xFFFF7 + 1048575, // 0xFFFFF + 16777200, // 0xFFFFF0 + 16777207, // 0xFFFFF7 + 16777215, // 0xFFFFFF + 268435440, // 0xFFFFFF0 + 268435447, // 0xFFFFFF7 + 268435455, // 0xFFFFFFF + 4294967280, // 0xFFFFFFF0 + 4294967287, // 0xFFFFFFF7 + 4294967295, // 0xFFFFFFFF + 18446744073709551615, // 0xFFFFFFFFFFFFFFFF +]; + +#[test] +fn to_f32_test() { + // underflow + let x = ExtendedFloat { + mant: 9223372036854775808, + exp: -213, + }; + assert_eq!(x.into_float::(), 0.0); + + // min value + let x = ExtendedFloat { + mant: 9223372036854775808, + exp: -212, + }; + assert_eq!(x.into_float::(), 1e-45); + + // 1.0e-40 + let x = ExtendedFloat { + mant: 10043308644012916736, + exp: -196, + }; + assert_eq!(x.into_float::(), 1e-40); + + // 1.0e-20 + let x = ExtendedFloat { + mant: 13611294244890214400, + exp: -130, + }; + assert_eq!(x.into_float::(), 1e-20); + + // 1.0 + let x = ExtendedFloat { + mant: 9223372036854775808, + exp: -63, + }; + assert_eq!(x.into_float::(), 1.0); + + // 1e20 + let x = ExtendedFloat { + mant: 12500000250510966784, + exp: 3, + }; + assert_eq!(x.into_float::(), 1e20); + + // max value + let x = ExtendedFloat { + mant: 18446740775174668288, + exp: 64, + }; + assert_eq!(x.into_float::(), 3.402823e38); + + // almost max, high exp + let x = ExtendedFloat { + mant: 1048575, + exp: 108, + }; + assert_eq!(x.into_float::(), 3.4028204e38); + + // max value + 1 + let x = ExtendedFloat { + mant: 16777216, + exp: 104, + }; + assert_eq!(x.into_float::(), f32::INFINITY); + + // max value + 1 + let x = ExtendedFloat { + mant: 1048576, + exp: 108, + }; + assert_eq!(x.into_float::(), f32::INFINITY); + + // 1e40 + let x = ExtendedFloat { + mant: 16940658945086007296, + exp: 69, + }; + assert_eq!(x.into_float::(), f32::INFINITY); + + // Integers. + for int in &INTEGERS { + let fp = ExtendedFloat { mant: *int, exp: 0 }; + assert_eq!(fp.into_float::(), *int as f32, "{:?} as f32", *int); + } +} + +#[test] +fn to_f64_test() { + // underflow + let x = ExtendedFloat { + mant: 9223372036854775808, + exp: -1138, + }; + assert_eq!(x.into_float::(), 0.0); + + // min value + let x = ExtendedFloat { + mant: 9223372036854775808, + exp: -1137, + }; + assert_eq!(x.into_float::(), 5e-324); + + // 1.0e-250 + let x = ExtendedFloat { + mant: 13207363278391631872, + exp: -894, + }; + assert_eq!(x.into_float::(), 1e-250); + + // 1.0e-150 + let x = ExtendedFloat { + mant: 15095849699286165504, + exp: -562, + }; + assert_eq!(x.into_float::(), 1e-150); + + // 1.0e-45 + let x = ExtendedFloat { + mant: 13164036458569648128, + exp: -213, + }; + assert_eq!(x.into_float::(), 1e-45); + + // 1.0e-40 + let x = ExtendedFloat { + mant: 10043362776618688512, + exp: -196, + }; + assert_eq!(x.into_float::(), 1e-40); + + // 1.0e-20 + let x = ExtendedFloat { + mant: 13611294676837537792, + exp: -130, + }; + assert_eq!(x.into_float::(), 1e-20); + + // 1.0 + let x = ExtendedFloat { + mant: 9223372036854775808, + exp: -63, + }; + assert_eq!(x.into_float::(), 1.0); + + // 1e20 + let x = ExtendedFloat { + mant: 12500000000000000000, + exp: 3, + }; + assert_eq!(x.into_float::(), 1e20); + + // 1e40 + let x = ExtendedFloat { + mant: 16940658945086007296, + exp: 69, + }; + assert_eq!(x.into_float::(), 1e40); + + // 1e150 + let x = ExtendedFloat { + mant: 11270725851789228032, + exp: 435, + }; + assert_eq!(x.into_float::(), 1e150); + + // 1e250 + let x = ExtendedFloat { + mant: 12882297539194265600, + exp: 767, + }; + assert_eq!(x.into_float::(), 1e250); + + // max value + let x = ExtendedFloat { + mant: 9007199254740991, + exp: 971, + }; + assert_eq!(x.into_float::(), 1.7976931348623157e308); + + // max value + let x = ExtendedFloat { + mant: 18446744073709549568, + exp: 960, + }; + assert_eq!(x.into_float::(), 1.7976931348623157e308); + + // overflow + let x = ExtendedFloat { + mant: 9007199254740992, + exp: 971, + }; + assert_eq!(x.into_float::(), f64::INFINITY); + + // overflow + let x = ExtendedFloat { + mant: 18446744073709549568, + exp: 961, + }; + assert_eq!(x.into_float::(), f64::INFINITY); + + // Underflow + // Adapted from failures in strtod. + let x = ExtendedFloat { + exp: -1139, + mant: 18446744073709550712, + }; + assert_eq!(x.into_float::(), 0.0); + + let x = ExtendedFloat { + exp: -1139, + mant: 18446744073709551460, + }; + assert_eq!(x.into_float::(), 0.0); + + let x = ExtendedFloat { + exp: -1138, + mant: 9223372036854776103, + }; + assert_eq!(x.into_float::(), 5e-324); + + // Integers. + for int in &INTEGERS { + let fp = ExtendedFloat { mant: *int, exp: 0 }; + assert_eq!(fp.into_float::(), *int as f64, "{:?} as f64", *int); + } +} + +// OPERATIONS + +fn check_mul(a: ExtendedFloat, b: ExtendedFloat, c: ExtendedFloat) { + let r = a.mul(&b); + assert_eq!(r, c); +} + +#[test] +fn mul_test() { + // Normalized (64-bit mantissa) + let a = ExtendedFloat { + mant: 13164036458569648128, + exp: -213, + }; + let b = ExtendedFloat { + mant: 9223372036854775808, + exp: -62, + }; + let c = ExtendedFloat { + mant: 6582018229284824064, + exp: -211, + }; + check_mul(a, b, c); + + // Check with integers + // 64-bit mantissa + let mut a = ExtendedFloat { mant: 10, exp: 0 }; + let mut b = ExtendedFloat { mant: 10, exp: 0 }; + a.normalize(); + b.normalize(); + assert_eq!(a.mul(&b).into_float::(), 100.0); + + // Check both values need high bits set. + let a = ExtendedFloat { + mant: 1 << 32, + exp: -31, + }; + let b = ExtendedFloat { + mant: 1 << 32, + exp: -31, + }; + assert_eq!(a.mul(&b).into_float::(), 4.0); + + // Check both values need high bits set. + let a = ExtendedFloat { + mant: 10 << 31, + exp: -31, + }; + let b = ExtendedFloat { + mant: 10 << 31, + exp: -31, + }; + assert_eq!(a.mul(&b).into_float::(), 100.0); +} + +fn check_imul(mut a: ExtendedFloat, b: ExtendedFloat, c: ExtendedFloat) { + a.imul(&b); + assert_eq!(a, c); +} + +#[test] +fn imul_test() { + // Normalized (64-bit mantissa) + let a = ExtendedFloat { + mant: 13164036458569648128, + exp: -213, + }; + let b = ExtendedFloat { + mant: 9223372036854775808, + exp: -62, + }; + let c = ExtendedFloat { + mant: 6582018229284824064, + exp: -211, + }; + check_imul(a, b, c); + + // Check with integers + // 64-bit mantissa + let mut a = ExtendedFloat { mant: 10, exp: 0 }; + let mut b = ExtendedFloat { mant: 10, exp: 0 }; + a.normalize(); + b.normalize(); + a.imul(&b); + assert_eq!(a.into_float::(), 100.0); + + // Check both values need high bits set. + let mut a = ExtendedFloat { + mant: 1 << 32, + exp: -31, + }; + let b = ExtendedFloat { + mant: 1 << 32, + exp: -31, + }; + a.imul(&b); + assert_eq!(a.into_float::(), 4.0); + + // Check both values need high bits set. + let mut a = ExtendedFloat { + mant: 10 << 31, + exp: -31, + }; + let b = ExtendedFloat { + mant: 10 << 31, + exp: -31, + }; + a.imul(&b); + assert_eq!(a.into_float::(), 100.0); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/lexical/math.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/math.rs --- cargo-0.58.0/vendor/serde_json/tests/lexical/math.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/math.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,211 @@ +// Adapted from https://github.com/Alexhuszagh/rust-lexical. + +use crate::lexical::math::{Limb, Math}; +use std::cmp; + +#[derive(Clone, Default)] +struct Bigint { + data: Vec, +} + +impl Math for Bigint { + fn data(&self) -> &Vec { + &self.data + } + + fn data_mut(&mut self) -> &mut Vec { + &mut self.data + } +} + +#[cfg(limb_width_32)] +pub(crate) fn from_u32(x: &[u32]) -> Vec { + x.iter().cloned().collect() +} + +#[cfg(limb_width_64)] +pub(crate) fn from_u32(x: &[u32]) -> Vec { + let mut v = Vec::::default(); + for xi in x.chunks(2) { + match xi.len() { + 1 => v.push(xi[0] as u64), + 2 => v.push(((xi[1] as u64) << 32) | (xi[0] as u64)), + _ => unreachable!(), + } + } + + v +} + +#[test] +fn compare_test() { + // Simple + let x = Bigint { + data: from_u32(&[1]), + }; + let y = Bigint { + data: from_u32(&[2]), + }; + assert_eq!(x.compare(&y), cmp::Ordering::Less); + assert_eq!(x.compare(&x), cmp::Ordering::Equal); + assert_eq!(y.compare(&x), cmp::Ordering::Greater); + + // Check asymmetric + let x = Bigint { + data: from_u32(&[5, 1]), + }; + let y = Bigint { + data: from_u32(&[2]), + }; + assert_eq!(x.compare(&y), cmp::Ordering::Greater); + assert_eq!(x.compare(&x), cmp::Ordering::Equal); + assert_eq!(y.compare(&x), cmp::Ordering::Less); + + // Check when we use reverse ordering properly. + let x = Bigint { + data: from_u32(&[5, 1, 9]), + }; + let y = Bigint { + data: from_u32(&[6, 2, 8]), + }; + assert_eq!(x.compare(&y), cmp::Ordering::Greater); + assert_eq!(x.compare(&x), cmp::Ordering::Equal); + assert_eq!(y.compare(&x), cmp::Ordering::Less); + + // Complex scenario, check it properly uses reverse ordering. + let x = Bigint { + data: from_u32(&[0, 1, 9]), + }; + let y = Bigint { + data: from_u32(&[4294967295, 0, 9]), + }; + assert_eq!(x.compare(&y), cmp::Ordering::Greater); + assert_eq!(x.compare(&x), cmp::Ordering::Equal); + assert_eq!(y.compare(&x), cmp::Ordering::Less); +} + +#[test] +fn hi64_test() { + assert_eq!(Bigint::from_u64(0xA).hi64(), (0xA000000000000000, false)); + assert_eq!(Bigint::from_u64(0xAB).hi64(), (0xAB00000000000000, false)); + assert_eq!( + Bigint::from_u64(0xAB00000000).hi64(), + (0xAB00000000000000, false) + ); + assert_eq!( + Bigint::from_u64(0xA23456789A).hi64(), + (0xA23456789A000000, false) + ); +} + +#[test] +fn bit_length_test() { + let x = Bigint { + data: from_u32(&[0, 0, 0, 1]), + }; + assert_eq!(x.bit_length(), 97); + + let x = Bigint { + data: from_u32(&[0, 0, 0, 3]), + }; + assert_eq!(x.bit_length(), 98); + + let x = Bigint { + data: from_u32(&[1 << 31]), + }; + assert_eq!(x.bit_length(), 32); +} + +#[test] +fn iadd_small_test() { + // Overflow check (single) + // This should set all the internal data values to 0, the top + // value to (1<<31), and the bottom value to (4>>1). + // This is because the max_value + 1 leads to all 0s, we set the + // topmost bit to 1. + let mut x = Bigint { + data: from_u32(&[4294967295]), + }; + x.iadd_small(5); + assert_eq!(x.data, from_u32(&[4, 1])); + + // No overflow, single value + let mut x = Bigint { + data: from_u32(&[5]), + }; + x.iadd_small(7); + assert_eq!(x.data, from_u32(&[12])); + + // Single carry, internal overflow + let mut x = Bigint::from_u64(0x80000000FFFFFFFF); + x.iadd_small(7); + assert_eq!(x.data, from_u32(&[6, 0x80000001])); + + // Double carry, overflow + let mut x = Bigint::from_u64(0xFFFFFFFFFFFFFFFF); + x.iadd_small(7); + assert_eq!(x.data, from_u32(&[6, 0, 1])); +} + +#[test] +fn imul_small_test() { + // No overflow check, 1-int. + let mut x = Bigint { + data: from_u32(&[5]), + }; + x.imul_small(7); + assert_eq!(x.data, from_u32(&[35])); + + // No overflow check, 2-ints. + let mut x = Bigint::from_u64(0x4000000040000); + x.imul_small(5); + assert_eq!(x.data, from_u32(&[0x00140000, 0x140000])); + + // Overflow, 1 carry. + let mut x = Bigint { + data: from_u32(&[0x33333334]), + }; + x.imul_small(5); + assert_eq!(x.data, from_u32(&[4, 1])); + + // Overflow, 1 carry, internal. + let mut x = Bigint::from_u64(0x133333334); + x.imul_small(5); + assert_eq!(x.data, from_u32(&[4, 6])); + + // Overflow, 2 carries. + let mut x = Bigint::from_u64(0x3333333333333334); + x.imul_small(5); + assert_eq!(x.data, from_u32(&[4, 0, 1])); +} + +#[test] +fn shl_test() { + // Pattern generated via `''.join(["1" +"0"*i for i in range(20)])` + let mut big = Bigint { + data: from_u32(&[0xD2210408]), + }; + big.ishl(5); + assert_eq!(big.data, from_u32(&[0x44208100, 0x1A])); + big.ishl(32); + assert_eq!(big.data, from_u32(&[0, 0x44208100, 0x1A])); + big.ishl(27); + assert_eq!(big.data, from_u32(&[0, 0, 0xD2210408])); + + // 96-bits of previous pattern + let mut big = Bigint { + data: from_u32(&[0x20020010, 0x8040100, 0xD2210408]), + }; + big.ishl(5); + assert_eq!(big.data, from_u32(&[0x400200, 0x802004, 0x44208101, 0x1A])); + big.ishl(32); + assert_eq!( + big.data, + from_u32(&[0, 0x400200, 0x802004, 0x44208101, 0x1A]) + ); + big.ishl(27); + assert_eq!( + big.data, + from_u32(&[0, 0, 0x20020010, 0x8040100, 0xD2210408]) + ); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/lexical/num.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/num.rs --- cargo-0.58.0/vendor/serde_json/tests/lexical/num.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/num.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,76 @@ +// Adapted from https://github.com/Alexhuszagh/rust-lexical. + +use crate::lexical::num::{AsPrimitive, Float, Integer, Number}; + +fn check_as_primitive(t: T) { + let _: u32 = t.as_u32(); + let _: u64 = t.as_u64(); + let _: u128 = t.as_u128(); + let _: usize = t.as_usize(); + let _: f32 = t.as_f32(); + let _: f64 = t.as_f64(); +} + +#[test] +fn as_primitive_test() { + check_as_primitive(1u32); + check_as_primitive(1u64); + check_as_primitive(1u128); + check_as_primitive(1usize); + check_as_primitive(1f32); + check_as_primitive(1f64); +} + +fn check_number(x: T, y: T) { + // Copy, partialeq, partialord + let _ = x; + assert!(x < y); + assert!(x != y); + + // Operations + let _ = y + x; + + // Conversions already tested. +} + +#[test] +fn number_test() { + check_number(1u32, 5); + check_number(1u64, 5); + check_number(1u128, 5); + check_number(1usize, 5); + check_number(1f32, 5.0); + check_number(1f64, 5.0); +} + +fn check_integer(x: T) { + // Bitwise operations + let _ = x & T::ZERO; +} + +#[test] +fn integer_test() { + check_integer(65u32); + check_integer(65u64); + check_integer(65u128); + check_integer(65usize); +} + +fn check_float(x: T) { + // Check functions + let _ = x.pow10(5); + let _ = x.to_bits(); + assert!(T::from_bits(x.to_bits()) == x); + + // Check properties + let _ = x.to_bits() & T::SIGN_MASK; + let _ = x.to_bits() & T::EXPONENT_MASK; + let _ = x.to_bits() & T::HIDDEN_BIT_MASK; + let _ = x.to_bits() & T::MANTISSA_MASK; +} + +#[test] +fn float_test() { + check_float(123f32); + check_float(123f64); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/lexical/parse.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/parse.rs --- cargo-0.58.0/vendor/serde_json/tests/lexical/parse.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/parse.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,204 @@ +// Adapted from https://github.com/Alexhuszagh/rust-lexical. + +use crate::lexical::num::Float; +use crate::lexical::parse::{parse_concise_float, parse_truncated_float}; +use core::f64; +use core::fmt::Debug; + +fn check_concise_float(mantissa: u64, exponent: i32, expected: F) +where + F: Float + Debug, +{ + assert_eq!(parse_concise_float::(mantissa, exponent), expected); +} + +fn check_truncated_float(integer: &str, fraction: &str, exponent: i32, expected: F) +where + F: Float + Debug, +{ + let integer = integer.as_bytes(); + let fraction = fraction.as_bytes(); + assert_eq!( + parse_truncated_float::(integer, fraction, exponent), + expected, + ); +} + +#[test] +fn parse_f32_test() { + check_concise_float(0, 0, 0.0_f32); + check_concise_float(12345, -4, 1.2345_f32); + check_concise_float(12345, -3, 12.345_f32); + check_concise_float(123456789, -4, 12345.6789_f32); + check_concise_float(12345, 6, 1.2345e10_f32); + check_concise_float(12345, -42, 1.2345e-38_f32); + + // Check expected rounding, using borderline cases. + // Round-down, halfway + check_concise_float(16777216, 0, 16777216.0_f32); + check_concise_float(16777217, 0, 16777216.0_f32); + check_concise_float(16777218, 0, 16777218.0_f32); + check_concise_float(33554432, 0, 33554432.0_f32); + check_concise_float(33554434, 0, 33554432.0_f32); + check_concise_float(33554436, 0, 33554436.0_f32); + check_concise_float(17179869184, 0, 17179869184.0_f32); + check_concise_float(17179870208, 0, 17179869184.0_f32); + check_concise_float(17179871232, 0, 17179871232.0_f32); + + // Round-up, halfway + check_concise_float(16777218, 0, 16777218.0_f32); + check_concise_float(16777219, 0, 16777220.0_f32); + check_concise_float(16777220, 0, 16777220.0_f32); + + check_concise_float(33554436, 0, 33554436.0_f32); + check_concise_float(33554438, 0, 33554440.0_f32); + check_concise_float(33554440, 0, 33554440.0_f32); + + check_concise_float(17179871232, 0, 17179871232.0_f32); + check_concise_float(17179872256, 0, 17179873280.0_f32); + check_concise_float(17179873280, 0, 17179873280.0_f32); + + // Round-up, above halfway + check_concise_float(33554435, 0, 33554436.0_f32); + check_concise_float(17179870209, 0, 17179871232.0_f32); + + // Check exactly halfway, round-up at halfway + check_truncated_float("1", "00000017881393432617187499", 0, 1.0000001_f32); + check_truncated_float("1", "000000178813934326171875", 0, 1.0000002_f32); + check_truncated_float("1", "00000017881393432617187501", 0, 1.0000002_f32); +} + +#[test] +fn parse_f64_test() { + check_concise_float(0, 0, 0.0_f64); + check_concise_float(12345, -4, 1.2345_f64); + check_concise_float(12345, -3, 12.345_f64); + check_concise_float(123456789, -4, 12345.6789_f64); + check_concise_float(12345, 6, 1.2345e10_f64); + check_concise_float(12345, -312, 1.2345e-308_f64); + + // Check expected rounding, using borderline cases. + // Round-down, halfway + check_concise_float(9007199254740992, 0, 9007199254740992.0_f64); + check_concise_float(9007199254740993, 0, 9007199254740992.0_f64); + check_concise_float(9007199254740994, 0, 9007199254740994.0_f64); + + check_concise_float(18014398509481984, 0, 18014398509481984.0_f64); + check_concise_float(18014398509481986, 0, 18014398509481984.0_f64); + check_concise_float(18014398509481988, 0, 18014398509481988.0_f64); + + check_concise_float(9223372036854775808, 0, 9223372036854775808.0_f64); + check_concise_float(9223372036854776832, 0, 9223372036854775808.0_f64); + check_concise_float(9223372036854777856, 0, 9223372036854777856.0_f64); + + check_truncated_float( + "11417981541647679048466287755595961091061972992", + "", + 0, + 11417981541647679048466287755595961091061972992.0_f64, + ); + check_truncated_float( + "11417981541647680316116887983825362587765178368", + "", + 0, + 11417981541647679048466287755595961091061972992.0_f64, + ); + check_truncated_float( + "11417981541647681583767488212054764084468383744", + "", + 0, + 11417981541647681583767488212054764084468383744.0_f64, + ); + + // Round-up, halfway + check_concise_float(9007199254740994, 0, 9007199254740994.0_f64); + check_concise_float(9007199254740995, 0, 9007199254740996.0_f64); + check_concise_float(9007199254740996, 0, 9007199254740996.0_f64); + + check_concise_float(18014398509481988, 0, 18014398509481988.0_f64); + check_concise_float(18014398509481990, 0, 18014398509481992.0_f64); + check_concise_float(18014398509481992, 0, 18014398509481992.0_f64); + + check_concise_float(9223372036854777856, 0, 9223372036854777856.0_f64); + check_concise_float(9223372036854778880, 0, 9223372036854779904.0_f64); + check_concise_float(9223372036854779904, 0, 9223372036854779904.0_f64); + + check_truncated_float( + "11417981541647681583767488212054764084468383744", + "", + 0, + 11417981541647681583767488212054764084468383744.0_f64, + ); + check_truncated_float( + "11417981541647682851418088440284165581171589120", + "", + 0, + 11417981541647684119068688668513567077874794496.0_f64, + ); + check_truncated_float( + "11417981541647684119068688668513567077874794496", + "", + 0, + 11417981541647684119068688668513567077874794496.0_f64, + ); + + // Round-up, above halfway + check_concise_float(9223372036854776833, 0, 9223372036854777856.0_f64); + check_truncated_float( + "11417981541647680316116887983825362587765178369", + "", + 0, + 11417981541647681583767488212054764084468383744.0_f64, + ); + + // Rounding error + // Adapted from failures in strtod. + check_concise_float(22250738585072014, -324, 2.2250738585072014e-308_f64); + check_truncated_float("2", "2250738585072011360574097967091319759348195463516456480234261097248222220210769455165295239081350879141491589130396211068700864386945946455276572074078206217433799881410632673292535522868813721490129811224514518898490572223072852551331557550159143974763979834118019993239625482890171070818506906306666559949382757725720157630626906633326475653000092458883164330377797918696120494973903778297049050510806099407302629371289589500035837999672072543043602840788957717961509455167482434710307026091446215722898802581825451803257070188608721131280795122334262883686223215037756666225039825343359745688844239002654981983854879482922068947216898310996983658468140228542433306603398508864458040010349339704275671864433837704860378616227717385456230658746790140867233276367187499", -308, 2.225073858507201e-308_f64); + check_truncated_float("2", "22507385850720113605740979670913197593481954635164564802342610972482222202107694551652952390813508791414915891303962110687008643869459464552765720740782062174337998814106326732925355228688137214901298112245145188984905722230728525513315575501591439747639798341180199932396254828901710708185069063066665599493827577257201576306269066333264756530000924588831643303777979186961204949739037782970490505108060994073026293712895895000358379996720725430436028407889577179615094551674824347103070260914462157228988025818254518032570701886087211312807951223342628836862232150377566662250398253433597456888442390026549819838548794829220689472168983109969836584681402285424333066033985088644580400103493397042756718644338377048603786162277173854562306587467901408672332763671875", -308, 2.2250738585072014e-308_f64); + check_truncated_float("2", "2250738585072011360574097967091319759348195463516456480234261097248222220210769455165295239081350879141491589130396211068700864386945946455276572074078206217433799881410632673292535522868813721490129811224514518898490572223072852551331557550159143974763979834118019993239625482890171070818506906306666559949382757725720157630626906633326475653000092458883164330377797918696120494973903778297049050510806099407302629371289589500035837999672072543043602840788957717961509455167482434710307026091446215722898802581825451803257070188608721131280795122334262883686223215037756666225039825343359745688844239002654981983854879482922068947216898310996983658468140228542433306603398508864458040010349339704275671864433837704860378616227717385456230658746790140867233276367187501", -308, 2.2250738585072014e-308_f64); + check_truncated_float("179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791", "9999999999999999999999999999999999999999999999999999999999999999999999", 0, 1.7976931348623157e+308_f64); + check_truncated_float("7", "4109846876186981626485318930233205854758970392148714663837852375101326090531312779794975454245398856969484704316857659638998506553390969459816219401617281718945106978546710679176872575177347315553307795408549809608457500958111373034747658096871009590975442271004757307809711118935784838675653998783503015228055934046593739791790738723868299395818481660169122019456499931289798411362062484498678713572180352209017023903285791732520220528974020802906854021606612375549983402671300035812486479041385743401875520901590172592547146296175134159774938718574737870961645638908718119841271673056017045493004705269590165763776884908267986972573366521765567941072508764337560846003984904972149117463085539556354188641513168478436313080237596295773983001708984374999", -324, 5.0e-324_f64); + check_truncated_float("7", "4109846876186981626485318930233205854758970392148714663837852375101326090531312779794975454245398856969484704316857659638998506553390969459816219401617281718945106978546710679176872575177347315553307795408549809608457500958111373034747658096871009590975442271004757307809711118935784838675653998783503015228055934046593739791790738723868299395818481660169122019456499931289798411362062484498678713572180352209017023903285791732520220528974020802906854021606612375549983402671300035812486479041385743401875520901590172592547146296175134159774938718574737870961645638908718119841271673056017045493004705269590165763776884908267986972573366521765567941072508764337560846003984904972149117463085539556354188641513168478436313080237596295773983001708984375", -324, 1.0e-323_f64); + check_truncated_float("7", "4109846876186981626485318930233205854758970392148714663837852375101326090531312779794975454245398856969484704316857659638998506553390969459816219401617281718945106978546710679176872575177347315553307795408549809608457500958111373034747658096871009590975442271004757307809711118935784838675653998783503015228055934046593739791790738723868299395818481660169122019456499931289798411362062484498678713572180352209017023903285791732520220528974020802906854021606612375549983402671300035812486479041385743401875520901590172592547146296175134159774938718574737870961645638908718119841271673056017045493004705269590165763776884908267986972573366521765567941072508764337560846003984904972149117463085539556354188641513168478436313080237596295773983001708984375001", -324, 1.0e-323_f64); + check_truncated_float("", "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024703282292062327208828439643411068618252990130716238221279284125033775363510437593264991818081799618989828234772285886546332835517796989819938739800539093906315035659515570226392290858392449105184435931802849936536152500319370457678249219365623669863658480757001585769269903706311928279558551332927834338409351978015531246597263579574622766465272827220056374006485499977096599470454020828166226237857393450736339007967761930577506740176324673600968951340535537458516661134223766678604162159680461914467291840300530057530849048765391711386591646239524912623653881879636239373280423891018672348497668235089863388587925628302755995657524455507255189313690836254779186948667994968324049705821028513185451396213837722826145437693412532098591327667236328125", 0, 0.0_f64); + + // Rounding error + // Adapted from: + // https://www.exploringbinary.com/how-glibc-strtod-works/ + check_truncated_float("", "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022250738585072008890245868760858598876504231122409594654935248025624400092282356951787758888037591552642309780950434312085877387158357291821993020294379224223559819827501242041788969571311791082261043971979604000454897391938079198936081525613113376149842043271751033627391549782731594143828136275113838604094249464942286316695429105080201815926642134996606517803095075913058719846423906068637102005108723282784678843631944515866135041223479014792369585208321597621066375401613736583044193603714778355306682834535634005074073040135602968046375918583163124224521599262546494300836851861719422417646455137135420132217031370496583210154654068035397417906022589503023501937519773030945763173210852507299305089761582519159720757232455434770912461317493580281734466552734375", 0, 2.2250738585072011e-308_f64); + + // Rounding error + // Adapted from test-parse-random failures. + check_concise_float(1009, -31, 1.009e-28_f64); + check_concise_float(18294, 304, f64::INFINITY); + + // Rounding error + // Adapted from a @dangrabcad's issue #20. + check_concise_float(7689539722041643, 149, 7.689539722041643e164_f64); + check_truncated_float("768953972204164300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "", 0, 7.689539722041643e164_f64); + check_truncated_float("768953972204164300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "0", 0, 7.689539722041643e164_f64); + + // Check other cases similar to @dangrabcad's issue #20. + check_truncated_float("9223372036854776833", "0", 0, 9223372036854777856.0_f64); + check_truncated_float( + "11417981541647680316116887983825362587765178369", + "0", + 0, + 11417981541647681583767488212054764084468383744.0_f64, + ); + check_concise_float(90071992547409950, -1, 9007199254740996.0_f64); + check_concise_float(180143985094819900, -1, 18014398509481992.0_f64); + check_truncated_float("9223372036854778880", "0", 0, 9223372036854779904.0_f64); + check_truncated_float( + "11417981541647682851418088440284165581171589120", + "0", + 0, + 11417981541647684119068688668513567077874794496.0_f64, + ); + + // Check other cases ostensibly identified via proptest. + check_truncated_float("71610528364411830000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "0", 0, 71610528364411830000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0_f64); + check_truncated_float("126769393745745060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "0", 0, 126769393745745060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0_f64); + check_truncated_float("38652960461239320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "0", 0, 38652960461239320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0_f64); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/lexical/rounding.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/rounding.rs --- cargo-0.58.0/vendor/serde_json/tests/lexical/rounding.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical/rounding.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,316 @@ +// Adapted from https://github.com/Alexhuszagh/rust-lexical. + +use crate::lexical::float::ExtendedFloat; +use crate::lexical::num::Float; +use crate::lexical::rounding::*; + +// MASKS + +#[test] +fn lower_n_mask_test() { + assert_eq!(lower_n_mask(0u64), 0b0); + assert_eq!(lower_n_mask(1u64), 0b1); + assert_eq!(lower_n_mask(2u64), 0b11); + assert_eq!(lower_n_mask(10u64), 0b1111111111); + assert_eq!(lower_n_mask(32u64), 0b11111111111111111111111111111111); +} + +#[test] +fn lower_n_halfway_test() { + assert_eq!(lower_n_halfway(0u64), 0b0); + assert_eq!(lower_n_halfway(1u64), 0b1); + assert_eq!(lower_n_halfway(2u64), 0b10); + assert_eq!(lower_n_halfway(10u64), 0b1000000000); + assert_eq!(lower_n_halfway(32u64), 0b10000000000000000000000000000000); +} + +#[test] +fn nth_bit_test() { + assert_eq!(nth_bit(0u64), 0b1); + assert_eq!(nth_bit(1u64), 0b10); + assert_eq!(nth_bit(2u64), 0b100); + assert_eq!(nth_bit(10u64), 0b10000000000); + assert_eq!(nth_bit(31u64), 0b10000000000000000000000000000000); +} + +#[test] +fn internal_n_mask_test() { + assert_eq!(internal_n_mask(1u64, 0u64), 0b0); + assert_eq!(internal_n_mask(1u64, 1u64), 0b1); + assert_eq!(internal_n_mask(2u64, 1u64), 0b10); + assert_eq!(internal_n_mask(4u64, 2u64), 0b1100); + assert_eq!(internal_n_mask(10u64, 2u64), 0b1100000000); + assert_eq!(internal_n_mask(10u64, 4u64), 0b1111000000); + assert_eq!( + internal_n_mask(32u64, 4u64), + 0b11110000000000000000000000000000 + ); +} + +// NEAREST ROUNDING + +#[test] +fn round_nearest_test() { + // Check exactly halfway (b'1100000') + let mut fp = ExtendedFloat { mant: 0x60, exp: 0 }; + let (above, halfway) = round_nearest(&mut fp, 6); + assert!(!above); + assert!(halfway); + assert_eq!(fp.mant, 1); + + // Check above halfway (b'1100001') + let mut fp = ExtendedFloat { mant: 0x61, exp: 0 }; + let (above, halfway) = round_nearest(&mut fp, 6); + assert!(above); + assert!(!halfway); + assert_eq!(fp.mant, 1); + + // Check below halfway (b'1011111') + let mut fp = ExtendedFloat { mant: 0x5F, exp: 0 }; + let (above, halfway) = round_nearest(&mut fp, 6); + assert!(!above); + assert!(!halfway); + assert_eq!(fp.mant, 1); +} + +// DIRECTED ROUNDING + +#[test] +fn round_downward_test() { + // b0000000 + let mut fp = ExtendedFloat { mant: 0x00, exp: 0 }; + round_downward(&mut fp, 6); + assert_eq!(fp.mant, 0); + + // b1000000 + let mut fp = ExtendedFloat { mant: 0x40, exp: 0 }; + round_downward(&mut fp, 6); + assert_eq!(fp.mant, 1); + + // b1100000 + let mut fp = ExtendedFloat { mant: 0x60, exp: 0 }; + round_downward(&mut fp, 6); + assert_eq!(fp.mant, 1); + + // b1110000 + let mut fp = ExtendedFloat { mant: 0x70, exp: 0 }; + round_downward(&mut fp, 6); + assert_eq!(fp.mant, 1); +} + +#[test] +fn round_nearest_tie_even_test() { + // Check round-up, halfway + let mut fp = ExtendedFloat { mant: 0x60, exp: 0 }; + round_nearest_tie_even(&mut fp, 6); + assert_eq!(fp.mant, 2); + + // Check round-down, halfway + let mut fp = ExtendedFloat { mant: 0x20, exp: 0 }; + round_nearest_tie_even(&mut fp, 6); + assert_eq!(fp.mant, 0); + + // Check round-up, above halfway + let mut fp = ExtendedFloat { mant: 0x61, exp: 0 }; + round_nearest_tie_even(&mut fp, 6); + assert_eq!(fp.mant, 2); + + let mut fp = ExtendedFloat { mant: 0x21, exp: 0 }; + round_nearest_tie_even(&mut fp, 6); + assert_eq!(fp.mant, 1); + + // Check round-down, below halfway + let mut fp = ExtendedFloat { mant: 0x5F, exp: 0 }; + round_nearest_tie_even(&mut fp, 6); + assert_eq!(fp.mant, 1); + + let mut fp = ExtendedFloat { mant: 0x1F, exp: 0 }; + round_nearest_tie_even(&mut fp, 6); + assert_eq!(fp.mant, 0); +} + +// HIGH-LEVEL + +#[test] +fn round_to_float_test() { + // Denormal + let mut fp = ExtendedFloat { + mant: 1 << 63, + exp: f64::DENORMAL_EXPONENT - 15, + }; + round_to_float::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, 1 << 48); + assert_eq!(fp.exp, f64::DENORMAL_EXPONENT); + + // Halfway, round-down (b'1000000000000000000000000000000000000000000000000000010000000000') + let mut fp = ExtendedFloat { + mant: 0x8000000000000400, + exp: -63, + }; + round_to_float::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, 1 << 52); + assert_eq!(fp.exp, -52); + + // Halfway, round-up (b'1000000000000000000000000000000000000000000000000000110000000000') + let mut fp = ExtendedFloat { + mant: 0x8000000000000C00, + exp: -63, + }; + round_to_float::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, (1 << 52) + 2); + assert_eq!(fp.exp, -52); + + // Above halfway + let mut fp = ExtendedFloat { + mant: 0x8000000000000401, + exp: -63, + }; + round_to_float::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, (1 << 52) + 1); + assert_eq!(fp.exp, -52); + + let mut fp = ExtendedFloat { + mant: 0x8000000000000C01, + exp: -63, + }; + round_to_float::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, (1 << 52) + 2); + assert_eq!(fp.exp, -52); + + // Below halfway + let mut fp = ExtendedFloat { + mant: 0x80000000000003FF, + exp: -63, + }; + round_to_float::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, 1 << 52); + assert_eq!(fp.exp, -52); + + let mut fp = ExtendedFloat { + mant: 0x8000000000000BFF, + exp: -63, + }; + round_to_float::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, (1 << 52) + 1); + assert_eq!(fp.exp, -52); +} + +#[test] +fn avoid_overflow_test() { + // Avoid overflow, fails by 1 + let mut fp = ExtendedFloat { + mant: 0xFFFFFFFFFFFF, + exp: f64::MAX_EXPONENT + 5, + }; + avoid_overflow::(&mut fp); + assert_eq!(fp.mant, 0xFFFFFFFFFFFF); + assert_eq!(fp.exp, f64::MAX_EXPONENT + 5); + + // Avoid overflow, succeeds + let mut fp = ExtendedFloat { + mant: 0xFFFFFFFFFFFF, + exp: f64::MAX_EXPONENT + 4, + }; + avoid_overflow::(&mut fp); + assert_eq!(fp.mant, 0x1FFFFFFFFFFFE0); + assert_eq!(fp.exp, f64::MAX_EXPONENT - 1); +} + +#[test] +fn round_to_native_test() { + // Overflow + let mut fp = ExtendedFloat { + mant: 0xFFFFFFFFFFFF, + exp: f64::MAX_EXPONENT + 4, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, 0x1FFFFFFFFFFFE0); + assert_eq!(fp.exp, f64::MAX_EXPONENT - 1); + + // Need denormal + let mut fp = ExtendedFloat { + mant: 1, + exp: f64::DENORMAL_EXPONENT + 48, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, 1 << 48); + assert_eq!(fp.exp, f64::DENORMAL_EXPONENT); + + // Halfway, round-down (b'10000000000000000000000000000000000000000000000000000100000') + let mut fp = ExtendedFloat { + mant: 0x400000000000020, + exp: -58, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, 1 << 52); + assert_eq!(fp.exp, -52); + + // Halfway, round-up (b'10000000000000000000000000000000000000000000000000001100000') + let mut fp = ExtendedFloat { + mant: 0x400000000000060, + exp: -58, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, (1 << 52) + 2); + assert_eq!(fp.exp, -52); + + // Above halfway + let mut fp = ExtendedFloat { + mant: 0x400000000000021, + exp: -58, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, (1 << 52) + 1); + assert_eq!(fp.exp, -52); + + let mut fp = ExtendedFloat { + mant: 0x400000000000061, + exp: -58, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, (1 << 52) + 2); + assert_eq!(fp.exp, -52); + + // Below halfway + let mut fp = ExtendedFloat { + mant: 0x40000000000001F, + exp: -58, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, 1 << 52); + assert_eq!(fp.exp, -52); + + let mut fp = ExtendedFloat { + mant: 0x40000000000005F, + exp: -58, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, (1 << 52) + 1); + assert_eq!(fp.exp, -52); + + // Underflow + // Adapted from failures in strtod. + let mut fp = ExtendedFloat { + exp: -1139, + mant: 18446744073709550712, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, 0); + assert_eq!(fp.exp, 0); + + let mut fp = ExtendedFloat { + exp: -1139, + mant: 18446744073709551460, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, 0); + assert_eq!(fp.exp, 0); + + let mut fp = ExtendedFloat { + exp: -1138, + mant: 9223372036854776103, + }; + round_to_native::(&mut fp, round_nearest_tie_even); + assert_eq!(fp.mant, 1); + assert_eq!(fp.exp, -1074); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/lexical.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical.rs --- cargo-0.58.0/vendor/serde_json/tests/lexical.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/lexical.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,52 @@ +#![allow( + clippy::cast_lossless, + clippy::cast_possible_truncation, + clippy::cast_possible_wrap, + clippy::cast_precision_loss, + clippy::cast_sign_loss, + clippy::comparison_chain, + clippy::doc_markdown, + clippy::excessive_precision, + clippy::float_cmp, + clippy::if_not_else, + clippy::module_name_repetitions, + clippy::needless_late_init, + clippy::shadow_unrelated, + clippy::similar_names, + clippy::single_match_else, + clippy::too_many_lines, + clippy::unreadable_literal, + clippy::unseparated_literal_suffix, + clippy::wildcard_imports +)] + +extern crate alloc; + +#[path = "../src/lexical/mod.rs"] +mod lexical; + +mod lib { + pub use std::vec::Vec; + pub use std::{cmp, iter, mem, ops}; +} + +#[path = "lexical/algorithm.rs"] +mod algorithm; + +#[path = "lexical/exponent.rs"] +mod exponent; + +#[path = "lexical/float.rs"] +mod float; + +#[path = "lexical/math.rs"] +mod math; + +#[path = "lexical/num.rs"] +mod num; + +#[path = "lexical/parse.rs"] +mod parse; + +#[path = "lexical/rounding.rs"] +mod rounding; diff -Nru cargo-0.58.0/vendor/serde_json/tests/macros/mod.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/macros/mod.rs --- cargo-0.58.0/vendor/serde_json/tests/macros/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/macros/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,59 @@ +macro_rules! json_str { + ([]) => { + "[]" + }; + ([ $e0:tt $(, $e:tt)* $(,)? ]) => { + concat!("[", + json_str!($e0), + $(",", json_str!($e),)* + "]") + }; + ({}) => { + "{}" + }; + ({ $k0:tt : $v0:tt $(, $k:tt : $v:tt)* $(,)? }) => { + concat!("{", + stringify!($k0), ":", json_str!($v0), + $(",", stringify!($k), ":", json_str!($v),)* + "}") + }; + (($other:tt)) => { + $other + }; + ($other:tt) => { + stringify!($other) + }; +} + +macro_rules! pretty_str { + ($json:tt) => { + pretty_str_impl!("", $json) + }; +} + +macro_rules! pretty_str_impl { + ($indent:expr, []) => { + "[]" + }; + ($indent:expr, [ $e0:tt $(, $e:tt)* $(,)? ]) => { + concat!("[\n ", + $indent, pretty_str_impl!(concat!(" ", $indent), $e0), + $(",\n ", $indent, pretty_str_impl!(concat!(" ", $indent), $e),)* + "\n", $indent, "]") + }; + ($indent:expr, {}) => { + "{}" + }; + ($indent:expr, { $k0:tt : $v0:tt $(, $k:tt : $v:tt)* $(,)? }) => { + concat!("{\n ", + $indent, stringify!($k0), ": ", pretty_str_impl!(concat!(" ", $indent), $v0), + $(",\n ", $indent, stringify!($k), ": ", pretty_str_impl!(concat!(" ", $indent), $v),)* + "\n", $indent, "}") + }; + ($indent:expr, ($other:tt)) => { + $other + }; + ($indent:expr, $other:tt) => { + stringify!($other) + }; +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/map.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/map.rs --- cargo-0.58.0/vendor/serde_json/tests/map.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/map.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,47 @@ +use serde_json::{from_str, Map, Value}; + +#[test] +fn test_preserve_order() { + // Sorted order + #[cfg(not(feature = "preserve_order"))] + const EXPECTED: &[&str] = &["a", "b", "c"]; + + // Insertion order + #[cfg(feature = "preserve_order")] + const EXPECTED: &[&str] = &["b", "a", "c"]; + + let v: Value = from_str(r#"{"b":null,"a":null,"c":null}"#).unwrap(); + let keys: Vec<_> = v.as_object().unwrap().keys().collect(); + assert_eq!(keys, EXPECTED); +} + +#[test] +fn test_append() { + // Sorted order + #[cfg(not(feature = "preserve_order"))] + const EXPECTED: &[&str] = &["a", "b", "c"]; + + // Insertion order + #[cfg(feature = "preserve_order")] + const EXPECTED: &[&str] = &["b", "a", "c"]; + + let mut v: Value = from_str(r#"{"b":null,"a":null,"c":null}"#).unwrap(); + let val = v.as_object_mut().unwrap(); + let mut m = Map::new(); + m.append(val); + let keys: Vec<_> = m.keys().collect(); + + assert_eq!(keys, EXPECTED); + assert!(val.is_empty()); +} + +#[cfg(not(no_btreemap_retain))] +#[test] +fn test_retain() { + let mut v: Value = from_str(r#"{"b":null,"a":null,"c":null}"#).unwrap(); + let val = v.as_object_mut().unwrap(); + val.retain(|k, _| k.as_str() != "b"); + + let keys: Vec<_> = val.keys().collect(); + assert_eq!(keys, &["a", "c"]); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/regression/issue520.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/regression/issue520.rs --- cargo-0.58.0/vendor/serde_json/tests/regression/issue520.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/regression/issue520.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,20 @@ +#![allow(clippy::float_cmp)] + +use serde_derive::{Serialize, Deserialize}; + +#[derive(Serialize, Deserialize, Debug)] +#[serde(tag = "type", content = "data")] +enum E { + Float(f32), +} + +#[test] +fn test() { + let e = E::Float(159.1); + let v = serde_json::to_value(e).unwrap(); + let e = serde_json::from_value::(v).unwrap(); + + match e { + E::Float(f) => assert_eq!(f, 159.1), + } +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/regression/issue795.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/regression/issue795.rs --- cargo-0.58.0/vendor/serde_json/tests/regression/issue795.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/regression/issue795.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,57 @@ +use serde::de::{ + Deserialize, Deserializer, EnumAccess, IgnoredAny, MapAccess, VariantAccess, Visitor, +}; +use serde_json::json; +use std::fmt; + +#[derive(Debug)] +pub enum Enum { + Variant { x: u8 }, +} + +impl<'de> Deserialize<'de> for Enum { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct EnumVisitor; + + impl<'de> Visitor<'de> for EnumVisitor { + type Value = Enum; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("enum Enum") + } + + fn visit_enum(self, data: A) -> Result + where + A: EnumAccess<'de>, + { + let (IgnoredAny, variant) = data.variant()?; + variant.struct_variant(&["x"], self) + } + + fn visit_map(self, mut data: A) -> Result + where + A: MapAccess<'de>, + { + let mut x = 0; + if let Some((IgnoredAny, value)) = data.next_entry()? { + x = value; + } + Ok(Enum::Variant { x }) + } + } + + deserializer.deserialize_enum("Enum", &["Variant"], EnumVisitor) + } +} + +#[test] +fn test() { + let s = r#" {"Variant":{"x":0,"y":0}} "#; + assert!(serde_json::from_str::(s).is_err()); + + let j = json!({"Variant":{"x":0,"y":0}}); + assert!(serde_json::from_value::(j).is_err()); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/regression/issue845.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/regression/issue845.rs --- cargo-0.58.0/vendor/serde_json/tests/regression/issue845.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/regression/issue845.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,72 @@ +use serde::{Deserialize, Deserializer}; +use std::convert::TryFrom; +use std::fmt::{self, Display}; +use std::marker::PhantomData; +use std::str::FromStr; + +pub struct NumberVisitor { + marker: PhantomData, +} + +impl<'de, T> serde::de::Visitor<'de> for NumberVisitor +where + T: TryFrom + TryFrom + FromStr, + >::Error: Display, + >::Error: Display, + ::Err: Display, +{ + type Value = T; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("an integer or string") + } + + fn visit_u64(self, v: u64) -> Result + where + E: serde::de::Error, + { + T::try_from(v).map_err(serde::de::Error::custom) + } + + fn visit_i64(self, v: i64) -> Result + where + E: serde::de::Error, + { + T::try_from(v).map_err(serde::de::Error::custom) + } + + fn visit_str(self, v: &str) -> Result + where + E: serde::de::Error, + { + v.parse().map_err(serde::de::Error::custom) + } +} + +fn deserialize_integer_or_string<'de, D, T>(deserializer: D) -> Result +where + D: Deserializer<'de>, + T: TryFrom + TryFrom + FromStr, + >::Error: Display, + >::Error: Display, + ::Err: Display, +{ + deserializer.deserialize_any(NumberVisitor { + marker: PhantomData, + }) +} + +#[derive(Deserialize, Debug)] +pub struct Struct { + #[serde(deserialize_with = "deserialize_integer_or_string")] + pub i: i64, +} + +#[test] +fn test() { + let j = r#" {"i":100} "#; + println!("{:?}", serde_json::from_str::(j).unwrap()); + + let j = r#" {"i":"100"} "#; + println!("{:?}", serde_json::from_str::(j).unwrap()); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/regression.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/regression.rs --- cargo-0.58.0/vendor/serde_json/tests/regression.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/regression.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,3 @@ +mod regression { + automod::dir!("tests/regression"); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/stream.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/stream.rs --- cargo-0.58.0/vendor/serde_json/tests/stream.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/stream.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,182 @@ +#![cfg(not(feature = "preserve_order"))] + +use serde_json::{json, Deserializer, Value}; + +// Rustfmt issue https://github.com/rust-lang-nursery/rustfmt/issues/2740 +#[rustfmt::skip] +macro_rules! test_stream { + ($data:expr, $ty:ty, |$stream:ident| $test:block) => { + { + let de = Deserializer::from_str($data); + let mut $stream = de.into_iter::<$ty>(); + assert_eq!($stream.byte_offset(), 0); + $test + } + { + let de = Deserializer::from_slice($data.as_bytes()); + let mut $stream = de.into_iter::<$ty>(); + assert_eq!($stream.byte_offset(), 0); + $test + } + { + let mut bytes = $data.as_bytes(); + let de = Deserializer::from_reader(&mut bytes); + let mut $stream = de.into_iter::<$ty>(); + assert_eq!($stream.byte_offset(), 0); + $test + } + }; +} + +#[test] +fn test_json_stream_newlines() { + let data = "{\"x\":39} {\"x\":40}{\"x\":41}\n{\"x\":42}"; + + test_stream!(data, Value, |stream| { + assert_eq!(stream.next().unwrap().unwrap()["x"], 39); + assert_eq!(stream.byte_offset(), 8); + + assert_eq!(stream.next().unwrap().unwrap()["x"], 40); + assert_eq!(stream.byte_offset(), 17); + + assert_eq!(stream.next().unwrap().unwrap()["x"], 41); + assert_eq!(stream.byte_offset(), 25); + + assert_eq!(stream.next().unwrap().unwrap()["x"], 42); + assert_eq!(stream.byte_offset(), 34); + + assert!(stream.next().is_none()); + assert_eq!(stream.byte_offset(), 34); + }); +} + +#[test] +fn test_json_stream_trailing_whitespaces() { + let data = "{\"x\":42} \t\n"; + + test_stream!(data, Value, |stream| { + assert_eq!(stream.next().unwrap().unwrap()["x"], 42); + assert_eq!(stream.byte_offset(), 8); + + assert!(stream.next().is_none()); + assert_eq!(stream.byte_offset(), 11); + }); +} + +#[test] +fn test_json_stream_truncated() { + let data = "{\"x\":40}\n{\"x\":"; + + test_stream!(data, Value, |stream| { + assert_eq!(stream.next().unwrap().unwrap()["x"], 40); + assert_eq!(stream.byte_offset(), 8); + + assert!(stream.next().unwrap().unwrap_err().is_eof()); + assert_eq!(stream.byte_offset(), 9); + }); +} + +#[test] +fn test_json_stream_truncated_decimal() { + let data = "{\"x\":4."; + + test_stream!(data, Value, |stream| { + assert!(stream.next().unwrap().unwrap_err().is_eof()); + assert_eq!(stream.byte_offset(), 0); + }); +} + +#[test] +fn test_json_stream_truncated_negative() { + let data = "{\"x\":-"; + + test_stream!(data, Value, |stream| { + assert!(stream.next().unwrap().unwrap_err().is_eof()); + assert_eq!(stream.byte_offset(), 0); + }); +} + +#[test] +fn test_json_stream_truncated_exponent() { + let data = "{\"x\":4e"; + + test_stream!(data, Value, |stream| { + assert!(stream.next().unwrap().unwrap_err().is_eof()); + assert_eq!(stream.byte_offset(), 0); + }); +} + +#[test] +fn test_json_stream_empty() { + let data = ""; + + test_stream!(data, Value, |stream| { + assert!(stream.next().is_none()); + assert_eq!(stream.byte_offset(), 0); + }); +} + +#[test] +fn test_json_stream_primitive() { + let data = "{} true{}1[]\nfalse\"hey\"2 "; + + test_stream!(data, Value, |stream| { + assert_eq!(stream.next().unwrap().unwrap(), json!({})); + assert_eq!(stream.byte_offset(), 2); + + assert_eq!(stream.next().unwrap().unwrap(), true); + assert_eq!(stream.byte_offset(), 7); + + assert_eq!(stream.next().unwrap().unwrap(), json!({})); + assert_eq!(stream.byte_offset(), 9); + + assert_eq!(stream.next().unwrap().unwrap(), 1); + assert_eq!(stream.byte_offset(), 10); + + assert_eq!(stream.next().unwrap().unwrap(), json!([])); + assert_eq!(stream.byte_offset(), 12); + + assert_eq!(stream.next().unwrap().unwrap(), false); + assert_eq!(stream.byte_offset(), 18); + + assert_eq!(stream.next().unwrap().unwrap(), "hey"); + assert_eq!(stream.byte_offset(), 23); + + assert_eq!(stream.next().unwrap().unwrap(), 2); + assert_eq!(stream.byte_offset(), 24); + + assert!(stream.next().is_none()); + assert_eq!(stream.byte_offset(), 25); + }); +} + +#[test] +fn test_json_stream_invalid_literal() { + let data = "truefalse"; + + test_stream!(data, Value, |stream| { + let second = stream.next().unwrap().unwrap_err(); + assert_eq!(second.to_string(), "trailing characters at line 1 column 5"); + }); +} + +#[test] +fn test_json_stream_invalid_number() { + let data = "1true"; + + test_stream!(data, Value, |stream| { + let second = stream.next().unwrap().unwrap_err(); + assert_eq!(second.to_string(), "trailing characters at line 1 column 2"); + }); +} + +#[test] +fn test_error() { + let data = "true wrong false"; + + test_stream!(data, Value, |stream| { + assert_eq!(stream.next().unwrap().unwrap(), true); + assert!(stream.next().unwrap().is_err()); + assert!(stream.next().is_none()); + }); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/test.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/test.rs --- cargo-0.58.0/vendor/serde_json/tests/test.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/test.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,2386 @@ +#![cfg(not(feature = "preserve_order"))] +#![allow( + clippy::cast_precision_loss, + clippy::excessive_precision, + clippy::float_cmp, + clippy::items_after_statements, + clippy::let_underscore_drop, + clippy::shadow_unrelated, + clippy::too_many_lines, + clippy::unreadable_literal, + clippy::unseparated_literal_suffix, + clippy::vec_init_then_push, + clippy::zero_sized_map_values +)] +#![cfg_attr(feature = "trace-macros", feature(trace_macros))] +#[cfg(feature = "trace-macros")] +trace_macros!(true); + +#[macro_use] +mod macros; + +#[cfg(feature = "raw_value")] +use ref_cast::RefCast; +use serde::de::{self, IgnoredAny, IntoDeserializer}; +use serde::ser::{self, SerializeMap, SerializeSeq, Serializer}; +use serde::{Deserialize, Serialize}; +use serde_bytes::{ByteBuf, Bytes}; +#[cfg(feature = "raw_value")] +use serde_json::value::RawValue; +use serde_json::{ + from_reader, from_slice, from_str, from_value, json, to_string, to_string_pretty, to_value, + to_vec, Deserializer, Number, Value, +}; +use std::collections::hash_map::DefaultHasher; +use std::collections::BTreeMap; +#[cfg(feature = "raw_value")] +use std::collections::HashMap; +use std::fmt::{self, Debug}; +use std::hash::{Hash, Hasher}; +use std::io; +use std::iter; +use std::marker::PhantomData; +use std::mem; +use std::str::FromStr; +use std::string::ToString; +use std::{f32, f64}; +use std::{i16, i32, i64, i8}; +use std::{u16, u32, u64, u8}; + +macro_rules! treemap { + () => { + BTreeMap::new() + }; + ($($k:expr => $v:expr),+) => { + { + let mut m = BTreeMap::new(); + $( + m.insert($k, $v); + )+ + m + } + }; +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +enum Animal { + Dog, + Frog(String, Vec), + Cat { age: usize, name: String }, + AntHive(Vec), +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +struct Inner { + a: (), + b: usize, + c: Vec, +} + +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +struct Outer { + inner: Vec, +} + +fn test_encode_ok(errors: &[(T, &str)]) +where + T: PartialEq + Debug + ser::Serialize, +{ + for &(ref value, out) in errors { + let out = out.to_string(); + + let s = to_string(value).unwrap(); + assert_eq!(s, out); + + let v = to_value(&value).unwrap(); + let s = to_string(&v).unwrap(); + assert_eq!(s, out); + } +} + +fn test_pretty_encode_ok(errors: &[(T, &str)]) +where + T: PartialEq + Debug + ser::Serialize, +{ + for &(ref value, out) in errors { + let out = out.to_string(); + + let s = to_string_pretty(value).unwrap(); + assert_eq!(s, out); + + let v = to_value(&value).unwrap(); + let s = to_string_pretty(&v).unwrap(); + assert_eq!(s, out); + } +} + +#[test] +fn test_write_null() { + let tests = &[((), "null")]; + test_encode_ok(tests); + test_pretty_encode_ok(tests); +} + +#[test] +fn test_write_u64() { + let tests = &[(3u64, "3"), (u64::MAX, &u64::MAX.to_string())]; + test_encode_ok(tests); + test_pretty_encode_ok(tests); +} + +#[test] +fn test_write_i64() { + let tests = &[ + (3i64, "3"), + (-2i64, "-2"), + (-1234i64, "-1234"), + (i64::MIN, &i64::MIN.to_string()), + ]; + test_encode_ok(tests); + test_pretty_encode_ok(tests); +} + +#[test] +fn test_write_f64() { + let tests = &[ + (3.0, "3.0"), + (3.1, "3.1"), + (-1.5, "-1.5"), + (0.5, "0.5"), + (f64::MIN, "-1.7976931348623157e308"), + (f64::MAX, "1.7976931348623157e308"), + (f64::EPSILON, "2.220446049250313e-16"), + ]; + test_encode_ok(tests); + test_pretty_encode_ok(tests); +} + +#[test] +fn test_encode_nonfinite_float_yields_null() { + let v = to_value(::std::f64::NAN).unwrap(); + assert!(v.is_null()); + + let v = to_value(::std::f64::INFINITY).unwrap(); + assert!(v.is_null()); + + let v = to_value(::std::f32::NAN).unwrap(); + assert!(v.is_null()); + + let v = to_value(::std::f32::INFINITY).unwrap(); + assert!(v.is_null()); +} + +#[test] +fn test_write_str() { + let tests = &[("", "\"\""), ("foo", "\"foo\"")]; + test_encode_ok(tests); + test_pretty_encode_ok(tests); +} + +#[test] +fn test_write_bool() { + let tests = &[(true, "true"), (false, "false")]; + test_encode_ok(tests); + test_pretty_encode_ok(tests); +} + +#[test] +fn test_write_char() { + let tests = &[ + ('n', "\"n\""), + ('"', "\"\\\"\""), + ('\\', "\"\\\\\""), + ('/', "\"/\""), + ('\x08', "\"\\b\""), + ('\x0C', "\"\\f\""), + ('\n', "\"\\n\""), + ('\r', "\"\\r\""), + ('\t', "\"\\t\""), + ('\x0B', "\"\\u000b\""), + ('\u{3A3}', "\"\u{3A3}\""), + ]; + test_encode_ok(tests); + test_pretty_encode_ok(tests); +} + +#[test] +fn test_write_list() { + test_encode_ok(&[ + (vec![], "[]"), + (vec![true], "[true]"), + (vec![true, false], "[true,false]"), + ]); + + test_encode_ok(&[ + (vec![vec![], vec![], vec![]], "[[],[],[]]"), + (vec![vec![1, 2, 3], vec![], vec![]], "[[1,2,3],[],[]]"), + (vec![vec![], vec![1, 2, 3], vec![]], "[[],[1,2,3],[]]"), + (vec![vec![], vec![], vec![1, 2, 3]], "[[],[],[1,2,3]]"), + ]); + + test_pretty_encode_ok(&[ + (vec![vec![], vec![], vec![]], pretty_str!([[], [], []])), + ( + vec![vec![1, 2, 3], vec![], vec![]], + pretty_str!([[1, 2, 3], [], []]), + ), + ( + vec![vec![], vec![1, 2, 3], vec![]], + pretty_str!([[], [1, 2, 3], []]), + ), + ( + vec![vec![], vec![], vec![1, 2, 3]], + pretty_str!([[], [], [1, 2, 3]]), + ), + ]); + + test_pretty_encode_ok(&[ + (vec![], "[]"), + (vec![true], pretty_str!([true])), + (vec![true, false], pretty_str!([true, false])), + ]); + + let long_test_list = json!([false, null, ["foo\nbar", 3.5]]); + + test_encode_ok(&[( + long_test_list.clone(), + json_str!([false, null, ["foo\nbar", 3.5]]), + )]); + + test_pretty_encode_ok(&[( + long_test_list, + pretty_str!([false, null, ["foo\nbar", 3.5]]), + )]); +} + +#[test] +fn test_write_object() { + test_encode_ok(&[ + (treemap!(), "{}"), + (treemap!("a".to_string() => true), "{\"a\":true}"), + ( + treemap!( + "a".to_string() => true, + "b".to_string() => false + ), + "{\"a\":true,\"b\":false}", + ), + ]); + + test_encode_ok(&[ + ( + treemap![ + "a".to_string() => treemap![], + "b".to_string() => treemap![], + "c".to_string() => treemap![] + ], + "{\"a\":{},\"b\":{},\"c\":{}}", + ), + ( + treemap![ + "a".to_string() => treemap![ + "a".to_string() => treemap!["a" => vec![1,2,3]], + "b".to_string() => treemap![], + "c".to_string() => treemap![] + ], + "b".to_string() => treemap![], + "c".to_string() => treemap![] + ], + "{\"a\":{\"a\":{\"a\":[1,2,3]},\"b\":{},\"c\":{}},\"b\":{},\"c\":{}}", + ), + ( + treemap![ + "a".to_string() => treemap![], + "b".to_string() => treemap![ + "a".to_string() => treemap!["a" => vec![1,2,3]], + "b".to_string() => treemap![], + "c".to_string() => treemap![] + ], + "c".to_string() => treemap![] + ], + "{\"a\":{},\"b\":{\"a\":{\"a\":[1,2,3]},\"b\":{},\"c\":{}},\"c\":{}}", + ), + ( + treemap![ + "a".to_string() => treemap![], + "b".to_string() => treemap![], + "c".to_string() => treemap![ + "a".to_string() => treemap!["a" => vec![1,2,3]], + "b".to_string() => treemap![], + "c".to_string() => treemap![] + ] + ], + "{\"a\":{},\"b\":{},\"c\":{\"a\":{\"a\":[1,2,3]},\"b\":{},\"c\":{}}}", + ), + ]); + + test_encode_ok(&[(treemap!['c' => ()], "{\"c\":null}")]); + + test_pretty_encode_ok(&[ + ( + treemap![ + "a".to_string() => treemap![], + "b".to_string() => treemap![], + "c".to_string() => treemap![] + ], + pretty_str!({ + "a": {}, + "b": {}, + "c": {} + }), + ), + ( + treemap![ + "a".to_string() => treemap![ + "a".to_string() => treemap!["a" => vec![1,2,3]], + "b".to_string() => treemap![], + "c".to_string() => treemap![] + ], + "b".to_string() => treemap![], + "c".to_string() => treemap![] + ], + pretty_str!({ + "a": { + "a": { + "a": [ + 1, + 2, + 3 + ] + }, + "b": {}, + "c": {} + }, + "b": {}, + "c": {} + }), + ), + ( + treemap![ + "a".to_string() => treemap![], + "b".to_string() => treemap![ + "a".to_string() => treemap!["a" => vec![1,2,3]], + "b".to_string() => treemap![], + "c".to_string() => treemap![] + ], + "c".to_string() => treemap![] + ], + pretty_str!({ + "a": {}, + "b": { + "a": { + "a": [ + 1, + 2, + 3 + ] + }, + "b": {}, + "c": {} + }, + "c": {} + }), + ), + ( + treemap![ + "a".to_string() => treemap![], + "b".to_string() => treemap![], + "c".to_string() => treemap![ + "a".to_string() => treemap!["a" => vec![1,2,3]], + "b".to_string() => treemap![], + "c".to_string() => treemap![] + ] + ], + pretty_str!({ + "a": {}, + "b": {}, + "c": { + "a": { + "a": [ + 1, + 2, + 3 + ] + }, + "b": {}, + "c": {} + } + }), + ), + ]); + + test_pretty_encode_ok(&[ + (treemap!(), "{}"), + ( + treemap!("a".to_string() => true), + pretty_str!({ + "a": true + }), + ), + ( + treemap!( + "a".to_string() => true, + "b".to_string() => false + ), + pretty_str!( { + "a": true, + "b": false + }), + ), + ]); + + let complex_obj = json!({ + "b": [ + {"c": "\x0c\x1f\r"}, + {"d": ""} + ] + }); + + test_encode_ok(&[( + complex_obj.clone(), + json_str!({ + "b": [ + { + "c": (r#""\f\u001f\r""#) + }, + { + "d": "" + } + ] + }), + )]); + + test_pretty_encode_ok(&[( + complex_obj, + pretty_str!({ + "b": [ + { + "c": (r#""\f\u001f\r""#) + }, + { + "d": "" + } + ] + }), + )]); +} + +#[test] +fn test_write_tuple() { + test_encode_ok(&[((5,), "[5]")]); + + test_pretty_encode_ok(&[((5,), pretty_str!([5]))]); + + test_encode_ok(&[((5, (6, "abc")), "[5,[6,\"abc\"]]")]); + + test_pretty_encode_ok(&[((5, (6, "abc")), pretty_str!([5, [6, "abc"]]))]); +} + +#[test] +fn test_write_enum() { + test_encode_ok(&[ + (Animal::Dog, "\"Dog\""), + ( + Animal::Frog("Henry".to_string(), vec![]), + "{\"Frog\":[\"Henry\",[]]}", + ), + ( + Animal::Frog("Henry".to_string(), vec![349]), + "{\"Frog\":[\"Henry\",[349]]}", + ), + ( + Animal::Frog("Henry".to_string(), vec![349, 102]), + "{\"Frog\":[\"Henry\",[349,102]]}", + ), + ( + Animal::Cat { + age: 5, + name: "Kate".to_string(), + }, + "{\"Cat\":{\"age\":5,\"name\":\"Kate\"}}", + ), + ( + Animal::AntHive(vec!["Bob".to_string(), "Stuart".to_string()]), + "{\"AntHive\":[\"Bob\",\"Stuart\"]}", + ), + ]); + + test_pretty_encode_ok(&[ + (Animal::Dog, "\"Dog\""), + ( + Animal::Frog("Henry".to_string(), vec![]), + pretty_str!({ + "Frog": [ + "Henry", + [] + ] + }), + ), + ( + Animal::Frog("Henry".to_string(), vec![349]), + pretty_str!({ + "Frog": [ + "Henry", + [ + 349 + ] + ] + }), + ), + ( + Animal::Frog("Henry".to_string(), vec![349, 102]), + pretty_str!({ + "Frog": [ + "Henry", + [ + 349, + 102 + ] + ] + }), + ), + ]); +} + +#[test] +fn test_write_option() { + test_encode_ok(&[(None, "null"), (Some("jodhpurs"), "\"jodhpurs\"")]); + + test_encode_ok(&[ + (None, "null"), + (Some(vec!["foo", "bar"]), "[\"foo\",\"bar\"]"), + ]); + + test_pretty_encode_ok(&[(None, "null"), (Some("jodhpurs"), "\"jodhpurs\"")]); + + test_pretty_encode_ok(&[ + (None, "null"), + (Some(vec!["foo", "bar"]), pretty_str!(["foo", "bar"])), + ]); +} + +#[test] +fn test_write_newtype_struct() { + #[derive(Serialize, PartialEq, Debug)] + struct Newtype(BTreeMap); + + let inner = Newtype(treemap!(String::from("inner") => 123)); + let outer = treemap!(String::from("outer") => to_value(&inner).unwrap()); + + test_encode_ok(&[(inner, r#"{"inner":123}"#)]); + + test_encode_ok(&[(outer, r#"{"outer":{"inner":123}}"#)]); +} + +#[test] +fn test_deserialize_number_to_untagged_enum() { + #[derive(Eq, PartialEq, Deserialize, Debug)] + #[serde(untagged)] + enum E { + N(i64), + } + + assert_eq!(E::N(0), E::deserialize(Number::from(0)).unwrap()); +} + +fn test_parse_ok(tests: Vec<(&str, T)>) +where + T: Clone + Debug + PartialEq + ser::Serialize + de::DeserializeOwned, +{ + for (s, value) in tests { + let v: T = from_str(s).unwrap(); + assert_eq!(v, value.clone()); + + let v: T = from_slice(s.as_bytes()).unwrap(); + assert_eq!(v, value.clone()); + + // Make sure we can deserialize into a `Value`. + let json_value: Value = from_str(s).unwrap(); + assert_eq!(json_value, to_value(&value).unwrap()); + + // Make sure we can deserialize from a `&Value`. + let v = T::deserialize(&json_value).unwrap(); + assert_eq!(v, value); + + // Make sure we can deserialize from a `Value`. + let v: T = from_value(json_value.clone()).unwrap(); + assert_eq!(v, value); + + // Make sure we can round trip back to `Value`. + let json_value2: Value = from_value(json_value.clone()).unwrap(); + assert_eq!(json_value2, json_value); + + // Make sure we can fully ignore. + let twoline = s.to_owned() + "\n3735928559"; + let mut de = Deserializer::from_str(&twoline); + IgnoredAny::deserialize(&mut de).unwrap(); + assert_eq!(0xDEAD_BEEF, u64::deserialize(&mut de).unwrap()); + + // Make sure every prefix is an EOF error, except that a prefix of a + // number may be a valid number. + if !json_value.is_number() { + for (i, _) in s.trim_end().char_indices() { + assert!(from_str::(&s[..i]).unwrap_err().is_eof()); + assert!(from_str::(&s[..i]).unwrap_err().is_eof()); + } + } + } +} + +// For testing representations that the deserializer accepts but the serializer +// never generates. These do not survive a round-trip through Value. +fn test_parse_unusual_ok(tests: Vec<(&str, T)>) +where + T: Clone + Debug + PartialEq + ser::Serialize + de::DeserializeOwned, +{ + for (s, value) in tests { + let v: T = from_str(s).unwrap(); + assert_eq!(v, value.clone()); + + let v: T = from_slice(s.as_bytes()).unwrap(); + assert_eq!(v, value.clone()); + } +} + +macro_rules! test_parse_err { + ($name:ident::<$($ty:ty),*>($arg:expr) => $expected:expr) => { + let actual = $name::<$($ty),*>($arg).unwrap_err().to_string(); + assert_eq!(actual, $expected, "unexpected {} error", stringify!($name)); + }; +} + +fn test_parse_err(errors: &[(&str, &'static str)]) +where + T: Debug + PartialEq + de::DeserializeOwned, +{ + for &(s, err) in errors { + test_parse_err!(from_str::(s) => err); + test_parse_err!(from_slice::(s.as_bytes()) => err); + } +} + +fn test_parse_slice_err(errors: &[(&[u8], &'static str)]) +where + T: Debug + PartialEq + de::DeserializeOwned, +{ + for &(s, err) in errors { + test_parse_err!(from_slice::(s) => err); + } +} + +fn test_fromstr_parse_err(errors: &[(&str, &'static str)]) +where + T: Debug + PartialEq + FromStr, + ::Err: ToString, +{ + for &(s, err) in errors { + let actual = s.parse::().unwrap_err().to_string(); + assert_eq!(actual, err, "unexpected parsing error"); + } +} + +#[test] +fn test_parse_null() { + test_parse_err::<()>(&[ + ("n", "EOF while parsing a value at line 1 column 1"), + ("nul", "EOF while parsing a value at line 1 column 3"), + ("nulla", "trailing characters at line 1 column 5"), + ]); + + test_parse_ok(vec![("null", ())]); +} + +#[test] +fn test_parse_bool() { + test_parse_err::(&[ + ("t", "EOF while parsing a value at line 1 column 1"), + ("truz", "expected ident at line 1 column 4"), + ("f", "EOF while parsing a value at line 1 column 1"), + ("faz", "expected ident at line 1 column 3"), + ("truea", "trailing characters at line 1 column 5"), + ("falsea", "trailing characters at line 1 column 6"), + ]); + + test_parse_ok(vec![ + ("true", true), + (" true ", true), + ("false", false), + (" false ", false), + ]); +} + +#[test] +fn test_parse_char() { + test_parse_err::(&[ + ( + "\"ab\"", + "invalid value: string \"ab\", expected a character at line 1 column 4", + ), + ( + "10", + "invalid type: integer `10`, expected a character at line 1 column 2", + ), + ]); + + test_parse_ok(vec![ + ("\"n\"", 'n'), + ("\"\\\"\"", '"'), + ("\"\\\\\"", '\\'), + ("\"/\"", '/'), + ("\"\\b\"", '\x08'), + ("\"\\f\"", '\x0C'), + ("\"\\n\"", '\n'), + ("\"\\r\"", '\r'), + ("\"\\t\"", '\t'), + ("\"\\u000b\"", '\x0B'), + ("\"\\u000B\"", '\x0B'), + ("\"\u{3A3}\"", '\u{3A3}'), + ]); +} + +#[test] +fn test_parse_number_errors() { + test_parse_err::(&[ + ("+", "expected value at line 1 column 1"), + (".", "expected value at line 1 column 1"), + ("-", "EOF while parsing a value at line 1 column 1"), + ("00", "invalid number at line 1 column 2"), + ("0x80", "trailing characters at line 1 column 2"), + ("\\0", "expected value at line 1 column 1"), + (".0", "expected value at line 1 column 1"), + ("0.", "EOF while parsing a value at line 1 column 2"), + ("1.", "EOF while parsing a value at line 1 column 2"), + ("1.a", "invalid number at line 1 column 3"), + ("1.e1", "invalid number at line 1 column 3"), + ("1e", "EOF while parsing a value at line 1 column 2"), + ("1e+", "EOF while parsing a value at line 1 column 3"), + ("1a", "trailing characters at line 1 column 2"), + ( + "100e777777777777777777777777777", + "number out of range at line 1 column 14", + ), + ( + "-100e777777777777777777777777777", + "number out of range at line 1 column 15", + ), + ( + "1000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000", // 1e309 + "number out of range at line 1 column 310", + ), + ( + "1000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + .0e9", // 1e309 + "number out of range at line 1 column 305", + ), + ( + "1000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + e9", // 1e309 + "number out of range at line 1 column 303", + ), + ]); +} + +#[test] +fn test_parse_i64() { + test_parse_ok(vec![ + ("-2", -2), + ("-1234", -1234), + (" -1234 ", -1234), + (&i64::MIN.to_string(), i64::MIN), + (&i64::MAX.to_string(), i64::MAX), + ]); +} + +#[test] +fn test_parse_u64() { + test_parse_ok(vec![ + ("0", 0u64), + ("3", 3u64), + ("1234", 1234), + (&u64::MAX.to_string(), u64::MAX), + ]); +} + +#[test] +fn test_parse_negative_zero() { + for negative_zero in &[ + "-0", + "-0.0", + "-0e2", + "-0.0e2", + "-1e-400", + "-1e-4000000000000000000000000000000000000000000000000", + ] { + assert!( + from_str::(negative_zero).unwrap().is_sign_negative(), + "should have been negative: {:?}", + negative_zero, + ); + assert!( + from_str::(negative_zero).unwrap().is_sign_negative(), + "should have been negative: {:?}", + negative_zero, + ); + } +} + +#[test] +fn test_parse_f64() { + test_parse_ok(vec![ + ("0.0", 0.0f64), + ("3.0", 3.0f64), + ("3.1", 3.1), + ("-1.2", -1.2), + ("0.4", 0.4), + // Edge case from: + // https://github.com/serde-rs/json/issues/536#issuecomment-583714900 + ("2.638344616030823e-256", 2.638344616030823e-256), + ]); + + #[cfg(not(feature = "arbitrary_precision"))] + test_parse_ok(vec![ + // With arbitrary-precision enabled, this parses as Number{"3.00"} + // but the float is Number{"3.0"} + ("3.00", 3.0f64), + ("0.4e5", 0.4e5), + ("0.4e+5", 0.4e5), + ("0.4e15", 0.4e15), + ("0.4e+15", 0.4e15), + ("0.4e-01", 0.4e-1), + (" 0.4e-01 ", 0.4e-1), + ("0.4e-001", 0.4e-1), + ("0.4e-0", 0.4e0), + ("0.00e00", 0.0), + ("0.00e+00", 0.0), + ("0.00e-00", 0.0), + ("3.5E-2147483647", 0.0), + ("0.0100000000000000000001", 0.01), + ( + &format!("{}", (i64::MIN as f64) - 1.0), + (i64::MIN as f64) - 1.0, + ), + ( + &format!("{}", (u64::MAX as f64) + 1.0), + (u64::MAX as f64) + 1.0, + ), + (&format!("{}", f64::EPSILON), f64::EPSILON), + ( + "0.0000000000000000000000000000000000000000000000000123e50", + 1.23, + ), + ("100e-777777777777777777777777777", 0.0), + ( + "1010101010101010101010101010101010101010", + 10101010101010101010e20, + ), + ( + "0.1010101010101010101010101010101010101010", + 0.1010101010101010101, + ), + ("0e1000000000000000000000000000000000000000000000", 0.0), + ( + "1000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 00000000", + 1e308, + ), + ( + "1000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + .0e8", + 1e308, + ), + ( + "1000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + e8", + 1e308, + ), + ( + "1000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000000000000000000000000000000000000000000000\ + 000000000000000000e-10", + 1e308, + ), + ]); +} + +#[test] +fn test_value_as_f64() { + let v = serde_json::from_str::("1e1000"); + + #[cfg(not(feature = "arbitrary_precision"))] + assert!(v.is_err()); + + #[cfg(feature = "arbitrary_precision")] + assert_eq!(v.unwrap().as_f64(), None); +} + +// Test roundtrip with some values that were not perfectly roundtripped by the +// old f64 deserializer. +#[cfg(feature = "float_roundtrip")] +#[test] +fn test_roundtrip_f64() { + for &float in &[ + // Samples from quickcheck-ing roundtrip with `input: f64`. Comments + // indicate the value returned by the old deserializer. + 51.24817837550540_4, // 51.2481783755054_1 + -93.3113703768803_3, // -93.3113703768803_2 + -36.5739948427534_36, // -36.5739948427534_4 + 52.31400820410624_4, // 52.31400820410624_ + 97.4536532003468_5, // 97.4536532003468_4 + // Samples from `rng.next_u64` + `f64::from_bits` + `is_finite` filter. + 2.0030397744267762e-253, + 7.101215824554616e260, + 1.769268377902049e74, + -1.6727517818542075e58, + 3.9287532173373315e299, + ] { + let json = serde_json::to_string(&float).unwrap(); + let output: f64 = serde_json::from_str(&json).unwrap(); + assert_eq!(float, output); + } +} + +#[test] +fn test_roundtrip_f32() { + // This number has 1 ULP error if parsed via f64 and converted to f32. + // https://github.com/serde-rs/json/pull/671#issuecomment-628534468 + let float = 7.038531e-26; + let json = serde_json::to_string(&float).unwrap(); + let output: f32 = serde_json::from_str(&json).unwrap(); + assert_eq!(float, output); +} + +#[test] +fn test_serialize_char() { + let value = json!( + ({ + let mut map = BTreeMap::new(); + map.insert('c', ()); + map + }) + ); + assert_eq!(&Value::Null, value.get("c").unwrap()); +} + +#[cfg(feature = "arbitrary_precision")] +#[test] +fn test_malicious_number() { + #[derive(Serialize)] + #[serde(rename = "$serde_json::private::Number")] + struct S { + #[serde(rename = "$serde_json::private::Number")] + f: &'static str, + } + + let actual = serde_json::to_value(&S { f: "not a number" }) + .unwrap_err() + .to_string(); + assert_eq!(actual, "invalid number at line 1 column 1"); +} + +#[test] +fn test_parse_number() { + test_parse_ok(vec![ + ("0.0", Number::from_f64(0.0f64).unwrap()), + ("3.0", Number::from_f64(3.0f64).unwrap()), + ("3.1", Number::from_f64(3.1).unwrap()), + ("-1.2", Number::from_f64(-1.2).unwrap()), + ("0.4", Number::from_f64(0.4).unwrap()), + ]); + + test_fromstr_parse_err::(&[ + (" 1.0", "invalid number at line 1 column 1"), + ("1.0 ", "invalid number at line 1 column 4"), + ("\t1.0", "invalid number at line 1 column 1"), + ("1.0\t", "invalid number at line 1 column 4"), + ]); + + #[cfg(feature = "arbitrary_precision")] + test_parse_ok(vec![ + ("1e999", Number::from_string_unchecked("1e999".to_owned())), + ("1e+999", Number::from_string_unchecked("1e+999".to_owned())), + ("-1e999", Number::from_string_unchecked("-1e999".to_owned())), + ("1e-999", Number::from_string_unchecked("1e-999".to_owned())), + ("1E999", Number::from_string_unchecked("1E999".to_owned())), + ("1E+999", Number::from_string_unchecked("1E+999".to_owned())), + ("-1E999", Number::from_string_unchecked("-1E999".to_owned())), + ("1E-999", Number::from_string_unchecked("1E-999".to_owned())), + ("1E+000", Number::from_string_unchecked("1E+000".to_owned())), + ( + "2.3e999", + Number::from_string_unchecked("2.3e999".to_owned()), + ), + ( + "-2.3e999", + Number::from_string_unchecked("-2.3e999".to_owned()), + ), + ]); +} + +#[test] +fn test_parse_string() { + test_parse_err::(&[ + ("\"", "EOF while parsing a string at line 1 column 1"), + ("\"lol", "EOF while parsing a string at line 1 column 4"), + ("\"lol\"a", "trailing characters at line 1 column 6"), + ( + "\"\\uD83C\\uFFFF\"", + "lone leading surrogate in hex escape at line 1 column 13", + ), + ( + "\"\n\"", + "control character (\\u0000-\\u001F) found while parsing a string at line 2 column 0", + ), + ( + "\"\x1F\"", + "control character (\\u0000-\\u001F) found while parsing a string at line 1 column 2", + ), + ]); + + test_parse_slice_err::(&[ + ( + &[b'"', 159, 146, 150, b'"'], + "invalid unicode code point at line 1 column 5", + ), + ( + &[b'"', b'\\', b'n', 159, 146, 150, b'"'], + "invalid unicode code point at line 1 column 7", + ), + ( + &[b'"', b'\\', b'u', 48, 48, 51], + "EOF while parsing a string at line 1 column 6", + ), + ( + &[b'"', b'\\', b'u', 250, 48, 51, 48, b'"'], + "invalid escape at line 1 column 4", + ), + ( + &[b'"', b'\\', b'u', 48, 250, 51, 48, b'"'], + "invalid escape at line 1 column 5", + ), + ( + &[b'"', b'\\', b'u', 48, 48, 250, 48, b'"'], + "invalid escape at line 1 column 6", + ), + ( + &[b'"', b'\\', b'u', 48, 48, 51, 250, b'"'], + "invalid escape at line 1 column 7", + ), + ( + &[b'"', b'\n', b'"'], + "control character (\\u0000-\\u001F) found while parsing a string at line 2 column 0", + ), + ( + &[b'"', b'\x1F', b'"'], + "control character (\\u0000-\\u001F) found while parsing a string at line 1 column 2", + ), + ]); + + test_parse_ok(vec![ + ("\"\"", "".to_string()), + ("\"foo\"", "foo".to_string()), + (" \"foo\" ", "foo".to_string()), + ("\"\\\"\"", "\"".to_string()), + ("\"\\b\"", "\x08".to_string()), + ("\"\\n\"", "\n".to_string()), + ("\"\\r\"", "\r".to_string()), + ("\"\\t\"", "\t".to_string()), + ("\"\\u12ab\"", "\u{12ab}".to_string()), + ("\"\\uAB12\"", "\u{AB12}".to_string()), + ("\"\\uD83C\\uDF95\"", "\u{1F395}".to_string()), + ]); +} + +#[test] +fn test_parse_list() { + test_parse_err::>(&[ + ("[", "EOF while parsing a list at line 1 column 1"), + ("[ ", "EOF while parsing a list at line 1 column 2"), + ("[1", "EOF while parsing a list at line 1 column 2"), + ("[1,", "EOF while parsing a value at line 1 column 3"), + ("[1,]", "trailing comma at line 1 column 4"), + ("[1 2]", "expected `,` or `]` at line 1 column 4"), + ("[]a", "trailing characters at line 1 column 3"), + ]); + + test_parse_ok(vec![ + ("[]", vec![]), + ("[ ]", vec![]), + ("[null]", vec![()]), + (" [ null ] ", vec![()]), + ]); + + test_parse_ok(vec![("[true]", vec![true])]); + + test_parse_ok(vec![("[3,1]", vec![3u64, 1]), (" [ 3 , 1 ] ", vec![3, 1])]); + + test_parse_ok(vec![("[[3], [1, 2]]", vec![vec![3u64], vec![1, 2]])]); + + test_parse_ok(vec![("[1]", (1u64,))]); + + test_parse_ok(vec![("[1, 2]", (1u64, 2u64))]); + + test_parse_ok(vec![("[1, 2, 3]", (1u64, 2u64, 3u64))]); + + test_parse_ok(vec![("[1, [2, 3]]", (1u64, (2u64, 3u64)))]); +} + +#[test] +fn test_parse_object() { + test_parse_err::>(&[ + ("{", "EOF while parsing an object at line 1 column 1"), + ("{ ", "EOF while parsing an object at line 1 column 2"), + ("{1", "key must be a string at line 1 column 2"), + ("{ \"a\"", "EOF while parsing an object at line 1 column 5"), + ("{\"a\"", "EOF while parsing an object at line 1 column 4"), + ("{\"a\" ", "EOF while parsing an object at line 1 column 5"), + ("{\"a\" 1", "expected `:` at line 1 column 6"), + ("{\"a\":", "EOF while parsing a value at line 1 column 5"), + ("{\"a\":1", "EOF while parsing an object at line 1 column 6"), + ("{\"a\":1 1", "expected `,` or `}` at line 1 column 8"), + ("{\"a\":1,", "EOF while parsing a value at line 1 column 7"), + ("{}a", "trailing characters at line 1 column 3"), + ]); + + test_parse_ok(vec![ + ("{}", treemap!()), + ("{ }", treemap!()), + ("{\"a\":3}", treemap!("a".to_string() => 3u64)), + ("{ \"a\" : 3 }", treemap!("a".to_string() => 3)), + ( + "{\"a\":3,\"b\":4}", + treemap!("a".to_string() => 3, "b".to_string() => 4), + ), + ( + " { \"a\" : 3 , \"b\" : 4 } ", + treemap!("a".to_string() => 3, "b".to_string() => 4), + ), + ]); + + test_parse_ok(vec![( + "{\"a\": {\"b\": 3, \"c\": 4}}", + treemap!( + "a".to_string() => treemap!( + "b".to_string() => 3u64, + "c".to_string() => 4 + ) + ), + )]); + + test_parse_ok(vec![("{\"c\":null}", treemap!('c' => ()))]); +} + +#[test] +fn test_parse_struct() { + test_parse_err::(&[ + ( + "5", + "invalid type: integer `5`, expected struct Outer at line 1 column 1", + ), + ( + "\"hello\"", + "invalid type: string \"hello\", expected struct Outer at line 1 column 7", + ), + ( + "{\"inner\": true}", + "invalid type: boolean `true`, expected a sequence at line 1 column 14", + ), + ("{}", "missing field `inner` at line 1 column 2"), + ( + r#"{"inner": [{"b": 42, "c": []}]}"#, + "missing field `a` at line 1 column 29", + ), + ]); + + test_parse_ok(vec![ + ( + "{ + \"inner\": [] + }", + Outer { inner: vec![] }, + ), + ( + "{ + \"inner\": [ + { \"a\": null, \"b\": 2, \"c\": [\"abc\", \"xyz\"] } + ] + }", + Outer { + inner: vec![Inner { + a: (), + b: 2, + c: vec!["abc".to_string(), "xyz".to_string()], + }], + }, + ), + ]); + + let v: Outer = from_str( + "[ + [ + [ null, 2, [\"abc\", \"xyz\"] ] + ] + ]", + ) + .unwrap(); + + assert_eq!( + v, + Outer { + inner: vec![Inner { + a: (), + b: 2, + c: vec!["abc".to_string(), "xyz".to_string()], + }], + } + ); + + let j = json!([null, 2, []]); + Inner::deserialize(&j).unwrap(); + Inner::deserialize(j).unwrap(); +} + +#[test] +fn test_parse_option() { + test_parse_ok(vec![ + ("null", None::), + ("\"jodhpurs\"", Some("jodhpurs".to_string())), + ]); + + #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] + struct Foo { + x: Option, + } + + let value: Foo = from_str("{}").unwrap(); + assert_eq!(value, Foo { x: None }); + + test_parse_ok(vec![ + ("{\"x\": null}", Foo { x: None }), + ("{\"x\": 5}", Foo { x: Some(5) }), + ]); +} + +#[test] +fn test_parse_enum_errors() { + test_parse_err::( + &[ + ("{}", "expected value at line 1 column 2"), + ("[]", "expected value at line 1 column 1"), + ("\"unknown\"", + "unknown variant `unknown`, expected one of `Dog`, `Frog`, `Cat`, `AntHive` at line 1 column 9"), + ("{\"unknown\":null}", + "unknown variant `unknown`, expected one of `Dog`, `Frog`, `Cat`, `AntHive` at line 1 column 10"), + ("{\"Dog\":", "EOF while parsing a value at line 1 column 7"), + ("{\"Dog\":}", "expected value at line 1 column 8"), + ("{\"Dog\":{}}", "invalid type: map, expected unit at line 1 column 7"), + ("\"Frog\"", "invalid type: unit variant, expected tuple variant"), + ("\"Frog\" 0 ", "invalid type: unit variant, expected tuple variant"), + ("{\"Frog\":{}}", + "invalid type: map, expected tuple variant Animal::Frog at line 1 column 8"), + ("{\"Cat\":[]}", "invalid length 0, expected struct variant Animal::Cat with 2 elements at line 1 column 9"), + ("{\"Cat\":[0]}", "invalid length 1, expected struct variant Animal::Cat with 2 elements at line 1 column 10"), + ("{\"Cat\":[0, \"\", 2]}", "trailing characters at line 1 column 16"), + ("{\"Cat\":{\"age\": 5, \"name\": \"Kate\", \"foo\":\"bar\"}", + "unknown field `foo`, expected `age` or `name` at line 1 column 39"), + + // JSON does not allow trailing commas in data structures + ("{\"Cat\":[0, \"Kate\",]}", "trailing comma at line 1 column 19"), + ("{\"Cat\":{\"age\": 2, \"name\": \"Kate\",}}", + "trailing comma at line 1 column 34"), + ], + ); +} + +#[test] +fn test_parse_enum() { + test_parse_ok(vec![ + ("\"Dog\"", Animal::Dog), + (" \"Dog\" ", Animal::Dog), + ( + "{\"Frog\":[\"Henry\",[]]}", + Animal::Frog("Henry".to_string(), vec![]), + ), + ( + " { \"Frog\": [ \"Henry\" , [ 349, 102 ] ] } ", + Animal::Frog("Henry".to_string(), vec![349, 102]), + ), + ( + "{\"Cat\": {\"age\": 5, \"name\": \"Kate\"}}", + Animal::Cat { + age: 5, + name: "Kate".to_string(), + }, + ), + ( + " { \"Cat\" : { \"age\" : 5 , \"name\" : \"Kate\" } } ", + Animal::Cat { + age: 5, + name: "Kate".to_string(), + }, + ), + ( + " { \"AntHive\" : [\"Bob\", \"Stuart\"] } ", + Animal::AntHive(vec!["Bob".to_string(), "Stuart".to_string()]), + ), + ]); + + test_parse_unusual_ok(vec![ + ("{\"Dog\":null}", Animal::Dog), + (" { \"Dog\" : null } ", Animal::Dog), + ]); + + test_parse_ok(vec![( + concat!( + "{", + " \"a\": \"Dog\",", + " \"b\": {\"Frog\":[\"Henry\", []]}", + "}" + ), + treemap!( + "a".to_string() => Animal::Dog, + "b".to_string() => Animal::Frog("Henry".to_string(), vec![]) + ), + )]); +} + +#[test] +fn test_parse_trailing_whitespace() { + test_parse_ok(vec![ + ("[1, 2] ", vec![1u64, 2]), + ("[1, 2]\n", vec![1, 2]), + ("[1, 2]\t", vec![1, 2]), + ("[1, 2]\t \n", vec![1, 2]), + ]); +} + +#[test] +fn test_multiline_errors() { + test_parse_err::>(&[( + "{\n \"foo\":\n \"bar\"", + "EOF while parsing an object at line 3 column 6", + )]); +} + +#[test] +fn test_missing_option_field() { + #[derive(Debug, PartialEq, Deserialize)] + struct Foo { + x: Option, + } + + let value: Foo = from_str("{}").unwrap(); + assert_eq!(value, Foo { x: None }); + + let value: Foo = from_str("{\"x\": 5}").unwrap(); + assert_eq!(value, Foo { x: Some(5) }); + + let value: Foo = from_value(json!({})).unwrap(); + assert_eq!(value, Foo { x: None }); + + let value: Foo = from_value(json!({"x": 5})).unwrap(); + assert_eq!(value, Foo { x: Some(5) }); +} + +#[test] +fn test_missing_nonoption_field() { + #[derive(Debug, PartialEq, Deserialize)] + struct Foo { + x: u32, + } + + test_parse_err::(&[("{}", "missing field `x` at line 1 column 2")]); +} + +#[test] +fn test_missing_renamed_field() { + #[derive(Debug, PartialEq, Deserialize)] + struct Foo { + #[serde(rename = "y")] + x: Option, + } + + let value: Foo = from_str("{}").unwrap(); + assert_eq!(value, Foo { x: None }); + + let value: Foo = from_str("{\"y\": 5}").unwrap(); + assert_eq!(value, Foo { x: Some(5) }); + + let value: Foo = from_value(json!({})).unwrap(); + assert_eq!(value, Foo { x: None }); + + let value: Foo = from_value(json!({"y": 5})).unwrap(); + assert_eq!(value, Foo { x: Some(5) }); +} + +#[test] +fn test_serialize_seq_with_no_len() { + #[derive(Clone, Debug, PartialEq)] + struct MyVec(Vec); + + impl ser::Serialize for MyVec + where + T: ser::Serialize, + { + #[inline] + fn serialize(&self, serializer: S) -> Result + where + S: ser::Serializer, + { + let mut seq = serializer.serialize_seq(None)?; + for elem in &self.0 { + seq.serialize_element(elem)?; + } + seq.end() + } + } + + struct Visitor { + marker: PhantomData>, + } + + impl<'de, T> de::Visitor<'de> for Visitor + where + T: de::Deserialize<'de>, + { + type Value = MyVec; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("array") + } + + #[inline] + fn visit_unit(self) -> Result, E> + where + E: de::Error, + { + Ok(MyVec(Vec::new())) + } + + #[inline] + fn visit_seq(self, mut visitor: V) -> Result, V::Error> + where + V: de::SeqAccess<'de>, + { + let mut values = Vec::new(); + + while let Some(value) = visitor.next_element()? { + values.push(value); + } + + Ok(MyVec(values)) + } + } + + impl<'de, T> de::Deserialize<'de> for MyVec + where + T: de::Deserialize<'de>, + { + fn deserialize(deserializer: D) -> Result, D::Error> + where + D: de::Deserializer<'de>, + { + deserializer.deserialize_map(Visitor { + marker: PhantomData, + }) + } + } + + let mut vec = Vec::new(); + vec.push(MyVec(Vec::new())); + vec.push(MyVec(Vec::new())); + let vec: MyVec> = MyVec(vec); + + test_encode_ok(&[(vec.clone(), "[[],[]]")]); + + let s = to_string_pretty(&vec).unwrap(); + let expected = pretty_str!([[], []]); + assert_eq!(s, expected); +} + +#[test] +fn test_serialize_map_with_no_len() { + #[derive(Clone, Debug, PartialEq)] + struct MyMap(BTreeMap); + + impl ser::Serialize for MyMap + where + K: ser::Serialize + Ord, + V: ser::Serialize, + { + #[inline] + fn serialize(&self, serializer: S) -> Result + where + S: ser::Serializer, + { + let mut map = serializer.serialize_map(None)?; + for (k, v) in &self.0 { + map.serialize_entry(k, v)?; + } + map.end() + } + } + + struct Visitor { + marker: PhantomData>, + } + + impl<'de, K, V> de::Visitor<'de> for Visitor + where + K: de::Deserialize<'de> + Eq + Ord, + V: de::Deserialize<'de>, + { + type Value = MyMap; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("map") + } + + #[inline] + fn visit_unit(self) -> Result, E> + where + E: de::Error, + { + Ok(MyMap(BTreeMap::new())) + } + + #[inline] + fn visit_map(self, mut visitor: Visitor) -> Result, Visitor::Error> + where + Visitor: de::MapAccess<'de>, + { + let mut values = BTreeMap::new(); + + while let Some((key, value)) = visitor.next_entry()? { + values.insert(key, value); + } + + Ok(MyMap(values)) + } + } + + impl<'de, K, V> de::Deserialize<'de> for MyMap + where + K: de::Deserialize<'de> + Eq + Ord, + V: de::Deserialize<'de>, + { + fn deserialize(deserializer: D) -> Result, D::Error> + where + D: de::Deserializer<'de>, + { + deserializer.deserialize_map(Visitor { + marker: PhantomData, + }) + } + } + + let mut map = BTreeMap::new(); + map.insert("a", MyMap(BTreeMap::new())); + map.insert("b", MyMap(BTreeMap::new())); + let map: MyMap<_, MyMap> = MyMap(map); + + test_encode_ok(&[(map.clone(), "{\"a\":{},\"b\":{}}")]); + + let s = to_string_pretty(&map).unwrap(); + let expected = pretty_str!({ + "a": {}, + "b": {} + }); + assert_eq!(s, expected); +} + +#[cfg(not(miri))] +#[test] +fn test_deserialize_from_stream() { + use serde_json::to_writer; + use std::net::{TcpListener, TcpStream}; + use std::thread; + + #[derive(Debug, PartialEq, Serialize, Deserialize)] + struct Message { + message: String, + } + + let l = TcpListener::bind("localhost:20000").unwrap(); + + thread::spawn(|| { + let l = l; + for stream in l.incoming() { + let mut stream = stream.unwrap(); + let read_stream = stream.try_clone().unwrap(); + + let mut de = Deserializer::from_reader(read_stream); + let request = Message::deserialize(&mut de).unwrap(); + let response = Message { + message: request.message, + }; + to_writer(&mut stream, &response).unwrap(); + } + }); + + let mut stream = TcpStream::connect("localhost:20000").unwrap(); + let request = Message { + message: "hi there".to_string(), + }; + to_writer(&mut stream, &request).unwrap(); + + let mut de = Deserializer::from_reader(stream); + let response = Message::deserialize(&mut de).unwrap(); + + assert_eq!(request, response); +} + +#[test] +fn test_serialize_rejects_bool_keys() { + let map = treemap!( + true => 2, + false => 4 + ); + + let err = to_vec(&map).unwrap_err(); + assert_eq!(err.to_string(), "key must be a string"); +} + +#[test] +fn test_serialize_rejects_adt_keys() { + let map = treemap!( + Some("a") => 2, + Some("b") => 4, + None => 6 + ); + + let err = to_vec(&map).unwrap_err(); + assert_eq!(err.to_string(), "key must be a string"); +} + +#[test] +fn test_bytes_ser() { + let buf = vec![]; + let bytes = Bytes::new(&buf); + assert_eq!(to_string(&bytes).unwrap(), "[]".to_string()); + + let buf = vec![1, 2, 3]; + let bytes = Bytes::new(&buf); + assert_eq!(to_string(&bytes).unwrap(), "[1,2,3]".to_string()); +} + +#[test] +fn test_byte_buf_ser() { + let bytes = ByteBuf::new(); + assert_eq!(to_string(&bytes).unwrap(), "[]".to_string()); + + let bytes = ByteBuf::from(vec![1, 2, 3]); + assert_eq!(to_string(&bytes).unwrap(), "[1,2,3]".to_string()); +} + +#[test] +fn test_byte_buf_de() { + let bytes = ByteBuf::new(); + let v: ByteBuf = from_str("[]").unwrap(); + assert_eq!(v, bytes); + + let bytes = ByteBuf::from(vec![1, 2, 3]); + let v: ByteBuf = from_str("[1, 2, 3]").unwrap(); + assert_eq!(v, bytes); +} + +#[test] +fn test_byte_buf_de_lone_surrogate() { + let bytes = ByteBuf::from(vec![237, 160, 188]); + let v: ByteBuf = from_str(r#""\ud83c""#).unwrap(); + assert_eq!(v, bytes); + + let bytes = ByteBuf::from(vec![237, 160, 188, 10]); + let v: ByteBuf = from_str(r#""\ud83c\n""#).unwrap(); + assert_eq!(v, bytes); + + let bytes = ByteBuf::from(vec![237, 160, 188, 32]); + let v: ByteBuf = from_str(r#""\ud83c ""#).unwrap(); + assert_eq!(v, bytes); + + let bytes = ByteBuf::from(vec![237, 176, 129]); + let v: ByteBuf = from_str(r#""\udc01""#).unwrap(); + assert_eq!(v, bytes); + + let res = from_str::(r#""\ud83c\!""#); + assert!(res.is_err()); + + let res = from_str::(r#""\ud83c\u""#); + assert!(res.is_err()); + + let res = from_str::(r#""\ud83c\ud83c""#); + assert!(res.is_err()); +} + +#[cfg(feature = "raw_value")] +#[test] +fn test_raw_de_lone_surrogate() { + use serde_json::value::RawValue; + + assert!(from_str::>(r#""\ud83c""#).is_ok()); + assert!(from_str::>(r#""\ud83c\n""#).is_ok()); + assert!(from_str::>(r#""\ud83c ""#).is_ok()); + assert!(from_str::>(r#""\udc01 ""#).is_ok()); + assert!(from_str::>(r#""\udc01\!""#).is_err()); + assert!(from_str::>(r#""\udc01\u""#).is_err()); + assert!(from_str::>(r#""\ud83c\ud83c""#).is_ok()); +} + +#[test] +fn test_byte_buf_de_multiple() { + let s: Vec = from_str(r#"["ab\nc", "cd\ne"]"#).unwrap(); + let a = ByteBuf::from(b"ab\nc".to_vec()); + let b = ByteBuf::from(b"cd\ne".to_vec()); + assert_eq!(vec![a, b], s); +} + +#[test] +fn test_json_pointer() { + // Test case taken from https://tools.ietf.org/html/rfc6901#page-5 + let data: Value = from_str( + r#"{ + "foo": ["bar", "baz"], + "": 0, + "a/b": 1, + "c%d": 2, + "e^f": 3, + "g|h": 4, + "i\\j": 5, + "k\"l": 6, + " ": 7, + "m~n": 8 + }"#, + ) + .unwrap(); + assert_eq!(data.pointer("").unwrap(), &data); + assert_eq!(data.pointer("/foo").unwrap(), &json!(["bar", "baz"])); + assert_eq!(data.pointer("/foo/0").unwrap(), &json!("bar")); + assert_eq!(data.pointer("/").unwrap(), &json!(0)); + assert_eq!(data.pointer("/a~1b").unwrap(), &json!(1)); + assert_eq!(data.pointer("/c%d").unwrap(), &json!(2)); + assert_eq!(data.pointer("/e^f").unwrap(), &json!(3)); + assert_eq!(data.pointer("/g|h").unwrap(), &json!(4)); + assert_eq!(data.pointer("/i\\j").unwrap(), &json!(5)); + assert_eq!(data.pointer("/k\"l").unwrap(), &json!(6)); + assert_eq!(data.pointer("/ ").unwrap(), &json!(7)); + assert_eq!(data.pointer("/m~0n").unwrap(), &json!(8)); + // Invalid pointers + assert!(data.pointer("/unknown").is_none()); + assert!(data.pointer("/e^f/ertz").is_none()); + assert!(data.pointer("/foo/00").is_none()); + assert!(data.pointer("/foo/01").is_none()); +} + +#[test] +fn test_json_pointer_mut() { + // Test case taken from https://tools.ietf.org/html/rfc6901#page-5 + let mut data: Value = from_str( + r#"{ + "foo": ["bar", "baz"], + "": 0, + "a/b": 1, + "c%d": 2, + "e^f": 3, + "g|h": 4, + "i\\j": 5, + "k\"l": 6, + " ": 7, + "m~n": 8 + }"#, + ) + .unwrap(); + + // Basic pointer checks + assert_eq!(data.pointer_mut("/foo").unwrap(), &json!(["bar", "baz"])); + assert_eq!(data.pointer_mut("/foo/0").unwrap(), &json!("bar")); + assert_eq!(data.pointer_mut("/").unwrap(), 0); + assert_eq!(data.pointer_mut("/a~1b").unwrap(), 1); + assert_eq!(data.pointer_mut("/c%d").unwrap(), 2); + assert_eq!(data.pointer_mut("/e^f").unwrap(), 3); + assert_eq!(data.pointer_mut("/g|h").unwrap(), 4); + assert_eq!(data.pointer_mut("/i\\j").unwrap(), 5); + assert_eq!(data.pointer_mut("/k\"l").unwrap(), 6); + assert_eq!(data.pointer_mut("/ ").unwrap(), 7); + assert_eq!(data.pointer_mut("/m~0n").unwrap(), 8); + + // Invalid pointers + assert!(data.pointer_mut("/unknown").is_none()); + assert!(data.pointer_mut("/e^f/ertz").is_none()); + assert!(data.pointer_mut("/foo/00").is_none()); + assert!(data.pointer_mut("/foo/01").is_none()); + + // Mutable pointer checks + *data.pointer_mut("/").unwrap() = 100.into(); + assert_eq!(data.pointer("/").unwrap(), 100); + *data.pointer_mut("/foo/0").unwrap() = json!("buzz"); + assert_eq!(data.pointer("/foo/0").unwrap(), &json!("buzz")); + + // Example of ownership stealing + assert_eq!( + data.pointer_mut("/a~1b") + .map(|m| mem::replace(m, json!(null))) + .unwrap(), + 1 + ); + assert_eq!(data.pointer("/a~1b").unwrap(), &json!(null)); + + // Need to compare against a clone so we don't anger the borrow checker + // by taking out two references to a mutable value + let mut d2 = data.clone(); + assert_eq!(data.pointer_mut("").unwrap(), &mut d2); +} + +#[test] +fn test_stack_overflow() { + let brackets: String = iter::repeat('[') + .take(127) + .chain(iter::repeat(']').take(127)) + .collect(); + let _: Value = from_str(&brackets).unwrap(); + + let brackets = "[".repeat(129); + test_parse_err::(&[(&brackets, "recursion limit exceeded at line 1 column 128")]); +} + +#[test] +#[cfg(feature = "unbounded_depth")] +fn test_disable_recursion_limit() { + let brackets: String = iter::repeat('[') + .take(140) + .chain(iter::repeat(']').take(140)) + .collect(); + + let mut deserializer = Deserializer::from_str(&brackets); + deserializer.disable_recursion_limit(); + Value::deserialize(&mut deserializer).unwrap(); +} + +#[test] +fn test_integer_key() { + // map with integer keys + let map = treemap!( + 1 => 2, + -1 => 6 + ); + let j = r#"{"-1":6,"1":2}"#; + test_encode_ok(&[(&map, j)]); + test_parse_ok(vec![(j, map)]); + + let j = r#"{"x":null}"#; + test_parse_err::>(&[( + j, + "invalid type: string \"x\", expected i32 at line 1 column 4", + )]); +} + +#[test] +fn test_integer128_key() { + let map = treemap! { + 100000000000000000000000000000000000000u128 => () + }; + let j = r#"{"100000000000000000000000000000000000000":null}"#; + assert_eq!(to_string(&map).unwrap(), j); + assert_eq!(from_str::>(j).unwrap(), map); +} + +#[test] +fn test_deny_float_key() { + #[derive(Eq, PartialEq, Ord, PartialOrd)] + struct Float; + impl Serialize for Float { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_f32(1.0) + } + } + + // map with float key + let map = treemap!(Float => "x"); + assert!(serde_json::to_value(&map).is_err()); +} + +#[test] +fn test_borrowed_key() { + let map: BTreeMap<&str, ()> = from_str("{\"borrowed\":null}").unwrap(); + let expected = treemap! { "borrowed" => () }; + assert_eq!(map, expected); + + #[derive(Deserialize, Debug, Ord, PartialOrd, Eq, PartialEq)] + struct NewtypeStr<'a>(&'a str); + + let map: BTreeMap = from_str("{\"borrowed\":null}").unwrap(); + let expected = treemap! { NewtypeStr("borrowed") => () }; + assert_eq!(map, expected); +} + +#[test] +fn test_effectively_string_keys() { + #[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Serialize, Deserialize)] + enum Enum { + One, + Two, + } + let map = treemap! { + Enum::One => 1, + Enum::Two => 2 + }; + let expected = r#"{"One":1,"Two":2}"#; + test_encode_ok(&[(&map, expected)]); + test_parse_ok(vec![(expected, map)]); + + #[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Serialize, Deserialize)] + struct Wrapper(String); + let map = treemap! { + Wrapper("zero".to_owned()) => 0, + Wrapper("one".to_owned()) => 1 + }; + let expected = r#"{"one":1,"zero":0}"#; + test_encode_ok(&[(&map, expected)]); + test_parse_ok(vec![(expected, map)]); +} + +#[test] +fn test_json_macro() { + // This is tricky because the <...> is not a single TT and the comma inside + // looks like an array element separator. + let _ = json!([ + as Clone>::clone(&Ok(())), + as Clone>::clone(&Err(())) + ]); + + // Same thing but in the map values. + let _ = json!({ + "ok": as Clone>::clone(&Ok(())), + "err": as Clone>::clone(&Err(())) + }); + + // It works in map keys but only if they are parenthesized. + let _ = json!({ + ( as Clone>::clone(&Ok("")).unwrap()): "ok", + ( as Clone>::clone(&Err("")).unwrap_err()): "err" + }); + + #[deny(unused_results)] + let _ = json!({ "architecture": [true, null] }); +} + +#[test] +fn issue_220() { + #[derive(Debug, PartialEq, Eq, Deserialize)] + enum E { + V(u8), + } + + assert!(from_str::(r#" "V"0 "#).is_err()); + + assert_eq!(from_str::(r#"{"V": 0}"#).unwrap(), E::V(0)); +} + +macro_rules! number_partialeq_ok { + ($($n:expr)*) => { + $( + let value = to_value($n).unwrap(); + let s = $n.to_string(); + assert_eq!(value, $n); + assert_eq!($n, value); + assert_ne!(value, s); + )* + } +} + +#[test] +fn test_partialeq_number() { + number_partialeq_ok!(0 1 100 + i8::MIN i8::MAX i16::MIN i16::MAX i32::MIN i32::MAX i64::MIN i64::MAX + u8::MIN u8::MAX u16::MIN u16::MAX u32::MIN u32::MAX u64::MIN u64::MAX + f32::MIN f32::MAX f32::MIN_EXP f32::MAX_EXP f32::MIN_POSITIVE + f64::MIN f64::MAX f64::MIN_EXP f64::MAX_EXP f64::MIN_POSITIVE + f32::consts::E f32::consts::PI f32::consts::LN_2 f32::consts::LOG2_E + f64::consts::E f64::consts::PI f64::consts::LN_2 f64::consts::LOG2_E + ); +} + +#[test] +#[cfg(integer128)] +#[cfg(feature = "arbitrary_precision")] +fn test_partialeq_integer128() { + number_partialeq_ok!(i128::MIN i128::MAX u128::MIN u128::MAX) +} + +#[test] +fn test_partialeq_string() { + let v = to_value("42").unwrap(); + assert_eq!(v, "42"); + assert_eq!("42", v); + assert_ne!(v, 42); + assert_eq!(v, String::from("42")); + assert_eq!(String::from("42"), v); +} + +#[test] +fn test_partialeq_bool() { + let v = to_value(true).unwrap(); + assert_eq!(v, true); + assert_eq!(true, v); + assert_ne!(v, false); + assert_ne!(v, "true"); + assert_ne!(v, 1); + assert_ne!(v, 0); +} + +struct FailReader(io::ErrorKind); + +impl io::Read for FailReader { + fn read(&mut self, _: &mut [u8]) -> io::Result { + Err(io::Error::new(self.0, "oh no!")) + } +} + +#[test] +fn test_category() { + assert!(from_str::("123").unwrap_err().is_data()); + + assert!(from_str::("]").unwrap_err().is_syntax()); + + assert!(from_str::("").unwrap_err().is_eof()); + assert!(from_str::("\"").unwrap_err().is_eof()); + assert!(from_str::("\"\\").unwrap_err().is_eof()); + assert!(from_str::("\"\\u").unwrap_err().is_eof()); + assert!(from_str::("\"\\u0").unwrap_err().is_eof()); + assert!(from_str::("\"\\u00").unwrap_err().is_eof()); + assert!(from_str::("\"\\u000").unwrap_err().is_eof()); + + assert!(from_str::>("[").unwrap_err().is_eof()); + assert!(from_str::>("[0").unwrap_err().is_eof()); + assert!(from_str::>("[0,").unwrap_err().is_eof()); + + assert!(from_str::>("{") + .unwrap_err() + .is_eof()); + assert!(from_str::>("{\"k\"") + .unwrap_err() + .is_eof()); + assert!(from_str::>("{\"k\":") + .unwrap_err() + .is_eof()); + assert!(from_str::>("{\"k\":0") + .unwrap_err() + .is_eof()); + assert!(from_str::>("{\"k\":0,") + .unwrap_err() + .is_eof()); + + let fail = FailReader(io::ErrorKind::NotConnected); + assert!(from_reader::<_, String>(fail).unwrap_err().is_io()); +} + +#[test] +// Clippy false positive: https://github.com/Manishearth/rust-clippy/issues/292 +#[allow(clippy::needless_lifetimes)] +fn test_into_io_error() { + fn io_error<'de, T: Deserialize<'de> + Debug>(j: &'static str) -> io::Error { + from_str::(j).unwrap_err().into() + } + + assert_eq!( + io_error::("\"\\u").kind(), + io::ErrorKind::UnexpectedEof + ); + assert_eq!(io_error::("0").kind(), io::ErrorKind::InvalidData); + assert_eq!(io_error::("]").kind(), io::ErrorKind::InvalidData); + + let fail = FailReader(io::ErrorKind::NotConnected); + let io_err: io::Error = from_reader::<_, u8>(fail).unwrap_err().into(); + assert_eq!(io_err.kind(), io::ErrorKind::NotConnected); +} + +#[test] +fn test_borrow() { + let s: &str = from_str("\"borrowed\"").unwrap(); + assert_eq!("borrowed", s); + + let s: &str = from_slice(b"\"borrowed\"").unwrap(); + assert_eq!("borrowed", s); +} + +#[test] +fn null_invalid_type() { + let err = serde_json::from_str::("null").unwrap_err(); + assert_eq!( + format!("{}", err), + String::from("invalid type: null, expected a string at line 1 column 4") + ); +} + +#[test] +fn test_integer128() { + let signed = &[i128::min_value(), -1, 0, 1, i128::max_value()]; + let unsigned = &[0, 1, u128::max_value()]; + + for integer128 in signed { + let expected = integer128.to_string(); + assert_eq!(to_string(integer128).unwrap(), expected); + assert_eq!(from_str::(&expected).unwrap(), *integer128); + } + + for integer128 in unsigned { + let expected = integer128.to_string(); + assert_eq!(to_string(integer128).unwrap(), expected); + assert_eq!(from_str::(&expected).unwrap(), *integer128); + } + + test_parse_err::(&[ + ( + "-170141183460469231731687303715884105729", + "number out of range at line 1 column 40", + ), + ( + "170141183460469231731687303715884105728", + "number out of range at line 1 column 39", + ), + ]); + + test_parse_err::(&[ + ("-1", "number out of range at line 1 column 1"), + ( + "340282366920938463463374607431768211456", + "number out of range at line 1 column 39", + ), + ]); +} + +#[cfg(feature = "raw_value")] +#[test] +fn test_borrowed_raw_value() { + #[derive(Serialize, Deserialize)] + struct Wrapper<'a> { + a: i8, + #[serde(borrow)] + b: &'a RawValue, + c: i8, + } + + let wrapper_from_str: Wrapper = + serde_json::from_str(r#"{"a": 1, "b": {"foo": 2}, "c": 3}"#).unwrap(); + assert_eq!(r#"{"foo": 2}"#, wrapper_from_str.b.get()); + + let wrapper_to_string = serde_json::to_string(&wrapper_from_str).unwrap(); + assert_eq!(r#"{"a":1,"b":{"foo": 2},"c":3}"#, wrapper_to_string); + + let wrapper_to_value = serde_json::to_value(&wrapper_from_str).unwrap(); + assert_eq!(json!({"a": 1, "b": {"foo": 2}, "c": 3}), wrapper_to_value); + + let array_from_str: Vec<&RawValue> = + serde_json::from_str(r#"["a", 42, {"foo": "bar"}, null]"#).unwrap(); + assert_eq!(r#""a""#, array_from_str[0].get()); + assert_eq!(r#"42"#, array_from_str[1].get()); + assert_eq!(r#"{"foo": "bar"}"#, array_from_str[2].get()); + assert_eq!(r#"null"#, array_from_str[3].get()); + + let array_to_string = serde_json::to_string(&array_from_str).unwrap(); + assert_eq!(r#"["a",42,{"foo": "bar"},null]"#, array_to_string); +} + +#[cfg(feature = "raw_value")] +#[test] +fn test_raw_value_in_map_key() { + #[derive(RefCast)] + #[repr(transparent)] + struct RawMapKey(RawValue); + + impl<'de> Deserialize<'de> for &'de RawMapKey { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let raw_value = <&RawValue>::deserialize(deserializer)?; + Ok(RawMapKey::ref_cast(raw_value)) + } + } + + impl PartialEq for RawMapKey { + fn eq(&self, other: &Self) -> bool { + self.0.get() == other.0.get() + } + } + + impl Eq for RawMapKey {} + + impl Hash for RawMapKey { + fn hash(&self, hasher: &mut H) { + self.0.get().hash(hasher); + } + } + + let map_from_str: HashMap<&RawMapKey, &RawValue> = + serde_json::from_str(r#" {"\\k":"\\v"} "#).unwrap(); + let (map_k, map_v) = map_from_str.into_iter().next().unwrap(); + assert_eq!("\"\\\\k\"", map_k.0.get()); + assert_eq!("\"\\\\v\"", map_v.get()); +} + +#[cfg(feature = "raw_value")] +#[test] +fn test_boxed_raw_value() { + #[derive(Serialize, Deserialize)] + struct Wrapper { + a: i8, + b: Box, + c: i8, + } + + let wrapper_from_str: Wrapper = + serde_json::from_str(r#"{"a": 1, "b": {"foo": 2}, "c": 3}"#).unwrap(); + assert_eq!(r#"{"foo": 2}"#, wrapper_from_str.b.get()); + + let wrapper_from_reader: Wrapper = + serde_json::from_reader(br#"{"a": 1, "b": {"foo": 2}, "c": 3}"#.as_ref()).unwrap(); + assert_eq!(r#"{"foo": 2}"#, wrapper_from_reader.b.get()); + + let wrapper_from_value: Wrapper = + serde_json::from_value(json!({"a": 1, "b": {"foo": 2}, "c": 3})).unwrap(); + assert_eq!(r#"{"foo":2}"#, wrapper_from_value.b.get()); + + let wrapper_to_string = serde_json::to_string(&wrapper_from_str).unwrap(); + assert_eq!(r#"{"a":1,"b":{"foo": 2},"c":3}"#, wrapper_to_string); + + let wrapper_to_value = serde_json::to_value(&wrapper_from_str).unwrap(); + assert_eq!(json!({"a": 1, "b": {"foo": 2}, "c": 3}), wrapper_to_value); + + let array_from_str: Vec> = + serde_json::from_str(r#"["a", 42, {"foo": "bar"}, null]"#).unwrap(); + assert_eq!(r#""a""#, array_from_str[0].get()); + assert_eq!(r#"42"#, array_from_str[1].get()); + assert_eq!(r#"{"foo": "bar"}"#, array_from_str[2].get()); + assert_eq!(r#"null"#, array_from_str[3].get()); + + let array_from_reader: Vec> = + serde_json::from_reader(br#"["a", 42, {"foo": "bar"}, null]"#.as_ref()).unwrap(); + assert_eq!(r#""a""#, array_from_reader[0].get()); + assert_eq!(r#"42"#, array_from_reader[1].get()); + assert_eq!(r#"{"foo": "bar"}"#, array_from_reader[2].get()); + assert_eq!(r#"null"#, array_from_reader[3].get()); + + let array_to_string = serde_json::to_string(&array_from_str).unwrap(); + assert_eq!(r#"["a",42,{"foo": "bar"},null]"#, array_to_string); +} + +#[cfg(feature = "raw_value")] +#[test] +fn test_raw_invalid_utf8() { + let j = &[b'"', b'\xCE', b'\xF8', b'"']; + let value_err = serde_json::from_slice::(j).unwrap_err(); + let raw_value_err = serde_json::from_slice::>(j).unwrap_err(); + + assert_eq!( + value_err.to_string(), + "invalid unicode code point at line 1 column 4", + ); + assert_eq!( + raw_value_err.to_string(), + "invalid unicode code point at line 1 column 4", + ); +} + +#[cfg(feature = "raw_value")] +#[test] +fn test_serialize_unsized_value_to_raw_value() { + assert_eq!( + serde_json::value::to_raw_value("foobar").unwrap().get(), + r#""foobar""#, + ); +} + +#[test] +fn test_borrow_in_map_key() { + #[derive(Deserialize, Debug)] + struct Outer { + #[allow(dead_code)] + map: BTreeMap, + } + + #[derive(Ord, PartialOrd, Eq, PartialEq, Debug)] + struct MyMapKey(usize); + + impl<'de> Deserialize<'de> for MyMapKey { + fn deserialize(deserializer: D) -> Result + where + D: de::Deserializer<'de>, + { + let s = <&str>::deserialize(deserializer)?; + let n = s.parse().map_err(de::Error::custom)?; + Ok(MyMapKey(n)) + } + } + + let value = json!({ "map": { "1": null } }); + Outer::deserialize(&value).unwrap(); +} + +#[test] +fn test_value_into_deserializer() { + #[derive(Deserialize)] + struct Outer { + inner: Inner, + } + + #[derive(Deserialize)] + struct Inner { + string: String, + } + + let mut map = BTreeMap::new(); + map.insert("inner", json!({ "string": "Hello World" })); + + let outer = Outer::deserialize(map.into_deserializer()).unwrap(); + assert_eq!(outer.inner.string, "Hello World"); +} + +#[test] +fn hash_positive_and_negative_zero() { + fn hash(obj: impl Hash) -> u64 { + let mut hasher = DefaultHasher::new(); + obj.hash(&mut hasher); + hasher.finish() + } + + let k1 = serde_json::from_str::("0.0").unwrap(); + let k2 = serde_json::from_str::("-0.0").unwrap(); + if cfg!(feature = "arbitrary_precision") { + assert_ne!(k1, k2); + assert_ne!(hash(k1), hash(k2)); + } else { + assert_eq!(k1, k2); + assert_eq!(hash(k1), hash(k2)); + } +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/missing_colon.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_colon.rs --- cargo-0.58.0/vendor/serde_json/tests/ui/missing_colon.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_colon.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +use serde_json::json; + +fn main() { + json!({ "a" }); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/missing_colon.stderr cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_colon.stderr --- cargo-0.58.0/vendor/serde_json/tests/ui/missing_colon.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_colon.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,7 @@ +error: unexpected end of macro invocation + --> tests/ui/missing_colon.rs:4:5 + | +4 | json!({ "a" }); + | ^^^^^^^^^^^^^^ missing tokens in macro arguments + | + = note: this error originates in the macro `json_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/missing_comma.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_comma.rs --- cargo-0.58.0/vendor/serde_json/tests/ui/missing_comma.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_comma.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +use serde_json::json; + +fn main() { + json!({ "1": "" "2": "" }); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/missing_comma.stderr cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_comma.stderr --- cargo-0.58.0/vendor/serde_json/tests/ui/missing_comma.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_comma.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,7 @@ +error: no rules expected the token `"2"` + --> tests/ui/missing_comma.rs:4:21 + | +4 | json!({ "1": "" "2": "" }); + | -^^^ no rules expected this token in macro call + | | + | help: missing comma here diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/missing_value.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_value.rs --- cargo-0.58.0/vendor/serde_json/tests/ui/missing_value.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_value.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +use serde_json::json; + +fn main() { + json!({ "a" : }); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/missing_value.stderr cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_value.stderr --- cargo-0.58.0/vendor/serde_json/tests/ui/missing_value.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/missing_value.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,7 @@ +error: unexpected end of macro invocation + --> tests/ui/missing_value.rs:4:5 + | +4 | json!({ "a" : }); + | ^^^^^^^^^^^^^^^^ missing tokens in macro arguments + | + = note: this error originates in the macro `json_internal` (in Nightly builds, run with -Z macro-backtrace for more info) diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/not_found.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/not_found.rs --- cargo-0.58.0/vendor/serde_json/tests/ui/not_found.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/not_found.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +use serde_json::json; + +fn main() { + json!({ "a" : x }); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/not_found.stderr cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/not_found.stderr --- cargo-0.58.0/vendor/serde_json/tests/ui/not_found.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/not_found.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +error[E0425]: cannot find value `x` in this scope + --> tests/ui/not_found.rs:4:19 + | +4 | json!({ "a" : x }); + | ^ not found in this scope diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/parse_expr.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/parse_expr.rs --- cargo-0.58.0/vendor/serde_json/tests/ui/parse_expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/parse_expr.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +use serde_json::json; + +fn main() { + json!({ "a" : ~ }); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/parse_expr.stderr cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/parse_expr.stderr --- cargo-0.58.0/vendor/serde_json/tests/ui/parse_expr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/parse_expr.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +error: no rules expected the token `~` + --> tests/ui/parse_expr.rs:4:19 + | +4 | json!({ "a" : ~ }); + | ^ no rules expected this token in macro call diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/parse_key.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/parse_key.rs --- cargo-0.58.0/vendor/serde_json/tests/ui/parse_key.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/parse_key.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +use serde_json::json; + +fn main() { + json!({ "".s : true }); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/parse_key.stderr cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/parse_key.stderr --- cargo-0.58.0/vendor/serde_json/tests/ui/parse_key.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/parse_key.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +error[E0609]: no field `s` on type `&'static str` + --> tests/ui/parse_key.rs:4:16 + | +4 | json!({ "".s : true }); + | ^ diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_after_array_element.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_after_array_element.rs --- cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_after_array_element.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_after_array_element.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +use serde_json::json; + +fn main() { + json!([ true => ]); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_after_array_element.stderr cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_after_array_element.stderr --- cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_after_array_element.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_after_array_element.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +error: no rules expected the token `=>` + --> tests/ui/unexpected_after_array_element.rs:4:18 + | +4 | json!([ true => ]); + | ^^ no rules expected this token in macro call diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_after_map_entry.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_after_map_entry.rs --- cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_after_map_entry.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_after_map_entry.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +use serde_json::json; + +fn main() { + json!({ "k": true => }); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_after_map_entry.stderr cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_after_map_entry.stderr --- cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_after_map_entry.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_after_map_entry.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +error: no rules expected the token `=>` + --> tests/ui/unexpected_after_map_entry.rs:4:23 + | +4 | json!({ "k": true => }); + | ^^ no rules expected this token in macro call diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_colon.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_colon.rs --- cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_colon.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_colon.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +use serde_json::json; + +fn main() { + json!({ : true }); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_colon.stderr cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_colon.stderr --- cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_colon.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_colon.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +error: no rules expected the token `:` + --> tests/ui/unexpected_colon.rs:4:13 + | +4 | json!({ : true }); + | ^ no rules expected this token in macro call diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_comma.rs cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_comma.rs --- cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_comma.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_comma.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +use serde_json::json; + +fn main() { + json!({ "a" , "b": true }); +} diff -Nru cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_comma.stderr cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_comma.stderr --- cargo-0.58.0/vendor/serde_json/tests/ui/unexpected_comma.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/serde_json/tests/ui/unexpected_comma.stderr 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +error: no rules expected the token `,` + --> tests/ui/unexpected_comma.rs:4:17 + | +4 | json!({ "a" , "b": true }); + | ^ no rules expected this token in macro call diff -Nru cargo-0.58.0/vendor/socket2/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/socket2/.cargo-checksum.json --- cargo-0.58.0/vendor/socket2/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/socket2/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"0f82496b90c36d70af5fcd482edaa2e0bd16fade569de1330405fecbbdac736b"} \ No newline at end of file +{"files":{},"package":"66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/socket2/Cargo.toml cargo-0.60.0ubuntu1/vendor/socket2/Cargo.toml --- cargo-0.58.0/vendor/socket2/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/socket2/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "socket2" -version = "0.4.3" +version = "0.4.4" authors = ["Alex Crichton ", "Thomas de Zeeuw "] include = ["Cargo.toml", "LICENSE-APACHE", "LICENSE-MIT", "README.md", "src/**/*.rs"] description = "Utilities for handling networking sockets with a maximal amount of configuration\npossible intended.\n" @@ -21,7 +21,7 @@ readme = "README.md" keywords = ["io", "socket", "network"] categories = ["api-bindings", "network-programming"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/socket2" [package.metadata.docs.rs] all-features = true @@ -33,7 +33,7 @@ [features] all = [] [target."cfg(unix)".dependencies.libc] -version = "0.2.113" +version = "0.2.114" [target."cfg(windows)".dependencies.winapi] version = "0.3.9" features = ["handleapi", "ws2ipdef", "ws2tcpip"] diff -Nru cargo-0.58.0/vendor/syn/benches/file.rs cargo-0.60.0ubuntu1/vendor/syn/benches/file.rs --- cargo-0.58.0/vendor/syn/benches/file.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/benches/file.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,6 +2,7 @@ #![feature(rustc_private, test)] #![recursion_limit = "1024"] +#![allow(clippy::missing_panics_doc, clippy::must_use_candidate)] extern crate test; diff -Nru cargo-0.58.0/vendor/syn/benches/rust.rs cargo-0.60.0ubuntu1/vendor/syn/benches/rust.rs --- cargo-0.58.0/vendor/syn/benches/rust.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/benches/rust.rs 2022-04-20 13:48:09.000000000 +0000 @@ -5,6 +5,7 @@ #![cfg_attr(not(syn_only), feature(rustc_private))] #![recursion_limit = "1024"] +#![allow(clippy::cast_lossless, clippy::unnecessary_wraps)] #[macro_use] #[path = "../tests/macros/mod.rs"] @@ -63,7 +64,7 @@ let emitter = Box::new(SilentEmitter); let handler = Handler::with_emitter(false, None, emitter); let sess = ParseSess::with_span_handler(handler, cm); - if let Err(mut diagnostic) = rustc_parse::parse_crate_from_source_str( + if let Err(diagnostic) = rustc_parse::parse_crate_from_source_str( FileName::Custom("bench".to_owned()), content.to_owned(), &sess, @@ -116,7 +117,7 @@ macro_rules! testcases { ($($(#[$cfg:meta])* $name:ident,)*) => { - vec![ + [ $( $(#[$cfg])* (stringify!($name), $name::bench as fn(&str) -> Result<(), ()>), diff -Nru cargo-0.58.0/vendor/syn/build.rs cargo-0.60.0ubuntu1/vendor/syn/build.rs --- cargo-0.58.0/vendor/syn/build.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/build.rs 2022-04-20 13:48:09.000000000 +0000 @@ -19,6 +19,14 @@ println!("cargo:rustc-cfg=syn_no_const_vec_new"); } + if compiler.minor < 40 { + println!("cargo:rustc-cfg=syn_no_non_exhaustive"); + } + + if compiler.minor < 56 { + println!("cargo:rustc-cfg=syn_no_negative_literal_parse"); + } + if !compiler.nightly { println!("cargo:rustc-cfg=syn_disable_nightly_tests"); } @@ -38,6 +46,6 @@ return None; } let minor = pieces.next()?.parse().ok()?; - let nightly = version.contains("nightly"); + let nightly = version.contains("nightly") || version.ends_with("-dev"); Some(Compiler { minor, nightly }) } diff -Nru cargo-0.58.0/vendor/syn/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/syn/.cargo-checksum.json --- cargo-0.58.0/vendor/syn/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"5239bc68e0fef57495900cfea4e8dc75596d9a319d7e16b1e0a440d24e6fe0a0"} \ No newline at end of file +{"files":{},"package":"b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/syn/Cargo.toml cargo-0.60.0ubuntu1/vendor/syn/Cargo.toml --- cargo-0.58.0/vendor/syn/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -11,34 +11,61 @@ [package] edition = "2018" +rust-version = "1.31" name = "syn" -version = "1.0.77" +version = "1.0.91" authors = ["David Tolnay "] -include = ["/benches/**", "/build.rs", "/Cargo.toml", "/LICENSE-APACHE", "/LICENSE-MIT", "/README.md", "/src/**", "/tests/**"] +include = [ + "/benches/**", + "/build.rs", + "/Cargo.toml", + "/LICENSE-APACHE", + "/LICENSE-MIT", + "/README.md", + "/src/**", + "/tests/**", +] description = "Parser for Rust source code" documentation = "https://docs.rs/syn" readme = "README.md" categories = ["development-tools::procedural-macro-helpers"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/syn" + [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "doc_cfg"] targets = ["x86_64-unknown-linux-gnu"] +rustdoc-args = [ + "--cfg", + "doc_cfg", +] [package.metadata.playground] -features = ["full", "visit", "visit-mut", "fold", "extra-traits"] +features = [ + "full", + "visit", + "visit-mut", + "fold", + "extra-traits", +] [[bench]] name = "rust" harness = false -required-features = ["full", "parsing"] +required-features = [ + "full", + "parsing", +] [[bench]] name = "file" -required-features = ["full", "parsing"] +required-features = [ + "full", + "parsing", +] + [dependencies.proc-macro2] -version = "1.0" +version = "1.0.32" default-features = false [dependencies.quote] @@ -48,9 +75,13 @@ [dependencies.unicode-xid] version = "0.2" + [dev-dependencies.anyhow] version = "1.0" +[dev-dependencies.automod] +version = "1.0" + [dev-dependencies.flate2] version = "1.0" @@ -67,7 +98,11 @@ version = "1.0" [dev-dependencies.reqwest] -version = "0.9" +version = "0.11" +features = ["blocking"] + +[dev-dependencies.syn-test-suite] +version = "0" [dev-dependencies.tar] version = "0.4.16" @@ -80,13 +115,23 @@ [features] clone-impls = [] -default = ["derive", "parsing", "printing", "clone-impls", "proc-macro"] +default = [ + "derive", + "parsing", + "printing", + "clone-impls", + "proc-macro", +] derive = [] extra-traits = [] fold = [] full = [] parsing = [] printing = ["quote"] -proc-macro = ["proc-macro2/proc-macro", "quote/proc-macro"] +proc-macro = [ + "proc-macro2/proc-macro", + "quote/proc-macro", +] +test = ["syn-test-suite/all-features"] visit = [] visit-mut = [] diff -Nru cargo-0.58.0/vendor/syn/debian/patches/series cargo-0.60.0ubuntu1/vendor/syn/debian/patches/series --- cargo-0.58.0/vendor/syn/debian/patches/series 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -1 +0,0 @@ -relax-deps.patch diff -Nru cargo-0.58.0/vendor/syn/src/buffer.rs cargo-0.60.0ubuntu1/vendor/syn/src/buffer.rs --- cargo-0.58.0/vendor/syn/src/buffer.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/buffer.rs 2022-04-20 13:48:09.000000000 +0000 @@ -16,6 +16,7 @@ use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; use std::marker::PhantomData; use std::ptr; +use std::slice; /// Internal type which is used instead of `TokenTree` to represent a token tree /// within a `TokenBuffer`. @@ -36,20 +37,30 @@ /// /// *This type is available only if Syn is built with the `"parsing"` feature.* pub struct TokenBuffer { - // NOTE: Do not derive clone on this - there are raw pointers inside which - // will be messed up. Moving the `TokenBuffer` itself is safe as the actual - // backing slices won't be moved. - data: Box<[Entry]>, + // NOTE: Do not implement clone on this - there are raw pointers inside + // these entries which will be messed up. Moving the `TokenBuffer` itself is + // safe as the data pointed to won't be moved. + ptr: *const Entry, + len: usize, +} + +impl Drop for TokenBuffer { + fn drop(&mut self) { + unsafe { + let slice = slice::from_raw_parts_mut(self.ptr as *mut Entry, self.len); + let _ = Box::from_raw(slice); + } + } } impl TokenBuffer { - // NOTE: DO NOT MUTATE THE `Vec` RETURNED FROM THIS FUNCTION ONCE IT - // RETURNS, THE ADDRESS OF ITS BACKING MEMORY MUST REMAIN STABLE. + // NOTE: Do not mutate the Vec returned from this function once it returns; + // the address of its backing memory must remain stable. fn inner_new(stream: TokenStream, up: *const Entry) -> TokenBuffer { // Build up the entries list, recording the locations of any Groups // in the list to be processed later. let mut entries = Vec::new(); - let mut seqs = Vec::new(); + let mut groups = Vec::new(); for tt in stream { match tt { TokenTree::Ident(sym) => { @@ -63,8 +74,8 @@ } TokenTree::Group(g) => { // Record the index of the interesting entry, and store an - // `End(null)` there temporarially. - seqs.push((entries.len(), g)); + // `End(null)` there temporarily. + groups.push((entries.len(), g)); entries.push(Entry::End(ptr::null())); } } @@ -78,23 +89,28 @@ // constant address after this point, as we are going to store a raw // pointer into it. let mut entries = entries.into_boxed_slice(); - for (idx, group) in seqs { + for (idx, group) in groups { // We know that this index refers to one of the temporary // `End(null)` entries, and we know that the last entry is // `End(up)`, so the next index is also valid. - let seq_up = &entries[idx + 1] as *const Entry; + let group_up = unsafe { entries.as_ptr().add(idx + 1) }; // The end entry stored at the end of this Entry::Group should // point to the Entry which follows the Group in the list. - let inner = Self::inner_new(group.stream(), seq_up); + let inner = Self::inner_new(group.stream(), group_up); entries[idx] = Entry::Group(group, inner); } - TokenBuffer { data: entries } + let len = entries.len(); + let ptr = Box::into_raw(entries); + TokenBuffer { + ptr: ptr as *const Entry, + len, + } } /// Creates a `TokenBuffer` containing all the tokens from the input - /// `TokenStream`. + /// `proc_macro::TokenStream`. /// /// *This method is available only if Syn is built with both the `"parsing"` and /// `"proc-macro"` features.* @@ -102,20 +118,20 @@ not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))), feature = "proc-macro" ))] - pub fn new(stream: pm::TokenStream) -> TokenBuffer { + pub fn new(stream: pm::TokenStream) -> Self { Self::new2(stream.into()) } /// Creates a `TokenBuffer` containing all the tokens from the input - /// `TokenStream`. - pub fn new2(stream: TokenStream) -> TokenBuffer { + /// `proc_macro2::TokenStream`. + pub fn new2(stream: TokenStream) -> Self { Self::inner_new(stream, ptr::null()) } /// Creates a cursor referencing the first token in the buffer and able to /// traverse until the end of the buffer. pub fn begin(&self) -> Cursor { - unsafe { Cursor::create(&self.data[0], &self.data[self.data.len() - 1]) } + unsafe { Cursor::create(self.ptr, self.ptr.add(self.len - 1)) } } } @@ -210,7 +226,7 @@ // situations where we should immediately exit the span after // entering it are handled correctly. unsafe { - *self = Cursor::create(&buf.data[0], self.scope); + *self = Cursor::create(buf.ptr, self.scope); } } else { break; @@ -254,7 +270,7 @@ } } - /// If the cursor is pointing at an `Punct`, returns it along with a cursor + /// If the cursor is pointing at a `Punct`, returns it along with a cursor /// pointing at the next `TokenTree`. pub fn punct(mut self) -> Option<(Punct, Cursor<'a>)> { self.ignore_none(); @@ -321,9 +337,7 @@ Entry::Literal(lit) => lit.clone().into(), Entry::Ident(ident) => ident.clone().into(), Entry::Punct(op) => op.clone().into(), - Entry::End(..) => { - return None; - } + Entry::End(..) => return None, }; Some((tree, unsafe { self.bump() })) diff -Nru cargo-0.58.0/vendor/syn/src/data.rs cargo-0.60.0ubuntu1/vendor/syn/src/data.rs --- cargo-0.58.0/vendor/syn/src/data.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/data.rs 2022-04-20 13:48:09.000000000 +0000 @@ -246,12 +246,11 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for Variant { fn parse(input: ParseStream) -> Result { - let mut attrs = input.call(Attribute::parse_outer)?; + let attrs = input.call(Attribute::parse_outer)?; let _visibility: Visibility = input.parse()?; let ident: Ident = input.parse()?; let fields = if input.peek(token::Brace) { - let fields = parse_braced(input, &mut attrs)?; - Fields::Named(fields) + Fields::Named(input.parse()?) } else if input.peek(token::Paren) { Fields::Unnamed(input.parse()?) } else { @@ -295,17 +294,6 @@ } } - pub(crate) fn parse_braced( - input: ParseStream, - attrs: &mut Vec, - ) -> Result { - let content; - let brace_token = braced!(content in input); - attr::parsing::parse_inner(&content, attrs)?; - let named = content.parse_terminated(Field::parse_named)?; - Ok(FieldsNamed { brace_token, named }) - } - impl Field { /// Parses a named (braced struct) field. #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] diff -Nru cargo-0.58.0/vendor/syn/src/derive.rs cargo-0.60.0ubuntu1/vendor/syn/src/derive.rs --- cargo-0.58.0/vendor/syn/src/derive.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/derive.rs 2022-04-20 13:48:09.000000000 +0000 @@ -95,7 +95,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for DeriveInput { fn parse(input: ParseStream) -> Result { - let mut attrs = input.call(Attribute::parse_outer)?; + let attrs = input.call(Attribute::parse_outer)?; let vis = input.parse::()?; let lookahead = input.lookahead1(); @@ -103,7 +103,7 @@ let struct_token = input.parse::()?; let ident = input.parse::()?; let generics = input.parse::()?; - let (where_clause, fields, semi) = data_struct(input, &mut attrs)?; + let (where_clause, fields, semi) = data_struct(input)?; Ok(DeriveInput { attrs, vis, @@ -122,7 +122,7 @@ let enum_token = input.parse::()?; let ident = input.parse::()?; let generics = input.parse::()?; - let (where_clause, brace, variants) = data_enum(input, &mut attrs)?; + let (where_clause, brace, variants) = data_enum(input)?; Ok(DeriveInput { attrs, vis, @@ -141,7 +141,7 @@ let union_token = input.parse::()?; let ident = input.parse::()?; let generics = input.parse::()?; - let (where_clause, fields) = data_union(input, &mut attrs)?; + let (where_clause, fields) = data_union(input)?; Ok(DeriveInput { attrs, vis, @@ -163,7 +163,6 @@ pub fn data_struct( input: ParseStream, - attrs: &mut Vec, ) -> Result<(Option, Fields, Option)> { let mut lookahead = input.lookahead1(); let mut where_clause = None; @@ -188,7 +187,7 @@ Err(lookahead.error()) } } else if lookahead.peek(token::Brace) { - let fields = data::parsing::parse_braced(input, attrs)?; + let fields = input.parse()?; Ok((where_clause, Fields::Named(fields), None)) } else if lookahead.peek(Token![;]) { let semi = input.parse()?; @@ -200,7 +199,6 @@ pub fn data_enum( input: ParseStream, - attrs: &mut Vec, ) -> Result<( Option, token::Brace, @@ -210,18 +208,14 @@ let content; let brace = braced!(content in input); - attr::parsing::parse_inner(&content, attrs)?; let variants = content.parse_terminated(Variant::parse)?; Ok((where_clause, brace, variants)) } - pub fn data_union( - input: ParseStream, - attrs: &mut Vec, - ) -> Result<(Option, FieldsNamed)> { + pub fn data_union(input: ParseStream) -> Result<(Option, FieldsNamed)> { let where_clause = input.parse()?; - let fields = data::parsing::parse_braced(input, attrs)?; + let fields = input.parse()?; Ok((where_clause, fields)) } } diff -Nru cargo-0.58.0/vendor/syn/src/error.rs cargo-0.60.0ubuntu1/vendor/syn/src/error.rs --- cargo-0.58.0/vendor/syn/src/error.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/error.rs 2022-04-20 13:48:09.000000000 +0000 @@ -47,10 +47,11 @@ /// ``` /// /// For errors that arise later than the initial parsing stage, the -/// [`.to_compile_error()`] method can be used to perform an explicit conversion -/// to `compile_error!`. +/// [`.to_compile_error()`] or [`.into_compile_error()`] methods can be used to +/// perform an explicit conversion to `compile_error!`. /// /// [`.to_compile_error()`]: Error::to_compile_error +/// [`.into_compile_error()`]: Error::into_compile_error /// /// ``` /// # extern crate proc_macro; @@ -66,7 +67,7 @@ /// /// // fn(DeriveInput) -> syn::Result /// expand::my_derive(input) -/// .unwrap_or_else(|err| err.to_compile_error()) +/// .unwrap_or_else(syn::Error::into_compile_error) /// .into() /// } /// # diff -Nru cargo-0.58.0/vendor/syn/src/export.rs cargo-0.60.0ubuntu1/vendor/syn/src/export.rs --- cargo-0.58.0/vendor/syn/src/export.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/export.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,6 +1,5 @@ pub use std::clone::Clone; pub use std::cmp::{Eq, PartialEq}; -pub use std::convert::From; pub use std::default::Default; pub use std::fmt::{self, Debug, Formatter}; pub use std::hash::{Hash, Hasher}; diff -Nru cargo-0.58.0/vendor/syn/src/expr.rs cargo-0.60.0ubuntu1/vendor/syn/src/expr.rs --- cargo-0.58.0/vendor/syn/src/expr.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/expr.rs 2022-04-20 13:48:09.000000000 +0000 @@ -87,6 +87,7 @@ /// see names getting repeated in your code, like accessing /// `receiver.receiver` or `pat.pat` or `cond.cond`. #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] pub enum Expr { /// A slice literal expression: `[a, b, c, d]`. Array(ExprArray), @@ -224,18 +225,17 @@ /// A yield expression: `yield expr`. Yield(ExprYield), - // The following is the only supported idiom for exhaustive matching of - // this enum. + // Not public API. + // + // For testing exhaustiveness in downstream code, use the following idiom: // // match expr { - // Expr::Array(e) => {...} - // Expr::Assign(e) => {...} + // Expr::Array(expr) => {...} + // Expr::Assign(expr) => {...} // ... - // Expr::Yield(e) => {...} + // Expr::Yield(expr) => {...} // - // #[cfg(test)] - // Expr::__TestExhaustive(_) => unimplemented!(), - // #[cfg(not(test))] + // #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))] // _ => { /* some sane fallback */ } // } // @@ -243,12 +243,9 @@ // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - // - // Once `deny(reachable)` is available in rustc, Expr will be - // reimplemented as a non_exhaustive enum. - // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237 + #[cfg(syn_no_non_exhaustive)] #[doc(hidden)] - __TestExhaustive(crate::private), + __NonExhaustive, } } @@ -403,8 +400,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprClosure #full { pub attrs: Vec, - pub asyncness: Option, pub movability: Option, + pub asyncness: Option, pub capture: Option, pub or1_token: Token![|], pub inputs: Punctuated, @@ -784,6 +781,16 @@ } impl Expr { + #[cfg(all(feature = "parsing", not(syn_no_const_vec_new)))] + const DUMMY: Self = Expr::Path(ExprPath { + attrs: Vec::new(), + qself: None, + path: Path { + leading_colon: None, + segments: Punctuated::new(), + }, + }); + #[cfg(all(feature = "parsing", feature = "full"))] pub(crate) fn replace_attrs(&mut self, new: Vec) -> Vec { match self { @@ -828,9 +835,7 @@ | Expr::Yield(ExprYield { attrs, .. }) => mem::replace(attrs, new), Expr::Verbatim(_) => Vec::new(), - #[cfg(test)] - Expr::__TestExhaustive(_) => unimplemented!(), - #[cfg(not(test))] + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1365,6 +1370,7 @@ } else if Precedence::Cast >= base && input.peek(Token![as]) { let as_token: Token![as] = input.parse()?; let ty = input.call(Type::without_plus)?; + check_cast(input)?; lhs = Expr::Cast(ExprCast { attrs: Vec::new(), expr: Box::new(lhs), @@ -1374,6 +1380,7 @@ } else if Precedence::Cast >= base && input.peek(Token![:]) && !input.peek(Token![::]) { let colon_token: Token![:] = input.parse()?; let ty = input.call(Type::without_plus)?; + check_cast(input)?; lhs = Expr::Type(ExprType { attrs: Vec::new(), expr: Box::new(lhs), @@ -1421,6 +1428,7 @@ } else if Precedence::Cast >= base && input.peek(Token![as]) { let as_token: Token![as] = input.parse()?; let ty = input.call(Type::without_plus)?; + check_cast(input)?; lhs = Expr::Cast(ExprCast { attrs: Vec::new(), expr: Box::new(lhs), @@ -1595,27 +1603,7 @@ let member: Member = input.parse()?; let turbofish = if member.is_named() && input.peek(Token![::]) { - Some(MethodTurbofish { - colon2_token: input.parse()?, - lt_token: input.parse()?, - args: { - let mut args = Punctuated::new(); - loop { - if input.peek(Token![>]) { - break; - } - let value = input.call(generic_method_argument)?; - args.push_value(value); - if input.peek(Token![>]) { - break; - } - let punct = input.parse()?; - args.push_punct(punct); - } - args - }, - gt_token: input.parse()?, - }) + Some(input.parse::()?) } else { None }; @@ -1731,6 +1719,12 @@ || input.peek(Token![move]) { expr_closure(input, allow_struct).map(Expr::Closure) + } else if input.peek(Token![for]) && input.peek2(Token![<]) && input.peek3(Lifetime) { + let begin = input.fork(); + input.parse::()?; + expr_closure(input, allow_struct)?; + let verbatim = verbatim::between(begin, input); + Ok(Expr::Verbatim(verbatim)) } else if input.peek(Ident) || input.peek(Token![::]) || input.peek(Token![<]) @@ -1854,8 +1848,7 @@ } if allow_struct.0 && input.peek(token::Brace) { - let outer_attrs = Vec::new(); - let expr_struct = expr_struct_helper(input, outer_attrs, expr.path)?; + let expr_struct = expr_struct_helper(input, expr.path)?; if expr.qself.is_some() { Ok(Expr::Verbatim(verbatim::between(begin, input))) } else { @@ -1881,10 +1874,9 @@ fn paren_or_tuple(input: ParseStream) -> Result { let content; let paren_token = parenthesized!(content in input); - let inner_attrs = content.call(Attribute::parse_inner)?; if content.is_empty() { return Ok(Expr::Tuple(ExprTuple { - attrs: inner_attrs, + attrs: Vec::new(), paren_token, elems: Punctuated::new(), })); @@ -1893,7 +1885,7 @@ let first: Expr = content.parse()?; if content.is_empty() { return Ok(Expr::Paren(ExprParen { - attrs: inner_attrs, + attrs: Vec::new(), paren_token, expr: Box::new(first), })); @@ -1911,7 +1903,7 @@ elems.push_value(value); } Ok(Expr::Tuple(ExprTuple { - attrs: inner_attrs, + attrs: Vec::new(), paren_token, elems, })) @@ -1921,10 +1913,9 @@ fn array_or_repeat(input: ParseStream) -> Result { let content; let bracket_token = bracketed!(content in input); - let inner_attrs = content.call(Attribute::parse_inner)?; if content.is_empty() { return Ok(Expr::Array(ExprArray { - attrs: inner_attrs, + attrs: Vec::new(), bracket_token, elems: Punctuated::new(), })); @@ -1944,7 +1935,7 @@ elems.push_value(value); } Ok(Expr::Array(ExprArray { - attrs: inner_attrs, + attrs: Vec::new(), bracket_token, elems, })) @@ -1952,7 +1943,7 @@ let semi_token: Token![;] = content.parse()?; let len: Expr = content.parse()?; Ok(Expr::Repeat(ExprRepeat { - attrs: inner_attrs, + attrs: Vec::new(), bracket_token, expr: Box::new(first), semi_token, @@ -1969,7 +1960,6 @@ fn parse(input: ParseStream) -> Result { let content; let bracket_token = bracketed!(content in input); - let inner_attrs = content.call(Attribute::parse_inner)?; let mut elems = Punctuated::new(); while !content.is_empty() { @@ -1983,7 +1973,7 @@ } Ok(ExprArray { - attrs: inner_attrs, + attrs: Vec::new(), bracket_token, elems, }) @@ -1997,7 +1987,7 @@ let content; Ok(ExprRepeat { bracket_token: bracketed!(content in input), - attrs: content.call(Attribute::parse_inner)?, + attrs: Vec::new(), expr: content.parse()?, semi_token: content.parse()?, len: content.parse()?, @@ -2089,18 +2079,49 @@ } #[cfg(feature = "full")] - fn generic_method_argument(input: ParseStream) -> Result { - if input.peek(Lit) { - let lit = input.parse()?; - return Ok(GenericMethodArgument::Const(Expr::Lit(lit))); - } + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + impl Parse for GenericMethodArgument { + fn parse(input: ParseStream) -> Result { + if input.peek(Lit) { + let lit = input.parse()?; + return Ok(GenericMethodArgument::Const(Expr::Lit(lit))); + } - if input.peek(token::Brace) { - let block: ExprBlock = input.parse()?; - return Ok(GenericMethodArgument::Const(Expr::Block(block))); + if input.peek(token::Brace) { + let block: ExprBlock = input.parse()?; + return Ok(GenericMethodArgument::Const(Expr::Block(block))); + } + + input.parse().map(GenericMethodArgument::Type) } + } - input.parse().map(GenericMethodArgument::Type) + #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + impl Parse for MethodTurbofish { + fn parse(input: ParseStream) -> Result { + Ok(MethodTurbofish { + colon2_token: input.parse()?, + lt_token: input.parse()?, + args: { + let mut args = Punctuated::new(); + loop { + if input.peek(Token![>]) { + break; + } + let value: GenericMethodArgument = input.parse()?; + args.push_value(value); + if input.peek(Token![>]) { + break; + } + let punct = input.parse()?; + args.push_punct(punct); + } + args + }, + gt_token: input.parse()?, + }) + } } #[cfg(feature = "full")] @@ -2112,7 +2133,11 @@ let_token: input.parse()?, pat: pat::parsing::multi_pat_with_leading_vert(input)?, eq_token: input.parse()?, - expr: Box::new(input.call(Expr::parse_without_eager_brace)?), + expr: Box::new({ + let allow_struct = AllowStruct(false); + let lhs = unary_expr(input, allow_struct)?; + parse_expr(input, lhs, allow_struct, Precedence::Compare)? + }), }) } } @@ -2263,18 +2288,19 @@ } impl_by_parsing_expr! { - ExprCall, Call, "expected function call expression", - ExprMethodCall, MethodCall, "expected method call expression", - ExprTuple, Tuple, "expected tuple expression", - ExprBinary, Binary, "expected binary operation", - ExprCast, Cast, "expected cast expression", - ExprType, Type, "expected type ascription expression", ExprAssign, Assign, "expected assignment expression", ExprAssignOp, AssignOp, "expected compound assignment expression", + ExprAwait, Await, "expected await expression", + ExprBinary, Binary, "expected binary operation", + ExprCall, Call, "expected function call expression", + ExprCast, Cast, "expected cast expression", ExprField, Field, "expected struct field access", ExprIndex, Index, "expected indexing expression", + ExprMethodCall, MethodCall, "expected method call expression", ExprRange, Range, "expected range expression", ExprTry, Try, "expected try expression", + ExprTuple, Tuple, "expected tuple expression", + ExprType, Type, "expected type ascription expression", } #[cfg(feature = "full")] @@ -2397,12 +2423,8 @@ #[cfg(feature = "full")] fn expr_closure(input: ParseStream, allow_struct: AllowStruct) -> Result { + let movability: Option = input.parse()?; let asyncness: Option = input.parse()?; - let movability: Option = if asyncness.is_none() { - input.parse()? - } else { - None - }; let capture: Option = input.parse()?; let or1_token: Token![|] = input.parse()?; @@ -2440,8 +2462,8 @@ Ok(ExprClosure { attrs: Vec::new(), - asyncness, movability, + asyncness, capture, or1_token, inputs, @@ -2495,9 +2517,7 @@ Pat::Verbatim(_) => {} Pat::Wild(pat) => pat.attrs = attrs, - #[cfg(test)] - Pat::__TestExhaustive(_) => unimplemented!(), - #[cfg(not(test))] + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } Ok(pat) @@ -2639,27 +2659,21 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ExprStruct { fn parse(input: ParseStream) -> Result { - let attrs = Vec::new(); let path: Path = input.parse()?; - expr_struct_helper(input, attrs, path) + expr_struct_helper(input, path) } } #[cfg(feature = "full")] - fn expr_struct_helper( - input: ParseStream, - mut attrs: Vec, - path: Path, - ) -> Result { + fn expr_struct_helper(input: ParseStream, path: Path) -> Result { let content; let brace_token = braced!(content in input); - attr::parsing::parse_inner(&content, &mut attrs)?; let mut fields = Punctuated::new(); while !content.is_empty() { if content.peek(Token![..]) { return Ok(ExprStruct { - attrs, + attrs: Vec::new(), brace_token, path, fields, @@ -2681,7 +2695,7 @@ } Ok(ExprStruct { - attrs, + attrs: Vec::new(), brace_token, path, fields, @@ -2869,7 +2883,10 @@ } for part in float_repr.split('.') { let index = crate::parse_str(part).map_err(|err| Error::new(float.span(), err))?; - let base = mem::replace(e, Expr::__TestExhaustive(crate::private(()))); + #[cfg(not(syn_no_const_vec_new))] + let base = mem::replace(e, Expr::DUMMY); + #[cfg(syn_no_const_vec_new)] + let base = mem::replace(e, Expr::Verbatim(TokenStream::new())); *e = Expr::Field(ExprField { attrs: Vec::new(), base: Box::new(base), @@ -2890,6 +2907,28 @@ } } } + + fn check_cast(input: ParseStream) -> Result<()> { + let kind = if input.peek(Token![.]) && !input.peek(Token![..]) { + if input.peek2(token::Await) { + "`.await`" + } else if input.peek2(Ident) && (input.peek3(token::Paren) || input.peek3(Token![::])) { + "a method call" + } else { + "a field access" + } + } else if input.peek(Token![?]) { + "`?`" + } else if input.peek(token::Bracket) { + "indexing" + } else if input.peek(token::Paren) { + "a function call" + } else { + return Ok(()); + }; + let msg = format!("casts cannot be followed by {}", kind); + Err(input.error(msg)) + } } #[cfg(feature = "printing")] @@ -2926,9 +2965,6 @@ #[cfg(not(feature = "full"))] pub(crate) fn outer_attrs_to_tokens(_attrs: &[Attribute], _tokens: &mut TokenStream) {} - #[cfg(not(feature = "full"))] - fn inner_attrs_to_tokens(_attrs: &[Attribute], _tokens: &mut TokenStream) {} - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for ExprBox { @@ -2945,7 +2981,6 @@ fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); self.bracket_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); self.elems.to_tokens(tokens); }); } @@ -3005,7 +3040,6 @@ fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); self.paren_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); self.elems.to_tokens(tokens); // If we only have one argument, we need a trailing comma to // distinguish ExprTuple from ExprParen. @@ -3223,8 +3257,8 @@ impl ToTokens for ExprClosure { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.asyncness.to_tokens(tokens); self.movability.to_tokens(tokens); + self.asyncness.to_tokens(tokens); self.capture.to_tokens(tokens); self.or1_token.to_tokens(tokens); self.inputs.to_tokens(tokens); @@ -3324,14 +3358,22 @@ #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprRange { + impl ToTokens for RangeLimits { fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.from.to_tokens(tokens); - match &self.limits { + match self { RangeLimits::HalfOpen(t) => t.to_tokens(tokens), RangeLimits::Closed(t) => t.to_tokens(tokens), } + } + } + + #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] + impl ToTokens for ExprRange { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.from.to_tokens(tokens); + self.limits.to_tokens(tokens); self.to.to_tokens(tokens); } } @@ -3340,7 +3382,7 @@ impl ToTokens for ExprPath { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - private::print_path(tokens, &self.qself, &self.path); + path::printing::print_path(tokens, &self.qself, &self.path); } } @@ -3402,7 +3444,6 @@ outer_attrs_to_tokens(&self.attrs, tokens); self.path.to_tokens(tokens); self.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); self.fields.to_tokens(tokens); if let Some(dot2_token) = &self.dot2_token { dot2_token.to_tokens(tokens); @@ -3420,7 +3461,6 @@ fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); self.bracket_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); self.expr.to_tokens(tokens); self.semi_token.to_tokens(tokens); self.len.to_tokens(tokens); @@ -3444,7 +3484,6 @@ fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); self.paren_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); self.expr.to_tokens(tokens); }); } diff -Nru cargo-0.58.0/vendor/syn/src/gen/clone.rs cargo-0.60.0ubuntu1/vendor/syn/src/gen/clone.rs --- cargo-0.58.0/vendor/syn/src/gen/clone.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/gen/clone.rs 2022-04-20 13:48:09.000000000 +0000 @@ -273,6 +273,7 @@ Expr::While(v0) => Expr::While(v0.clone()), #[cfg(feature = "full")] Expr::Yield(v0) => Expr::Yield(v0.clone()), + #[cfg(any(syn_no_non_exhaustive, not(feature = "full")))] _ => unreachable!(), } } @@ -412,8 +413,8 @@ fn clone(&self) -> Self { ExprClosure { attrs: self.attrs.clone(), - asyncness: self.asyncness.clone(), movability: self.movability.clone(), + asyncness: self.asyncness.clone(), capture: self.capture.clone(), or1_token: self.or1_token.clone(), inputs: self.inputs.clone(), @@ -845,6 +846,7 @@ ForeignItem::Type(v0) => ForeignItem::Type(v0.clone()), ForeignItem::Macro(v0) => ForeignItem::Macro(v0.clone()), ForeignItem::Verbatim(v0) => ForeignItem::Verbatim(v0.clone()), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -957,6 +959,7 @@ ImplItem::Type(v0) => ImplItem::Type(v0.clone()), ImplItem::Macro(v0) => ImplItem::Macro(v0.clone()), ImplItem::Verbatim(v0) => ImplItem::Verbatim(v0.clone()), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1052,6 +1055,7 @@ Item::Union(v0) => Item::Union(v0.clone()), Item::Use(v0) => Item::Use(v0.clone()), Item::Verbatim(v0) => Item::Verbatim(v0.clone()), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1474,6 +1478,7 @@ Pat::Type(v0) => Pat::Type(v0.clone()), Pat::Verbatim(v0) => Pat::Verbatim(v0.clone()), Pat::Wild(v0) => Pat::Wild(v0.clone()), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1662,7 +1667,9 @@ fn clone(&self) -> Self { match self { PathArguments::None => PathArguments::None, - PathArguments::AngleBracketed(v0) => PathArguments::AngleBracketed(v0.clone()), + PathArguments::AngleBracketed(v0) => { + PathArguments::AngleBracketed(v0.clone()) + } PathArguments::Parenthesized(v0) => PathArguments::Parenthesized(v0.clone()), } } @@ -1819,6 +1826,7 @@ TraitItem::Type(v0) => TraitItem::Type(v0.clone()), TraitItem::Macro(v0) => TraitItem::Macro(v0.clone()), TraitItem::Verbatim(v0) => TraitItem::Verbatim(v0.clone()), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1897,6 +1905,7 @@ Type::TraitObject(v0) => Type::TraitObject(v0.clone()), Type::Tuple(v0) => Type::Tuple(v0.clone()), Type::Verbatim(v0) => Type::Verbatim(v0.clone()), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1962,9 +1971,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for TypeMacro { fn clone(&self) -> Self { - TypeMacro { - mac: self.mac.clone(), - } + TypeMacro { mac: self.mac.clone() } } } #[cfg(any(feature = "derive", feature = "full"))] diff -Nru cargo-0.58.0/vendor/syn/src/gen/debug.rs cargo-0.60.0ubuntu1/vendor/syn/src/gen/debug.rs --- cargo-0.58.0/vendor/syn/src/gen/debug.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/gen/debug.rs 2022-04-20 13:48:09.000000000 +0000 @@ -587,6 +587,7 @@ formatter.field(v0); formatter.finish() } + #[cfg(any(syn_no_non_exhaustive, not(feature = "full")))] _ => unreachable!(), } } @@ -726,8 +727,8 @@ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let mut formatter = formatter.debug_struct("ExprClosure"); formatter.field("attrs", &self.attrs); - formatter.field("asyncness", &self.asyncness); formatter.field("movability", &self.movability); + formatter.field("asyncness", &self.asyncness); formatter.field("capture", &self.capture); formatter.field("or1_token", &self.or1_token); formatter.field("inputs", &self.inputs); @@ -1195,6 +1196,7 @@ formatter.field(v0); formatter.finish() } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1367,6 +1369,7 @@ formatter.field(v0); formatter.finish() } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1530,6 +1533,7 @@ formatter.field(v0); formatter.finish() } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2088,6 +2092,7 @@ formatter.field(v0); formatter.finish() } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2495,6 +2500,7 @@ formatter.field(v0); formatter.finish() } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2633,6 +2639,7 @@ formatter.field(v0); formatter.finish() } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } diff -Nru cargo-0.58.0/vendor/syn/src/gen/eq.rs cargo-0.60.0ubuntu1/vendor/syn/src/gen/eq.rs --- cargo-0.58.0/vendor/syn/src/gen/eq.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/gen/eq.rs 2022-04-20 13:48:09.000000000 +0000 @@ -31,11 +31,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Arm { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.pat == other.pat - && self.guard == other.guard - && self.body == other.body - && self.comma == other.comma + self.attrs == other.attrs && self.pat == other.pat && self.guard == other.guard + && self.body == other.body && self.comma == other.comma } } #[cfg(any(feature = "derive", feature = "full"))] @@ -59,8 +56,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Attribute { fn eq(&self, other: &Self) -> bool { - self.style == other.style - && self.path == other.path + self.style == other.style && self.path == other.path && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens) } } @@ -151,11 +147,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ConstParam { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.ty == other.ty - && self.eq_token == other.eq_token - && self.default == other.default + self.attrs == other.attrs && self.ident == other.ident && self.ty == other.ty + && self.eq_token == other.eq_token && self.default == other.default } } #[cfg(any(feature = "derive", feature = "full"))] @@ -220,11 +213,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for DeriveInput { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.data == other.data + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.data == other.data } } #[cfg(any(feature = "derive", feature = "full"))] @@ -338,9 +328,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprAssignOp { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.left == other.left - && self.op == other.op + self.attrs == other.attrs && self.left == other.left && self.op == other.op && self.right == other.right } } @@ -351,7 +339,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprAsync { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.capture == other.capture && self.block == other.block + self.attrs == other.attrs && self.capture == other.capture + && self.block == other.block } } #[cfg(feature = "full")] @@ -371,9 +360,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprBinary { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.left == other.left - && self.op == other.op + self.attrs == other.attrs && self.left == other.left && self.op == other.op && self.right == other.right } } @@ -384,7 +371,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprBlock { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.label == other.label && self.block == other.block + self.attrs == other.attrs && self.label == other.label + && self.block == other.block } } #[cfg(feature = "full")] @@ -434,12 +422,9 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprClosure { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.asyncness == other.asyncness - && self.movability == other.movability - && self.capture == other.capture - && self.inputs == other.inputs - && self.output == other.output + self.attrs == other.attrs && self.movability == other.movability + && self.asyncness == other.asyncness && self.capture == other.capture + && self.inputs == other.inputs && self.output == other.output && self.body == other.body } } @@ -460,7 +445,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprField { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.base == other.base && self.member == other.member + self.attrs == other.attrs && self.base == other.base + && self.member == other.member } } #[cfg(feature = "full")] @@ -470,11 +456,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprForLoop { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.label == other.label - && self.pat == other.pat - && self.expr == other.expr - && self.body == other.body + self.attrs == other.attrs && self.label == other.label && self.pat == other.pat + && self.expr == other.expr && self.body == other.body } } #[cfg(feature = "full")] @@ -494,8 +477,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprIf { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.cond == other.cond + self.attrs == other.attrs && self.cond == other.cond && self.then_branch == other.then_branch && self.else_branch == other.else_branch } @@ -567,10 +549,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprMethodCall { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.receiver == other.receiver - && self.method == other.method - && self.turbofish == other.turbofish + self.attrs == other.attrs && self.receiver == other.receiver + && self.method == other.method && self.turbofish == other.turbofish && self.args == other.args } } @@ -601,10 +581,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprRange { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.from == other.from - && self.limits == other.limits - && self.to == other.to + self.attrs == other.attrs && self.from == other.from + && self.limits == other.limits && self.to == other.to } } #[cfg(feature = "full")] @@ -614,7 +592,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprReference { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mutability == other.mutability && self.expr == other.expr + self.attrs == other.attrs && self.mutability == other.mutability + && self.expr == other.expr } } #[cfg(feature = "full")] @@ -644,10 +623,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprStruct { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.path == other.path - && self.fields == other.fields - && self.dot2_token == other.dot2_token + self.attrs == other.attrs && self.path == other.path + && self.fields == other.fields && self.dot2_token == other.dot2_token && self.rest == other.rest } } @@ -718,9 +695,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprWhile { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.label == other.label - && self.cond == other.cond + self.attrs == other.attrs && self.label == other.label && self.cond == other.cond && self.body == other.body } } @@ -741,11 +716,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Field { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.colon_token == other.colon_token - && self.ty == other.ty + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.colon_token == other.colon_token && self.ty == other.ty } } #[cfg(feature = "full")] @@ -755,10 +727,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for FieldPat { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.member == other.member - && self.colon_token == other.colon_token - && self.pat == other.pat + self.attrs == other.attrs && self.member == other.member + && self.colon_token == other.colon_token && self.pat == other.pat } } #[cfg(feature = "full")] @@ -768,10 +738,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for FieldValue { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.member == other.member - && self.colon_token == other.colon_token - && self.expr == other.expr + self.attrs == other.attrs && self.member == other.member + && self.colon_token == other.colon_token && self.expr == other.expr } } #[cfg(any(feature = "derive", feature = "full"))] @@ -816,7 +784,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for File { fn eq(&self, other: &Self) -> bool { - self.shebang == other.shebang && self.attrs == other.attrs && self.items == other.items + self.shebang == other.shebang && self.attrs == other.attrs + && self.items == other.items } } #[cfg(feature = "full")] @@ -869,7 +838,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ForeignItemMacro { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mac == other.mac && self.semi_token == other.semi_token + self.attrs == other.attrs && self.mac == other.mac + && self.semi_token == other.semi_token } } #[cfg(feature = "full")] @@ -879,10 +849,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ForeignItemStatic { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.mutability == other.mutability - && self.ident == other.ident + self.attrs == other.attrs && self.vis == other.vis + && self.mutability == other.mutability && self.ident == other.ident && self.ty == other.ty } } @@ -907,12 +875,18 @@ (GenericArgument::Lifetime(self0), GenericArgument::Lifetime(other0)) => { self0 == other0 } - (GenericArgument::Type(self0), GenericArgument::Type(other0)) => self0 == other0, - (GenericArgument::Binding(self0), GenericArgument::Binding(other0)) => self0 == other0, + (GenericArgument::Type(self0), GenericArgument::Type(other0)) => { + self0 == other0 + } + (GenericArgument::Binding(self0), GenericArgument::Binding(other0)) => { + self0 == other0 + } (GenericArgument::Constraint(self0), GenericArgument::Constraint(other0)) => { self0 == other0 } - (GenericArgument::Const(self0), GenericArgument::Const(other0)) => self0 == other0, + (GenericArgument::Const(self0), GenericArgument::Const(other0)) => { + self0 == other0 + } _ => false, } } @@ -928,9 +902,10 @@ (GenericMethodArgument::Type(self0), GenericMethodArgument::Type(other0)) => { self0 == other0 } - (GenericMethodArgument::Const(self0), GenericMethodArgument::Const(other0)) => { - self0 == other0 - } + ( + GenericMethodArgument::Const(self0), + GenericMethodArgument::Const(other0), + ) => self0 == other0, _ => false, } } @@ -944,7 +919,9 @@ fn eq(&self, other: &Self) -> bool { match (self, other) { (GenericParam::Type(self0), GenericParam::Type(other0)) => self0 == other0, - (GenericParam::Lifetime(self0), GenericParam::Lifetime(other0)) => self0 == other0, + (GenericParam::Lifetime(self0), GenericParam::Lifetime(other0)) => { + self0 == other0 + } (GenericParam::Const(self0), GenericParam::Const(other0)) => self0 == other0, _ => false, } @@ -957,10 +934,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Generics { fn eq(&self, other: &Self) -> bool { - self.lt_token == other.lt_token - && self.params == other.params - && self.gt_token == other.gt_token - && self.where_clause == other.where_clause + self.lt_token == other.lt_token && self.params == other.params + && self.gt_token == other.gt_token && self.where_clause == other.where_clause } } #[cfg(feature = "full")] @@ -989,12 +964,9 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ImplItemConst { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.defaultness == other.defaultness - && self.ident == other.ident - && self.ty == other.ty - && self.expr == other.expr + self.attrs == other.attrs && self.vis == other.vis + && self.defaultness == other.defaultness && self.ident == other.ident + && self.ty == other.ty && self.expr == other.expr } } #[cfg(feature = "full")] @@ -1004,7 +976,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ImplItemMacro { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mac == other.mac && self.semi_token == other.semi_token + self.attrs == other.attrs && self.mac == other.mac + && self.semi_token == other.semi_token } } #[cfg(feature = "full")] @@ -1014,10 +987,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ImplItemMethod { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.defaultness == other.defaultness - && self.sig == other.sig + self.attrs == other.attrs && self.vis == other.vis + && self.defaultness == other.defaultness && self.sig == other.sig && self.block == other.block } } @@ -1028,12 +999,9 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ImplItemType { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.defaultness == other.defaultness - && self.ident == other.ident - && self.generics == other.generics - && self.ty == other.ty + self.attrs == other.attrs && self.vis == other.vis + && self.defaultness == other.defaultness && self.ident == other.ident + && self.generics == other.generics && self.ty == other.ty } } #[cfg(feature = "full")] @@ -1074,11 +1042,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemConst { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.ty == other.ty - && self.expr == other.expr + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.ty == other.ty && self.expr == other.expr } } #[cfg(feature = "full")] @@ -1088,11 +1053,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemEnum { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.variants == other.variants + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.variants == other.variants } } #[cfg(feature = "full")] @@ -1102,9 +1064,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemExternCrate { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident && self.rename == other.rename } } @@ -1115,9 +1075,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemFn { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.sig == other.sig + self.attrs == other.attrs && self.vis == other.vis && self.sig == other.sig && self.block == other.block } } @@ -1138,12 +1096,9 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemImpl { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.defaultness == other.defaultness - && self.unsafety == other.unsafety - && self.generics == other.generics - && self.trait_ == other.trait_ - && self.self_ty == other.self_ty + self.attrs == other.attrs && self.defaultness == other.defaultness + && self.unsafety == other.unsafety && self.generics == other.generics + && self.trait_ == other.trait_ && self.self_ty == other.self_ty && self.items == other.items } } @@ -1154,9 +1109,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemMacro { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.mac == other.mac + self.attrs == other.attrs && self.ident == other.ident && self.mac == other.mac && self.semi_token == other.semi_token } } @@ -1167,9 +1120,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemMacro2 { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident && TokenStreamHelper(&self.rules) == TokenStreamHelper(&other.rules) } } @@ -1180,11 +1131,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemMod { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.content == other.content - && self.semi == other.semi + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.content == other.content && self.semi == other.semi } } #[cfg(feature = "full")] @@ -1194,12 +1142,9 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemStatic { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.mutability == other.mutability - && self.ident == other.ident - && self.ty == other.ty - && self.expr == other.expr + self.attrs == other.attrs && self.vis == other.vis + && self.mutability == other.mutability && self.ident == other.ident + && self.ty == other.ty && self.expr == other.expr } } #[cfg(feature = "full")] @@ -1209,11 +1154,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemStruct { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.fields == other.fields + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.fields == other.fields && self.semi_token == other.semi_token } } @@ -1224,15 +1166,11 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemTrait { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.unsafety == other.unsafety - && self.auto_token == other.auto_token - && self.ident == other.ident - && self.generics == other.generics + self.attrs == other.attrs && self.vis == other.vis + && self.unsafety == other.unsafety && self.auto_token == other.auto_token + && self.ident == other.ident && self.generics == other.generics && self.colon_token == other.colon_token - && self.supertraits == other.supertraits - && self.items == other.items + && self.supertraits == other.supertraits && self.items == other.items } } #[cfg(feature = "full")] @@ -1242,11 +1180,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemTraitAlias { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.bounds == other.bounds + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.bounds == other.bounds } } #[cfg(feature = "full")] @@ -1256,11 +1191,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemType { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.ty == other.ty + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.ty == other.ty } } #[cfg(feature = "full")] @@ -1270,11 +1202,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemUnion { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.ident == other.ident - && self.generics == other.generics - && self.fields == other.fields + self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics && self.fields == other.fields } } #[cfg(feature = "full")] @@ -1284,10 +1213,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemUse { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.leading_colon == other.leading_colon - && self.tree == other.tree + self.attrs == other.attrs && self.vis == other.vis + && self.leading_colon == other.leading_colon && self.tree == other.tree } } #[cfg(feature = "full")] @@ -1307,10 +1234,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for LifetimeDef { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.lifetime == other.lifetime - && self.colon_token == other.colon_token - && self.bounds == other.bounds + self.attrs == other.attrs && self.lifetime == other.lifetime + && self.colon_token == other.colon_token && self.bounds == other.bounds } } #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -1370,8 +1295,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Macro { fn eq(&self, other: &Self) -> bool { - self.path == other.path - && self.delimiter == other.delimiter + self.path == other.path && self.delimiter == other.delimiter && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens) } } @@ -1506,10 +1430,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatIdent { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.by_ref == other.by_ref - && self.mutability == other.mutability - && self.ident == other.ident + self.attrs == other.attrs && self.by_ref == other.by_ref + && self.mutability == other.mutability && self.ident == other.ident && self.subpat == other.subpat } } @@ -1540,8 +1462,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatOr { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.leading_vert == other.leading_vert + self.attrs == other.attrs && self.leading_vert == other.leading_vert && self.cases == other.cases } } @@ -1562,9 +1483,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatRange { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.lo == other.lo - && self.limits == other.limits + self.attrs == other.attrs && self.lo == other.lo && self.limits == other.limits && self.hi == other.hi } } @@ -1575,7 +1494,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatReference { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mutability == other.mutability && self.pat == other.pat + self.attrs == other.attrs && self.mutability == other.mutability + && self.pat == other.pat } } #[cfg(feature = "full")] @@ -1605,10 +1525,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatStruct { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.path == other.path - && self.fields == other.fields - && self.dot2_token == other.dot2_token + self.attrs == other.attrs && self.path == other.path + && self.fields == other.fields && self.dot2_token == other.dot2_token } } #[cfg(feature = "full")] @@ -1670,12 +1588,14 @@ fn eq(&self, other: &Self) -> bool { match (self, other) { (PathArguments::None, PathArguments::None) => true, - (PathArguments::AngleBracketed(self0), PathArguments::AngleBracketed(other0)) => { - self0 == other0 - } - (PathArguments::Parenthesized(self0), PathArguments::Parenthesized(other0)) => { - self0 == other0 - } + ( + PathArguments::AngleBracketed(self0), + PathArguments::AngleBracketed(other0), + ) => self0 == other0, + ( + PathArguments::Parenthesized(self0), + PathArguments::Parenthesized(other0), + ) => self0 == other0, _ => false, } } @@ -1717,8 +1637,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PredicateType { fn eq(&self, other: &Self) -> bool { - self.lifetimes == other.lifetimes - && self.bounded_ty == other.bounded_ty + self.lifetimes == other.lifetimes && self.bounded_ty == other.bounded_ty && self.bounds == other.bounds } } @@ -1729,7 +1648,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for QSelf { fn eq(&self, other: &Self) -> bool { - self.ty == other.ty && self.position == other.position && self.as_token == other.as_token + self.ty == other.ty && self.position == other.position + && self.as_token == other.as_token } } #[cfg(feature = "full")] @@ -1753,8 +1673,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Receiver { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.reference == other.reference + self.attrs == other.attrs && self.reference == other.reference && self.mutability == other.mutability } } @@ -1779,14 +1698,10 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Signature { fn eq(&self, other: &Self) -> bool { - self.constness == other.constness - && self.asyncness == other.asyncness - && self.unsafety == other.unsafety - && self.abi == other.abi - && self.ident == other.ident - && self.generics == other.generics - && self.inputs == other.inputs - && self.variadic == other.variadic + self.constness == other.constness && self.asyncness == other.asyncness + && self.unsafety == other.unsafety && self.abi == other.abi + && self.ident == other.ident && self.generics == other.generics + && self.inputs == other.inputs && self.variadic == other.variadic && self.output == other.output } } @@ -1813,10 +1728,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitBound { fn eq(&self, other: &Self) -> bool { - self.paren_token == other.paren_token - && self.modifier == other.modifier - && self.lifetimes == other.lifetimes - && self.path == other.path + self.paren_token == other.paren_token && self.modifier == other.modifier + && self.lifetimes == other.lifetimes && self.path == other.path } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1859,9 +1772,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitItemConst { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.ty == other.ty + self.attrs == other.attrs && self.ident == other.ident && self.ty == other.ty && self.default == other.default } } @@ -1872,7 +1783,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitItemMacro { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mac == other.mac && self.semi_token == other.semi_token + self.attrs == other.attrs && self.mac == other.mac + && self.semi_token == other.semi_token } } #[cfg(feature = "full")] @@ -1882,10 +1794,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitItemMethod { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.sig == other.sig - && self.default == other.default - && self.semi_token == other.semi_token + self.attrs == other.attrs && self.sig == other.sig + && self.default == other.default && self.semi_token == other.semi_token } } #[cfg(feature = "full")] @@ -1895,12 +1805,9 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitItemType { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.generics == other.generics - && self.colon_token == other.colon_token - && self.bounds == other.bounds - && self.default == other.default + self.attrs == other.attrs && self.ident == other.ident + && self.generics == other.generics && self.colon_token == other.colon_token + && self.bounds == other.bounds && self.default == other.default } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1949,12 +1856,9 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TypeBareFn { fn eq(&self, other: &Self) -> bool { - self.lifetimes == other.lifetimes - && self.unsafety == other.unsafety - && self.abi == other.abi - && self.inputs == other.inputs - && self.variadic == other.variadic - && self.output == other.output + self.lifetimes == other.lifetimes && self.unsafety == other.unsafety + && self.abi == other.abi && self.inputs == other.inputs + && self.variadic == other.variadic && self.output == other.output } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2014,12 +1918,9 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TypeParam { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.colon_token == other.colon_token - && self.bounds == other.bounds - && self.eq_token == other.eq_token - && self.default == other.default + self.attrs == other.attrs && self.ident == other.ident + && self.colon_token == other.colon_token && self.bounds == other.bounds + && self.eq_token == other.eq_token && self.default == other.default } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2030,8 +1931,12 @@ impl PartialEq for TypeParamBound { fn eq(&self, other: &Self) -> bool { match (self, other) { - (TypeParamBound::Trait(self0), TypeParamBound::Trait(other0)) => self0 == other0, - (TypeParamBound::Lifetime(self0), TypeParamBound::Lifetime(other0)) => self0 == other0, + (TypeParamBound::Trait(self0), TypeParamBound::Trait(other0)) => { + self0 == other0 + } + (TypeParamBound::Lifetime(self0), TypeParamBound::Lifetime(other0)) => { + self0 == other0 + } _ => false, } } @@ -2063,8 +1968,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TypePtr { fn eq(&self, other: &Self) -> bool { - self.const_token == other.const_token - && self.mutability == other.mutability + self.const_token == other.const_token && self.mutability == other.mutability && self.elem == other.elem } } @@ -2075,8 +1979,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TypeReference { fn eq(&self, other: &Self) -> bool { - self.lifetime == other.lifetime - && self.mutability == other.mutability + self.lifetime == other.lifetime && self.mutability == other.mutability && self.elem == other.elem } } @@ -2209,10 +2112,8 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Variant { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.ident == other.ident - && self.fields == other.fields - && self.discriminant == other.discriminant + self.attrs == other.attrs && self.ident == other.ident + && self.fields == other.fields && self.discriminant == other.discriminant } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2255,7 +2156,9 @@ match (self, other) { (Visibility::Public(self0), Visibility::Public(other0)) => self0 == other0, (Visibility::Crate(self0), Visibility::Crate(other0)) => self0 == other0, - (Visibility::Restricted(self0), Visibility::Restricted(other0)) => self0 == other0, + (Visibility::Restricted(self0), Visibility::Restricted(other0)) => { + self0 == other0 + } (Visibility::Inherited, Visibility::Inherited) => true, _ => false, } @@ -2279,8 +2182,12 @@ impl PartialEq for WherePredicate { fn eq(&self, other: &Self) -> bool { match (self, other) { - (WherePredicate::Type(self0), WherePredicate::Type(other0)) => self0 == other0, - (WherePredicate::Lifetime(self0), WherePredicate::Lifetime(other0)) => self0 == other0, + (WherePredicate::Type(self0), WherePredicate::Type(other0)) => { + self0 == other0 + } + (WherePredicate::Lifetime(self0), WherePredicate::Lifetime(other0)) => { + self0 == other0 + } (WherePredicate::Eq(self0), WherePredicate::Eq(other0)) => self0 == other0, _ => false, } diff -Nru cargo-0.58.0/vendor/syn/src/gen/fold.rs cargo-0.60.0ubuntu1/vendor/syn/src/gen/fold.rs --- cargo-0.58.0/vendor/syn/src/gen/fold.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/gen/fold.rs 2022-04-20 13:48:09.000000000 +0000 @@ -317,7 +317,10 @@ fold_generic_argument(self, i) } #[cfg(feature = "full")] - fn fold_generic_method_argument(&mut self, i: GenericMethodArgument) -> GenericMethodArgument { + fn fold_generic_method_argument( + &mut self, + i: GenericMethodArgument, + ) -> GenericMethodArgument { fold_generic_method_argument(self, i) } #[cfg(any(feature = "derive", feature = "full"))] @@ -621,7 +624,10 @@ fold_trait_bound(self, i) } #[cfg(any(feature = "derive", feature = "full"))] - fn fold_trait_bound_modifier(&mut self, i: TraitBoundModifier) -> TraitBoundModifier { + fn fold_trait_bound_modifier( + &mut self, + i: TraitBoundModifier, + ) -> TraitBoundModifier { fold_trait_bound_modifier(self, i) } #[cfg(feature = "full")] @@ -792,10 +798,11 @@ F: Fold + ?Sized, { AngleBracketedGenericArguments { - colon2_token: (node.colon2_token).map(|it| Token ! [::](tokens_helper(f, &it.spans))), - lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), + colon2_token: (node.colon2_token) + .map(|it| Token![::](tokens_helper(f, &it.spans))), + lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), args: FoldHelper::lift(node.args, |it| f.fold_generic_argument(it)), - gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), + gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), } } #[cfg(feature = "full")] @@ -806,15 +813,14 @@ Arm { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), pat: f.fold_pat(node.pat), - guard: (node.guard).map(|it| { - ( + guard: (node.guard) + .map(|it| ( Token![if](tokens_helper(f, &(it).0.span)), Box::new(f.fold_expr(*(it).1)), - ) - }), - fat_arrow_token: Token ! [=>](tokens_helper(f, &node.fat_arrow_token.spans)), + )), + fat_arrow_token: Token![=>](tokens_helper(f, &node.fat_arrow_token.spans)), body: Box::new(f.fold_expr(*node.body)), - comma: (node.comma).map(|it| Token ! [,](tokens_helper(f, &it.spans))), + comma: (node.comma).map(|it| Token![,](tokens_helper(f, &it.spans))), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -835,7 +841,7 @@ F: Fold + ?Sized, { Attribute { - pound_token: Token ! [#](tokens_helper(f, &node.pound_token.spans)), + pound_token: Token![#](tokens_helper(f, &node.pound_token.spans)), style: f.fold_attr_style(node.style), bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), path: f.fold_path(node.path), @@ -849,12 +855,11 @@ { BareFnArg { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - name: (node.name).map(|it| { - ( + name: (node.name) + .map(|it| ( f.fold_ident((it).0), - Token ! [:](tokens_helper(f, &(it).1.spans)), - ) - }), + Token![:](tokens_helper(f, &(it).1.spans)), + )), ty: f.fold_type(node.ty), } } @@ -864,47 +869,89 @@ F: Fold + ?Sized, { match node { - BinOp::Add(_binding_0) => BinOp::Add(Token ! [+](tokens_helper(f, &_binding_0.spans))), - BinOp::Sub(_binding_0) => BinOp::Sub(Token ! [-](tokens_helper(f, &_binding_0.spans))), - BinOp::Mul(_binding_0) => BinOp::Mul(Token ! [*](tokens_helper(f, &_binding_0.spans))), - BinOp::Div(_binding_0) => BinOp::Div(Token ! [/](tokens_helper(f, &_binding_0.spans))), - BinOp::Rem(_binding_0) => BinOp::Rem(Token ! [%](tokens_helper(f, &_binding_0.spans))), - BinOp::And(_binding_0) => BinOp::And(Token ! [&&](tokens_helper(f, &_binding_0.spans))), - BinOp::Or(_binding_0) => BinOp::Or(Token ! [||](tokens_helper(f, &_binding_0.spans))), + BinOp::Add(_binding_0) => { + BinOp::Add(Token![+](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Sub(_binding_0) => { + BinOp::Sub(Token![-](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Mul(_binding_0) => { + BinOp::Mul(Token![*](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Div(_binding_0) => { + BinOp::Div(Token![/](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Rem(_binding_0) => { + BinOp::Rem(Token![%](tokens_helper(f, &_binding_0.spans))) + } + BinOp::And(_binding_0) => { + BinOp::And(Token![&&](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Or(_binding_0) => { + BinOp::Or(Token![||](tokens_helper(f, &_binding_0.spans))) + } BinOp::BitXor(_binding_0) => { - BinOp::BitXor(Token ! [^](tokens_helper(f, &_binding_0.spans))) + BinOp::BitXor(Token![^](tokens_helper(f, &_binding_0.spans))) } BinOp::BitAnd(_binding_0) => { - BinOp::BitAnd(Token ! [&](tokens_helper(f, &_binding_0.spans))) + BinOp::BitAnd(Token![&](tokens_helper(f, &_binding_0.spans))) + } + BinOp::BitOr(_binding_0) => { + BinOp::BitOr(Token![|](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Shl(_binding_0) => { + BinOp::Shl(Token![<<](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Shr(_binding_0) => { + BinOp::Shr(Token![>>](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Eq(_binding_0) => { + BinOp::Eq(Token![==](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Lt(_binding_0) => { + BinOp::Lt(Token![<](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Le(_binding_0) => { + BinOp::Le(Token![<=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Ne(_binding_0) => { + BinOp::Ne(Token![!=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Ge(_binding_0) => { + BinOp::Ge(Token![>=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::Gt(_binding_0) => { + BinOp::Gt(Token![>](tokens_helper(f, &_binding_0.spans))) + } + BinOp::AddEq(_binding_0) => { + BinOp::AddEq(Token![+=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::SubEq(_binding_0) => { + BinOp::SubEq(Token![-=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::MulEq(_binding_0) => { + BinOp::MulEq(Token![*=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::DivEq(_binding_0) => { + BinOp::DivEq(Token![/=](tokens_helper(f, &_binding_0.spans))) + } + BinOp::RemEq(_binding_0) => { + BinOp::RemEq(Token![%=](tokens_helper(f, &_binding_0.spans))) } - BinOp::BitOr(_binding_0) => BinOp::BitOr(Token ! [|](tokens_helper(f, &_binding_0.spans))), - BinOp::Shl(_binding_0) => BinOp::Shl(Token ! [<<](tokens_helper(f, &_binding_0.spans))), - BinOp::Shr(_binding_0) => BinOp::Shr(Token ! [>>](tokens_helper(f, &_binding_0.spans))), - BinOp::Eq(_binding_0) => BinOp::Eq(Token ! [==](tokens_helper(f, &_binding_0.spans))), - BinOp::Lt(_binding_0) => BinOp::Lt(Token ! [<](tokens_helper(f, &_binding_0.spans))), - BinOp::Le(_binding_0) => BinOp::Le(Token ! [<=](tokens_helper(f, &_binding_0.spans))), - BinOp::Ne(_binding_0) => BinOp::Ne(Token ! [!=](tokens_helper(f, &_binding_0.spans))), - BinOp::Ge(_binding_0) => BinOp::Ge(Token ! [>=](tokens_helper(f, &_binding_0.spans))), - BinOp::Gt(_binding_0) => BinOp::Gt(Token ! [>](tokens_helper(f, &_binding_0.spans))), - BinOp::AddEq(_binding_0) => BinOp::AddEq(Token ! [+=](tokens_helper(f, &_binding_0.spans))), - BinOp::SubEq(_binding_0) => BinOp::SubEq(Token ! [-=](tokens_helper(f, &_binding_0.spans))), - BinOp::MulEq(_binding_0) => BinOp::MulEq(Token ! [*=](tokens_helper(f, &_binding_0.spans))), - BinOp::DivEq(_binding_0) => BinOp::DivEq(Token ! [/=](tokens_helper(f, &_binding_0.spans))), - BinOp::RemEq(_binding_0) => BinOp::RemEq(Token ! [%=](tokens_helper(f, &_binding_0.spans))), BinOp::BitXorEq(_binding_0) => { - BinOp::BitXorEq(Token ! [^=](tokens_helper(f, &_binding_0.spans))) + BinOp::BitXorEq(Token![^=](tokens_helper(f, &_binding_0.spans))) } BinOp::BitAndEq(_binding_0) => { - BinOp::BitAndEq(Token ! [&=](tokens_helper(f, &_binding_0.spans))) + BinOp::BitAndEq(Token![&=](tokens_helper(f, &_binding_0.spans))) } BinOp::BitOrEq(_binding_0) => { - BinOp::BitOrEq(Token ! [|=](tokens_helper(f, &_binding_0.spans))) + BinOp::BitOrEq(Token![|=](tokens_helper(f, &_binding_0.spans))) } BinOp::ShlEq(_binding_0) => { - BinOp::ShlEq(Token ! [<<=](tokens_helper(f, &_binding_0.spans))) + BinOp::ShlEq(Token![<<=](tokens_helper(f, &_binding_0.spans))) } BinOp::ShrEq(_binding_0) => { - BinOp::ShrEq(Token ! [>>=](tokens_helper(f, &_binding_0.spans))) + BinOp::ShrEq(Token![>>=](tokens_helper(f, &_binding_0.spans))) } } } @@ -915,7 +962,7 @@ { Binding { ident: f.fold_ident(node.ident), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), ty: f.fold_type(node.ty), } } @@ -936,9 +983,9 @@ { BoundLifetimes { for_token: Token![for](tokens_helper(f, &node.for_token.span)), - lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), + lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), lifetimes: FoldHelper::lift(node.lifetimes, |it| f.fold_lifetime_def(it)), - gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), + gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -950,9 +997,9 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), const_token: Token![const](tokens_helper(f, &node.const_token.span)), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: f.fold_type(node.ty), - eq_token: (node.eq_token).map(|it| Token ! [=](tokens_helper(f, &it.spans))), + eq_token: (node.eq_token).map(|it| Token![=](tokens_helper(f, &it.spans))), default: (node.default).map(|it| f.fold_expr(it)), } } @@ -963,7 +1010,7 @@ { Constraint { ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), } } @@ -997,7 +1044,7 @@ DataStruct { struct_token: Token![struct](tokens_helper(f, &node.struct_token.span)), fields: f.fold_fields(node.fields), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "derive")] @@ -1031,7 +1078,9 @@ match node { Expr::Array(_binding_0) => Expr::Array(full!(f.fold_expr_array(_binding_0))), Expr::Assign(_binding_0) => Expr::Assign(full!(f.fold_expr_assign(_binding_0))), - Expr::AssignOp(_binding_0) => Expr::AssignOp(full!(f.fold_expr_assign_op(_binding_0))), + Expr::AssignOp(_binding_0) => { + Expr::AssignOp(full!(f.fold_expr_assign_op(_binding_0))) + } Expr::Async(_binding_0) => Expr::Async(full!(f.fold_expr_async(_binding_0))), Expr::Await(_binding_0) => Expr::Await(full!(f.fold_expr_await(_binding_0))), Expr::Binary(_binding_0) => Expr::Binary(f.fold_expr_binary(_binding_0)), @@ -1040,10 +1089,16 @@ Expr::Break(_binding_0) => Expr::Break(full!(f.fold_expr_break(_binding_0))), Expr::Call(_binding_0) => Expr::Call(f.fold_expr_call(_binding_0)), Expr::Cast(_binding_0) => Expr::Cast(f.fold_expr_cast(_binding_0)), - Expr::Closure(_binding_0) => Expr::Closure(full!(f.fold_expr_closure(_binding_0))), - Expr::Continue(_binding_0) => Expr::Continue(full!(f.fold_expr_continue(_binding_0))), + Expr::Closure(_binding_0) => { + Expr::Closure(full!(f.fold_expr_closure(_binding_0))) + } + Expr::Continue(_binding_0) => { + Expr::Continue(full!(f.fold_expr_continue(_binding_0))) + } Expr::Field(_binding_0) => Expr::Field(f.fold_expr_field(_binding_0)), - Expr::ForLoop(_binding_0) => Expr::ForLoop(full!(f.fold_expr_for_loop(_binding_0))), + Expr::ForLoop(_binding_0) => { + Expr::ForLoop(full!(f.fold_expr_for_loop(_binding_0))) + } Expr::Group(_binding_0) => Expr::Group(full!(f.fold_expr_group(_binding_0))), Expr::If(_binding_0) => Expr::If(full!(f.fold_expr_if(_binding_0))), Expr::Index(_binding_0) => Expr::Index(f.fold_expr_index(_binding_0)), @@ -1058,12 +1113,16 @@ Expr::Paren(_binding_0) => Expr::Paren(f.fold_expr_paren(_binding_0)), Expr::Path(_binding_0) => Expr::Path(f.fold_expr_path(_binding_0)), Expr::Range(_binding_0) => Expr::Range(full!(f.fold_expr_range(_binding_0))), - Expr::Reference(_binding_0) => Expr::Reference(full!(f.fold_expr_reference(_binding_0))), + Expr::Reference(_binding_0) => { + Expr::Reference(full!(f.fold_expr_reference(_binding_0))) + } Expr::Repeat(_binding_0) => Expr::Repeat(full!(f.fold_expr_repeat(_binding_0))), Expr::Return(_binding_0) => Expr::Return(full!(f.fold_expr_return(_binding_0))), Expr::Struct(_binding_0) => Expr::Struct(full!(f.fold_expr_struct(_binding_0))), Expr::Try(_binding_0) => Expr::Try(full!(f.fold_expr_try(_binding_0))), - Expr::TryBlock(_binding_0) => Expr::TryBlock(full!(f.fold_expr_try_block(_binding_0))), + Expr::TryBlock(_binding_0) => { + Expr::TryBlock(full!(f.fold_expr_try_block(_binding_0))) + } Expr::Tuple(_binding_0) => Expr::Tuple(full!(f.fold_expr_tuple(_binding_0))), Expr::Type(_binding_0) => Expr::Type(full!(f.fold_expr_type(_binding_0))), Expr::Unary(_binding_0) => Expr::Unary(f.fold_expr_unary(_binding_0)), @@ -1071,6 +1130,7 @@ Expr::Verbatim(_binding_0) => Expr::Verbatim(_binding_0), Expr::While(_binding_0) => Expr::While(full!(f.fold_expr_while(_binding_0))), Expr::Yield(_binding_0) => Expr::Yield(full!(f.fold_expr_yield(_binding_0))), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1093,7 +1153,7 @@ ExprAssign { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), left: Box::new(f.fold_expr(*node.left)), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), right: Box::new(f.fold_expr(*node.right)), } } @@ -1129,7 +1189,7 @@ ExprAwait { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), base: Box::new(f.fold_expr(*node.base)), - dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)), + dot_token: Token![.](tokens_helper(f, &node.dot_token.spans)), await_token: crate::token::Await(tokens_helper(f, &node.await_token.span)), } } @@ -1210,12 +1270,13 @@ { ExprClosure { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), + movability: (node.movability) + .map(|it| Token![static](tokens_helper(f, &it.span))), asyncness: (node.asyncness).map(|it| Token![async](tokens_helper(f, &it.span))), - movability: (node.movability).map(|it| Token![static](tokens_helper(f, &it.span))), capture: (node.capture).map(|it| Token![move](tokens_helper(f, &it.span))), - or1_token: Token ! [|](tokens_helper(f, &node.or1_token.spans)), + or1_token: Token![|](tokens_helper(f, &node.or1_token.spans)), inputs: FoldHelper::lift(node.inputs, |it| f.fold_pat(it)), - or2_token: Token ! [|](tokens_helper(f, &node.or2_token.spans)), + or2_token: Token![|](tokens_helper(f, &node.or2_token.spans)), output: f.fold_return_type(node.output), body: Box::new(f.fold_expr(*node.body)), } @@ -1239,7 +1300,7 @@ ExprField { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), base: Box::new(f.fold_expr(*node.base)), - dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)), + dot_token: Token![.](tokens_helper(f, &node.dot_token.spans)), member: f.fold_member(node.member), } } @@ -1279,12 +1340,11 @@ if_token: Token![if](tokens_helper(f, &node.if_token.span)), cond: Box::new(f.fold_expr(*node.cond)), then_branch: f.fold_block(node.then_branch), - else_branch: (node.else_branch).map(|it| { - ( + else_branch: (node.else_branch) + .map(|it| ( Token![else](tokens_helper(f, &(it).0.span)), Box::new(f.fold_expr(*(it).1)), - ) - }), + )), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1308,7 +1368,7 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), let_token: Token![let](tokens_helper(f, &node.let_token.span)), pat: f.fold_pat(node.pat), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), expr: Box::new(f.fold_expr(*node.expr)), } } @@ -1365,7 +1425,7 @@ ExprMethodCall { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), receiver: Box::new(f.fold_expr(*node.receiver)), - dot_token: Token ! [.](tokens_helper(f, &node.dot_token.spans)), + dot_token: Token![.](tokens_helper(f, &node.dot_token.spans)), method: f.fold_ident(node.method), turbofish: (node.turbofish).map(|it| f.fold_method_turbofish(it)), paren_token: Paren(tokens_helper(f, &node.paren_token.span)), @@ -1413,7 +1473,7 @@ { ExprReference { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)), + and_token: Token![&](tokens_helper(f, &node.and_token.spans)), raw: node.raw, mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), expr: Box::new(f.fold_expr(*node.expr)), @@ -1428,7 +1488,7 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), expr: Box::new(f.fold_expr(*node.expr)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), len: Box::new(f.fold_expr(*node.len)), } } @@ -1465,7 +1525,7 @@ ExprTry { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), expr: Box::new(f.fold_expr(*node.expr)), - question_token: Token ! [?](tokens_helper(f, &node.question_token.spans)), + question_token: Token![?](tokens_helper(f, &node.question_token.spans)), } } #[cfg(feature = "full")] @@ -1498,7 +1558,7 @@ ExprType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), expr: Box::new(f.fold_expr(*node.expr)), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: Box::new(f.fold_type(*node.ty)), } } @@ -1557,7 +1617,7 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), ident: (node.ident).map(|it| f.fold_ident(it)), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), ty: f.fold_type(node.ty), } } @@ -1569,7 +1629,7 @@ FieldPat { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), member: f.fold_member(node.member), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), pat: Box::new(f.fold_pat(*node.pat)), } } @@ -1581,7 +1641,7 @@ FieldValue { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), member: f.fold_member(node.member), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), expr: f.fold_expr(node.expr), } } @@ -1643,13 +1703,20 @@ F: Fold + ?Sized, { match node { - ForeignItem::Fn(_binding_0) => ForeignItem::Fn(f.fold_foreign_item_fn(_binding_0)), + ForeignItem::Fn(_binding_0) => { + ForeignItem::Fn(f.fold_foreign_item_fn(_binding_0)) + } ForeignItem::Static(_binding_0) => { ForeignItem::Static(f.fold_foreign_item_static(_binding_0)) } - ForeignItem::Type(_binding_0) => ForeignItem::Type(f.fold_foreign_item_type(_binding_0)), - ForeignItem::Macro(_binding_0) => ForeignItem::Macro(f.fold_foreign_item_macro(_binding_0)), + ForeignItem::Type(_binding_0) => { + ForeignItem::Type(f.fold_foreign_item_type(_binding_0)) + } + ForeignItem::Macro(_binding_0) => { + ForeignItem::Macro(f.fold_foreign_item_macro(_binding_0)) + } ForeignItem::Verbatim(_binding_0) => ForeignItem::Verbatim(_binding_0), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1662,7 +1729,7 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), sig: f.fold_signature(node.sig), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -1673,11 +1740,14 @@ ForeignItemMacro { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] -pub fn fold_foreign_item_static(f: &mut F, node: ForeignItemStatic) -> ForeignItemStatic +pub fn fold_foreign_item_static( + f: &mut F, + node: ForeignItemStatic, +) -> ForeignItemStatic where F: Fold + ?Sized, { @@ -1687,9 +1757,9 @@ static_token: Token![static](tokens_helper(f, &node.static_token.span)), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: Box::new(f.fold_type(*node.ty)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -1702,7 +1772,7 @@ vis: f.fold_visibility(node.vis), type_token: Token![type](tokens_helper(f, &node.type_token.span)), ident: f.fold_ident(node.ident), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1714,14 +1784,18 @@ GenericArgument::Lifetime(_binding_0) => { GenericArgument::Lifetime(f.fold_lifetime(_binding_0)) } - GenericArgument::Type(_binding_0) => GenericArgument::Type(f.fold_type(_binding_0)), + GenericArgument::Type(_binding_0) => { + GenericArgument::Type(f.fold_type(_binding_0)) + } GenericArgument::Binding(_binding_0) => { GenericArgument::Binding(f.fold_binding(_binding_0)) } GenericArgument::Constraint(_binding_0) => { GenericArgument::Constraint(f.fold_constraint(_binding_0)) } - GenericArgument::Const(_binding_0) => GenericArgument::Const(f.fold_expr(_binding_0)), + GenericArgument::Const(_binding_0) => { + GenericArgument::Const(f.fold_expr(_binding_0)) + } } } #[cfg(feature = "full")] @@ -1747,11 +1821,15 @@ F: Fold + ?Sized, { match node { - GenericParam::Type(_binding_0) => GenericParam::Type(f.fold_type_param(_binding_0)), + GenericParam::Type(_binding_0) => { + GenericParam::Type(f.fold_type_param(_binding_0)) + } GenericParam::Lifetime(_binding_0) => { GenericParam::Lifetime(f.fold_lifetime_def(_binding_0)) } - GenericParam::Const(_binding_0) => GenericParam::Const(f.fold_const_param(_binding_0)), + GenericParam::Const(_binding_0) => { + GenericParam::Const(f.fold_const_param(_binding_0)) + } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1760,9 +1838,9 @@ F: Fold + ?Sized, { Generics { - lt_token: (node.lt_token).map(|it| Token ! [<](tokens_helper(f, &it.spans))), + lt_token: (node.lt_token).map(|it| Token![<](tokens_helper(f, &it.spans))), params: FoldHelper::lift(node.params, |it| f.fold_generic_param(it)), - gt_token: (node.gt_token).map(|it| Token ! [>](tokens_helper(f, &it.spans))), + gt_token: (node.gt_token).map(|it| Token![>](tokens_helper(f, &it.spans))), where_clause: (node.where_clause).map(|it| f.fold_where_clause(it)), } } @@ -1781,11 +1859,18 @@ F: Fold + ?Sized, { match node { - ImplItem::Const(_binding_0) => ImplItem::Const(f.fold_impl_item_const(_binding_0)), - ImplItem::Method(_binding_0) => ImplItem::Method(f.fold_impl_item_method(_binding_0)), + ImplItem::Const(_binding_0) => { + ImplItem::Const(f.fold_impl_item_const(_binding_0)) + } + ImplItem::Method(_binding_0) => { + ImplItem::Method(f.fold_impl_item_method(_binding_0)) + } ImplItem::Type(_binding_0) => ImplItem::Type(f.fold_impl_item_type(_binding_0)), - ImplItem::Macro(_binding_0) => ImplItem::Macro(f.fold_impl_item_macro(_binding_0)), + ImplItem::Macro(_binding_0) => { + ImplItem::Macro(f.fold_impl_item_macro(_binding_0)) + } ImplItem::Verbatim(_binding_0) => ImplItem::Verbatim(_binding_0), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1797,14 +1882,15 @@ ImplItemConst { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), + defaultness: (node.defaultness) + .map(|it| Token![default](tokens_helper(f, &it.span))), const_token: Token![const](tokens_helper(f, &node.const_token.span)), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: f.fold_type(node.ty), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), expr: f.fold_expr(node.expr), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -1815,7 +1901,7 @@ ImplItemMacro { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -1826,7 +1912,8 @@ ImplItemMethod { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), + defaultness: (node.defaultness) + .map(|it| Token![default](tokens_helper(f, &it.span))), sig: f.fold_signature(node.sig), block: f.fold_block(node.block), } @@ -1839,13 +1926,14 @@ ImplItemType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), + defaultness: (node.defaultness) + .map(|it| Token![default](tokens_helper(f, &it.span))), type_token: Token![type](tokens_helper(f, &node.type_token.span)), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), ty: f.fold_type(node.ty), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1866,9 +1954,13 @@ match node { Item::Const(_binding_0) => Item::Const(f.fold_item_const(_binding_0)), Item::Enum(_binding_0) => Item::Enum(f.fold_item_enum(_binding_0)), - Item::ExternCrate(_binding_0) => Item::ExternCrate(f.fold_item_extern_crate(_binding_0)), + Item::ExternCrate(_binding_0) => { + Item::ExternCrate(f.fold_item_extern_crate(_binding_0)) + } Item::Fn(_binding_0) => Item::Fn(f.fold_item_fn(_binding_0)), - Item::ForeignMod(_binding_0) => Item::ForeignMod(f.fold_item_foreign_mod(_binding_0)), + Item::ForeignMod(_binding_0) => { + Item::ForeignMod(f.fold_item_foreign_mod(_binding_0)) + } Item::Impl(_binding_0) => Item::Impl(f.fold_item_impl(_binding_0)), Item::Macro(_binding_0) => Item::Macro(f.fold_item_macro(_binding_0)), Item::Macro2(_binding_0) => Item::Macro2(f.fold_item_macro2(_binding_0)), @@ -1876,11 +1968,14 @@ Item::Static(_binding_0) => Item::Static(f.fold_item_static(_binding_0)), Item::Struct(_binding_0) => Item::Struct(f.fold_item_struct(_binding_0)), Item::Trait(_binding_0) => Item::Trait(f.fold_item_trait(_binding_0)), - Item::TraitAlias(_binding_0) => Item::TraitAlias(f.fold_item_trait_alias(_binding_0)), + Item::TraitAlias(_binding_0) => { + Item::TraitAlias(f.fold_item_trait_alias(_binding_0)) + } Item::Type(_binding_0) => Item::Type(f.fold_item_type(_binding_0)), Item::Union(_binding_0) => Item::Union(f.fold_item_union(_binding_0)), Item::Use(_binding_0) => Item::Use(f.fold_item_use(_binding_0)), Item::Verbatim(_binding_0) => Item::Verbatim(_binding_0), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1894,11 +1989,11 @@ vis: f.fold_visibility(node.vis), const_token: Token![const](tokens_helper(f, &node.const_token.span)), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: Box::new(f.fold_type(*node.ty)), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), expr: Box::new(f.fold_expr(*node.expr)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -1927,13 +2022,12 @@ extern_token: Token![extern](tokens_helper(f, &node.extern_token.span)), crate_token: Token![crate](tokens_helper(f, &node.crate_token.span)), ident: f.fold_ident(node.ident), - rename: (node.rename).map(|it| { - ( + rename: (node.rename) + .map(|it| ( Token![as](tokens_helper(f, &(it).0.span)), f.fold_ident((it).1), - ) - }), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + )), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -1967,17 +2061,17 @@ { ItemImpl { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - defaultness: (node.defaultness).map(|it| Token![default](tokens_helper(f, &it.span))), + defaultness: (node.defaultness) + .map(|it| Token![default](tokens_helper(f, &it.span))), unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))), impl_token: Token![impl](tokens_helper(f, &node.impl_token.span)), generics: f.fold_generics(node.generics), - trait_: (node.trait_).map(|it| { - ( + trait_: (node.trait_) + .map(|it| ( ((it).0).map(|it| Token![!](tokens_helper(f, &it.spans))), f.fold_path((it).1), Token![for](tokens_helper(f, &(it).2.span)), - ) - }), + )), self_ty: Box::new(f.fold_type(*node.self_ty)), brace_token: Brace(tokens_helper(f, &node.brace_token.span)), items: FoldHelper::lift(node.items, |it| f.fold_impl_item(it)), @@ -1992,7 +2086,7 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), ident: (node.ident).map(|it| f.fold_ident(it)), mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -2018,13 +2112,12 @@ vis: f.fold_visibility(node.vis), mod_token: Token![mod](tokens_helper(f, &node.mod_token.span)), ident: f.fold_ident(node.ident), - content: (node.content).map(|it| { - ( + content: (node.content) + .map(|it| ( Brace(tokens_helper(f, &(it).0.span)), FoldHelper::lift((it).1, |it| f.fold_item(it)), - ) - }), - semi: (node.semi).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + )), + semi: (node.semi).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -2038,11 +2131,11 @@ static_token: Token![static](tokens_helper(f, &node.static_token.span)), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: Box::new(f.fold_type(*node.ty)), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), expr: Box::new(f.fold_expr(*node.expr)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -2057,7 +2150,7 @@ ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), fields: f.fold_fields(node.fields), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -2073,8 +2166,11 @@ trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), - supertraits: FoldHelper::lift(node.supertraits, |it| f.fold_type_param_bound(it)), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), + supertraits: FoldHelper::lift( + node.supertraits, + |it| f.fold_type_param_bound(it), + ), brace_token: Brace(tokens_helper(f, &node.brace_token.span)), items: FoldHelper::lift(node.items, |it| f.fold_trait_item(it)), } @@ -2090,9 +2186,9 @@ trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -2106,9 +2202,9 @@ type_token: Token![type](tokens_helper(f, &node.type_token.span)), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), ty: Box::new(f.fold_type(*node.ty)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -2134,9 +2230,10 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), use_token: Token![use](tokens_helper(f, &node.use_token.span)), - leading_colon: (node.leading_colon).map(|it| Token ! [::](tokens_helper(f, &it.spans))), + leading_colon: (node.leading_colon) + .map(|it| Token![::](tokens_helper(f, &it.spans))), tree: f.fold_use_tree(node.tree), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -2146,7 +2243,7 @@ { Label { name: f.fold_lifetime(node.name), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), } } pub fn fold_lifetime(f: &mut F, node: Lifetime) -> Lifetime @@ -2166,7 +2263,7 @@ LifetimeDef { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), lifetime: f.fold_lifetime(node.lifetime), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)), } } @@ -2257,13 +2354,12 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), let_token: Token![let](tokens_helper(f, &node.let_token.span)), pat: f.fold_pat(node.pat), - init: (node.init).map(|it| { - ( - Token ! [=](tokens_helper(f, &(it).0.spans)), + init: (node.init) + .map(|it| ( + Token![=](tokens_helper(f, &(it).0.spans)), Box::new(f.fold_expr(*(it).1)), - ) - }), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + )), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2313,7 +2409,9 @@ match node { Meta::Path(_binding_0) => Meta::Path(f.fold_path(_binding_0)), Meta::List(_binding_0) => Meta::List(f.fold_meta_list(_binding_0)), - Meta::NameValue(_binding_0) => Meta::NameValue(f.fold_meta_name_value(_binding_0)), + Meta::NameValue(_binding_0) => { + Meta::NameValue(f.fold_meta_name_value(_binding_0)) + } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2334,7 +2432,7 @@ { MetaNameValue { path: f.fold_path(node.path), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), lit: f.fold_lit(node.lit), } } @@ -2344,10 +2442,10 @@ F: Fold + ?Sized, { MethodTurbofish { - colon2_token: Token ! [::](tokens_helper(f, &node.colon2_token.spans)), - lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), + colon2_token: Token![::](tokens_helper(f, &node.colon2_token.spans)), + lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), args: FoldHelper::lift(node.args, |it| f.fold_generic_method_argument(it)), - gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), + gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2392,10 +2490,13 @@ Pat::Slice(_binding_0) => Pat::Slice(f.fold_pat_slice(_binding_0)), Pat::Struct(_binding_0) => Pat::Struct(f.fold_pat_struct(_binding_0)), Pat::Tuple(_binding_0) => Pat::Tuple(f.fold_pat_tuple(_binding_0)), - Pat::TupleStruct(_binding_0) => Pat::TupleStruct(f.fold_pat_tuple_struct(_binding_0)), + Pat::TupleStruct(_binding_0) => { + Pat::TupleStruct(f.fold_pat_tuple_struct(_binding_0)) + } Pat::Type(_binding_0) => Pat::Type(f.fold_pat_type(_binding_0)), Pat::Verbatim(_binding_0) => Pat::Verbatim(_binding_0), Pat::Wild(_binding_0) => Pat::Wild(f.fold_pat_wild(_binding_0)), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2420,12 +2521,11 @@ by_ref: (node.by_ref).map(|it| Token![ref](tokens_helper(f, &it.span))), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), ident: f.fold_ident(node.ident), - subpat: (node.subpat).map(|it| { - ( - Token ! [@](tokens_helper(f, &(it).0.spans)), + subpat: (node.subpat) + .map(|it| ( + Token![@](tokens_helper(f, &(it).0.spans)), Box::new(f.fold_pat(*(it).1)), - ) - }), + )), } } #[cfg(feature = "full")] @@ -2455,7 +2555,8 @@ { PatOr { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - leading_vert: (node.leading_vert).map(|it| Token ! [|](tokens_helper(f, &it.spans))), + leading_vert: (node.leading_vert) + .map(|it| Token![|](tokens_helper(f, &it.spans))), cases: FoldHelper::lift(node.cases, |it| f.fold_pat(it)), } } @@ -2489,7 +2590,7 @@ { PatReference { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)), + and_token: Token![&](tokens_helper(f, &node.and_token.spans)), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), pat: Box::new(f.fold_pat(*node.pat)), } @@ -2558,7 +2659,7 @@ PatType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), pat: Box::new(f.fold_pat(*node.pat)), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: Box::new(f.fold_type(*node.ty)), } } @@ -2578,7 +2679,8 @@ F: Fold + ?Sized, { Path { - leading_colon: (node.leading_colon).map(|it| Token ! [::](tokens_helper(f, &it.spans))), + leading_colon: (node.leading_colon) + .map(|it| Token![::](tokens_helper(f, &it.spans))), segments: FoldHelper::lift(node.segments, |it| f.fold_path_segment(it)), } } @@ -2590,10 +2692,14 @@ match node { PathArguments::None => PathArguments::None, PathArguments::AngleBracketed(_binding_0) => { - PathArguments::AngleBracketed(f.fold_angle_bracketed_generic_arguments(_binding_0)) + PathArguments::AngleBracketed( + f.fold_angle_bracketed_generic_arguments(_binding_0), + ) } PathArguments::Parenthesized(_binding_0) => { - PathArguments::Parenthesized(f.fold_parenthesized_generic_arguments(_binding_0)) + PathArguments::Parenthesized( + f.fold_parenthesized_generic_arguments(_binding_0), + ) } } } @@ -2614,18 +2720,21 @@ { PredicateEq { lhs_ty: f.fold_type(node.lhs_ty), - eq_token: Token ! [=](tokens_helper(f, &node.eq_token.spans)), + eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), rhs_ty: f.fold_type(node.rhs_ty), } } #[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_predicate_lifetime(f: &mut F, node: PredicateLifetime) -> PredicateLifetime +pub fn fold_predicate_lifetime( + f: &mut F, + node: PredicateLifetime, +) -> PredicateLifetime where F: Fold + ?Sized, { PredicateLifetime { lifetime: f.fold_lifetime(node.lifetime), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)), } } @@ -2637,7 +2746,7 @@ PredicateType { lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), bounded_ty: f.fold_type(node.bounded_ty), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), } } @@ -2647,11 +2756,11 @@ F: Fold + ?Sized, { QSelf { - lt_token: Token ! [<](tokens_helper(f, &node.lt_token.spans)), + lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), ty: Box::new(f.fold_type(*node.ty)), position: node.position, as_token: (node.as_token).map(|it| Token![as](tokens_helper(f, &it.span))), - gt_token: Token ! [>](tokens_helper(f, &node.gt_token.spans)), + gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), } } #[cfg(feature = "full")] @@ -2664,7 +2773,7 @@ RangeLimits::HalfOpen(Token![..](tokens_helper(f, &_binding_0.spans))) } RangeLimits::Closed(_binding_0) => { - RangeLimits::Closed(Token ! [..=](tokens_helper(f, &_binding_0.spans))) + RangeLimits::Closed(Token![..=](tokens_helper(f, &_binding_0.spans))) } } } @@ -2675,12 +2784,11 @@ { Receiver { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - reference: (node.reference).map(|it| { - ( - Token ! [&](tokens_helper(f, &(it).0.spans)), + reference: (node.reference) + .map(|it| ( + Token![&](tokens_helper(f, &(it).0.spans)), ((it).1).map(|it| f.fold_lifetime(it)), - ) - }), + )), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), self_token: Token![self](tokens_helper(f, &node.self_token.span)), } @@ -2692,10 +2800,12 @@ { match node { ReturnType::Default => ReturnType::Default, - ReturnType::Type(_binding_0, _binding_1) => ReturnType::Type( - Token ! [->](tokens_helper(f, &_binding_0.spans)), - Box::new(f.fold_type(*_binding_1)), - ), + ReturnType::Type(_binding_0, _binding_1) => { + ReturnType::Type( + Token![->](tokens_helper(f, &_binding_0.spans)), + Box::new(f.fold_type(*_binding_1)), + ) + } } } #[cfg(feature = "full")] @@ -2732,10 +2842,12 @@ Stmt::Local(_binding_0) => Stmt::Local(f.fold_local(_binding_0)), Stmt::Item(_binding_0) => Stmt::Item(f.fold_item(_binding_0)), Stmt::Expr(_binding_0) => Stmt::Expr(f.fold_expr(_binding_0)), - Stmt::Semi(_binding_0, _binding_1) => Stmt::Semi( - f.fold_expr(_binding_0), - Token ! [;](tokens_helper(f, &_binding_1.spans)), - ), + Stmt::Semi(_binding_0, _binding_1) => { + Stmt::Semi( + f.fold_expr(_binding_0), + Token![;](tokens_helper(f, &_binding_1.spans)), + ) + } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2751,14 +2863,17 @@ } } #[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_trait_bound_modifier(f: &mut F, node: TraitBoundModifier) -> TraitBoundModifier +pub fn fold_trait_bound_modifier( + f: &mut F, + node: TraitBoundModifier, +) -> TraitBoundModifier where F: Fold + ?Sized, { match node { TraitBoundModifier::None => TraitBoundModifier::None, TraitBoundModifier::Maybe(_binding_0) => { - TraitBoundModifier::Maybe(Token ! [?](tokens_helper(f, &_binding_0.spans))) + TraitBoundModifier::Maybe(Token![?](tokens_helper(f, &_binding_0.spans))) } } } @@ -2768,11 +2883,20 @@ F: Fold + ?Sized, { match node { - TraitItem::Const(_binding_0) => TraitItem::Const(f.fold_trait_item_const(_binding_0)), - TraitItem::Method(_binding_0) => TraitItem::Method(f.fold_trait_item_method(_binding_0)), - TraitItem::Type(_binding_0) => TraitItem::Type(f.fold_trait_item_type(_binding_0)), - TraitItem::Macro(_binding_0) => TraitItem::Macro(f.fold_trait_item_macro(_binding_0)), + TraitItem::Const(_binding_0) => { + TraitItem::Const(f.fold_trait_item_const(_binding_0)) + } + TraitItem::Method(_binding_0) => { + TraitItem::Method(f.fold_trait_item_method(_binding_0)) + } + TraitItem::Type(_binding_0) => { + TraitItem::Type(f.fold_trait_item_type(_binding_0)) + } + TraitItem::Macro(_binding_0) => { + TraitItem::Macro(f.fold_trait_item_macro(_binding_0)) + } TraitItem::Verbatim(_binding_0) => TraitItem::Verbatim(_binding_0), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2785,15 +2909,11 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), const_token: Token![const](tokens_helper(f, &node.const_token.span)), ident: f.fold_ident(node.ident), - colon_token: Token ! [:](tokens_helper(f, &node.colon_token.spans)), + colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), ty: f.fold_type(node.ty), - default: (node.default).map(|it| { - ( - Token ! [=](tokens_helper(f, &(it).0.spans)), - f.fold_expr((it).1), - ) - }), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + default: (node.default) + .map(|it| (Token![=](tokens_helper(f, &(it).0.spans)), f.fold_expr((it).1))), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(feature = "full")] @@ -2804,7 +2924,7 @@ TraitItemMacro { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -2816,7 +2936,7 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), sig: f.fold_signature(node.sig), default: (node.default).map(|it| f.fold_block(it)), - semi_token: (node.semi_token).map(|it| Token ! [;](tokens_helper(f, &it.spans))), + semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), } } #[cfg(feature = "full")] @@ -2829,15 +2949,11 @@ type_token: Token![type](tokens_helper(f, &node.type_token.span)), ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), - default: (node.default).map(|it| { - ( - Token ! [=](tokens_helper(f, &(it).0.spans)), - f.fold_type((it).1), - ) - }), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + default: (node.default) + .map(|it| (Token![=](tokens_helper(f, &(it).0.spans)), f.fold_type((it).1))), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2849,7 +2965,9 @@ Type::Array(_binding_0) => Type::Array(f.fold_type_array(_binding_0)), Type::BareFn(_binding_0) => Type::BareFn(f.fold_type_bare_fn(_binding_0)), Type::Group(_binding_0) => Type::Group(f.fold_type_group(_binding_0)), - Type::ImplTrait(_binding_0) => Type::ImplTrait(f.fold_type_impl_trait(_binding_0)), + Type::ImplTrait(_binding_0) => { + Type::ImplTrait(f.fold_type_impl_trait(_binding_0)) + } Type::Infer(_binding_0) => Type::Infer(f.fold_type_infer(_binding_0)), Type::Macro(_binding_0) => Type::Macro(f.fold_type_macro(_binding_0)), Type::Never(_binding_0) => Type::Never(f.fold_type_never(_binding_0)), @@ -2858,9 +2976,12 @@ Type::Ptr(_binding_0) => Type::Ptr(f.fold_type_ptr(_binding_0)), Type::Reference(_binding_0) => Type::Reference(f.fold_type_reference(_binding_0)), Type::Slice(_binding_0) => Type::Slice(f.fold_type_slice(_binding_0)), - Type::TraitObject(_binding_0) => Type::TraitObject(f.fold_type_trait_object(_binding_0)), + Type::TraitObject(_binding_0) => { + Type::TraitObject(f.fold_type_trait_object(_binding_0)) + } Type::Tuple(_binding_0) => Type::Tuple(f.fold_type_tuple(_binding_0)), Type::Verbatim(_binding_0) => Type::Verbatim(_binding_0), + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2872,7 +2993,7 @@ TypeArray { bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), elem: Box::new(f.fold_type(*node.elem)), - semi_token: Token ! [;](tokens_helper(f, &node.semi_token.spans)), + semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), len: f.fold_expr(node.len), } } @@ -2947,9 +3068,9 @@ TypeParam { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), ident: f.fold_ident(node.ident), - colon_token: (node.colon_token).map(|it| Token ! [:](tokens_helper(f, &it.spans))), + colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), - eq_token: (node.eq_token).map(|it| Token ! [=](tokens_helper(f, &it.spans))), + eq_token: (node.eq_token).map(|it| Token![=](tokens_helper(f, &it.spans))), default: (node.default).map(|it| f.fold_type(it)), } } @@ -2959,7 +3080,9 @@ F: Fold + ?Sized, { match node { - TypeParamBound::Trait(_binding_0) => TypeParamBound::Trait(f.fold_trait_bound(_binding_0)), + TypeParamBound::Trait(_binding_0) => { + TypeParamBound::Trait(f.fold_trait_bound(_binding_0)) + } TypeParamBound::Lifetime(_binding_0) => { TypeParamBound::Lifetime(f.fold_lifetime(_binding_0)) } @@ -2991,8 +3114,9 @@ F: Fold + ?Sized, { TypePtr { - star_token: Token ! [*](tokens_helper(f, &node.star_token.spans)), - const_token: (node.const_token).map(|it| Token![const](tokens_helper(f, &it.span))), + star_token: Token![*](tokens_helper(f, &node.star_token.spans)), + const_token: (node.const_token) + .map(|it| Token![const](tokens_helper(f, &it.span))), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), elem: Box::new(f.fold_type(*node.elem)), } @@ -3003,7 +3127,7 @@ F: Fold + ?Sized, { TypeReference { - and_token: Token ! [&](tokens_helper(f, &node.and_token.spans)), + and_token: Token![&](tokens_helper(f, &node.and_token.spans)), lifetime: (node.lifetime).map(|it| f.fold_lifetime(it)), mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), elem: Box::new(f.fold_type(*node.elem)), @@ -3045,9 +3169,15 @@ F: Fold + ?Sized, { match node { - UnOp::Deref(_binding_0) => UnOp::Deref(Token ! [*](tokens_helper(f, &_binding_0.spans))), - UnOp::Not(_binding_0) => UnOp::Not(Token![!](tokens_helper(f, &_binding_0.spans))), - UnOp::Neg(_binding_0) => UnOp::Neg(Token ! [-](tokens_helper(f, &_binding_0.spans))), + UnOp::Deref(_binding_0) => { + UnOp::Deref(Token![*](tokens_helper(f, &_binding_0.spans))) + } + UnOp::Not(_binding_0) => { + UnOp::Not(Token![!](tokens_helper(f, &_binding_0.spans))) + } + UnOp::Neg(_binding_0) => { + UnOp::Neg(Token![-](tokens_helper(f, &_binding_0.spans))) + } } } #[cfg(feature = "full")] @@ -3056,7 +3186,7 @@ F: Fold + ?Sized, { UseGlob { - star_token: Token ! [*](tokens_helper(f, &node.star_token.spans)), + star_token: Token![*](tokens_helper(f, &node.star_token.spans)), } } #[cfg(feature = "full")] @@ -3085,7 +3215,7 @@ { UsePath { ident: f.fold_ident(node.ident), - colon2_token: Token ! [::](tokens_helper(f, &node.colon2_token.spans)), + colon2_token: Token![::](tokens_helper(f, &node.colon2_token.spans)), tree: Box::new(f.fold_use_tree(*node.tree)), } } @@ -3120,7 +3250,7 @@ { Variadic { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - dots: Token ! [...](tokens_helper(f, &node.dots.spans)), + dots: Token![...](tokens_helper(f, &node.dots.spans)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3132,12 +3262,8 @@ attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), ident: f.fold_ident(node.ident), fields: f.fold_fields(node.fields), - discriminant: (node.discriminant).map(|it| { - ( - Token ! [=](tokens_helper(f, &(it).0.spans)), - f.fold_expr((it).1), - ) - }), + discriminant: (node.discriminant) + .map(|it| (Token![=](tokens_helper(f, &(it).0.spans)), f.fold_expr((it).1))), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3176,7 +3302,9 @@ F: Fold + ?Sized, { match node { - Visibility::Public(_binding_0) => Visibility::Public(f.fold_vis_public(_binding_0)), + Visibility::Public(_binding_0) => { + Visibility::Public(f.fold_vis_public(_binding_0)) + } Visibility::Crate(_binding_0) => Visibility::Crate(f.fold_vis_crate(_binding_0)), Visibility::Restricted(_binding_0) => { Visibility::Restricted(f.fold_vis_restricted(_binding_0)) @@ -3200,10 +3328,14 @@ F: Fold + ?Sized, { match node { - WherePredicate::Type(_binding_0) => WherePredicate::Type(f.fold_predicate_type(_binding_0)), + WherePredicate::Type(_binding_0) => { + WherePredicate::Type(f.fold_predicate_type(_binding_0)) + } WherePredicate::Lifetime(_binding_0) => { WherePredicate::Lifetime(f.fold_predicate_lifetime(_binding_0)) } - WherePredicate::Eq(_binding_0) => WherePredicate::Eq(f.fold_predicate_eq(_binding_0)), + WherePredicate::Eq(_binding_0) => { + WherePredicate::Eq(f.fold_predicate_eq(_binding_0)) + } } } diff -Nru cargo-0.58.0/vendor/syn/src/gen/hash.rs cargo-0.60.0ubuntu1/vendor/syn/src/gen/hash.rs --- cargo-0.58.0/vendor/syn/src/gen/hash.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/gen/hash.rs 2022-04-20 13:48:09.000000000 +0000 @@ -498,6 +498,7 @@ state.write_u8(39u8); v0.hash(state); } + #[cfg(any(syn_no_non_exhaustive, not(feature = "full")))] _ => unreachable!(), } } @@ -641,8 +642,8 @@ H: Hasher, { self.attrs.hash(state); - self.asyncness.hash(state); self.movability.hash(state); + self.asyncness.hash(state); self.capture.hash(state); self.inputs.hash(state); self.output.hash(state); @@ -1112,6 +1113,7 @@ state.write_u8(4u8); TokenStreamHelper(v0).hash(state); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1280,6 +1282,7 @@ state.write_u8(4u8); TokenStreamHelper(v0).hash(state); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1416,6 +1419,7 @@ state.write_u8(16u8); TokenStreamHelper(v0).hash(state); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1920,6 +1924,7 @@ state.write_u8(15u8); v0.hash(state); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2339,6 +2344,7 @@ state.write_u8(4u8); TokenStreamHelper(v0).hash(state); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2464,6 +2470,7 @@ state.write_u8(14u8); TokenStreamHelper(v0).hash(state); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2520,8 +2527,7 @@ fn hash(&self, _state: &mut H) where H: Hasher, - { - } + {} } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -2539,8 +2545,7 @@ fn hash(&self, _state: &mut H) where H: Hasher, - { - } + {} } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -2678,8 +2683,7 @@ fn hash(&self, _state: &mut H) where H: Hasher, - { - } + {} } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -2783,8 +2787,7 @@ fn hash(&self, _state: &mut H) where H: Hasher, - { - } + {} } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -2792,8 +2795,7 @@ fn hash(&self, _state: &mut H) where H: Hasher, - { - } + {} } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] diff -Nru cargo-0.58.0/vendor/syn/src/gen/visit_mut.rs cargo-0.60.0ubuntu1/vendor/syn/src/gen/visit_mut.rs --- cargo-0.58.0/vendor/syn/src/gen/visit_mut.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/gen/visit_mut.rs 2022-04-20 13:48:09.000000000 +0000 @@ -498,7 +498,10 @@ visit_nested_meta_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_parenthesized_generic_arguments_mut(&mut self, i: &mut ParenthesizedGenericArguments) { + fn visit_parenthesized_generic_arguments_mut( + &mut self, + i: &mut ParenthesizedGenericArguments, + ) { visit_parenthesized_generic_arguments_mut(self, i); } #[cfg(feature = "full")] @@ -781,18 +784,19 @@ tokens_helper(v, &mut node.extern_token.span); if let Some(it) = &mut node.name { v.visit_lit_str_mut(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_angle_bracketed_generic_arguments_mut( v: &mut V, node: &mut AngleBracketedGenericArguments, -) where +) +where V: VisitMut + ?Sized, { if let Some(it) = &mut node.colon2_token { tokens_helper(v, &mut it.spans); - }; + } tokens_helper(v, &mut node.lt_token.spans); for el in Punctuated::pairs_mut(&mut node.args) { let (it, p) = el.into_tuple(); @@ -815,12 +819,12 @@ if let Some(it) = &mut node.guard { tokens_helper(v, &mut (it).0.span); v.visit_expr_mut(&mut *(it).1); - }; + } tokens_helper(v, &mut node.fat_arrow_token.spans); v.visit_expr_mut(&mut *node.body); if let Some(it) = &mut node.comma { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_attr_style_mut(v: &mut V, node: &mut AttrStyle) @@ -856,7 +860,7 @@ if let Some(it) = &mut node.name { v.visit_ident_mut(&mut (it).0); tokens_helper(v, &mut (it).1.spans); - }; + } v.visit_type_mut(&mut node.ty); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1000,10 +1004,10 @@ v.visit_type_mut(&mut node.ty); if let Some(it) = &mut node.eq_token { tokens_helper(v, &mut it.spans); - }; + } if let Some(it) = &mut node.default { v.visit_expr_mut(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_constraint_mut(v: &mut V, node: &mut Constraint) @@ -1061,7 +1065,7 @@ v.visit_fields_mut(&mut node.fields); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "derive")] pub fn visit_data_union_mut(v: &mut V, node: &mut DataUnion) @@ -1210,6 +1214,7 @@ Expr::Yield(_binding_0) => { full!(v.visit_expr_yield_mut(_binding_0)); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1265,7 +1270,7 @@ tokens_helper(v, &mut node.async_token.span); if let Some(it) = &mut node.capture { tokens_helper(v, &mut it.span); - }; + } v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] @@ -1302,7 +1307,7 @@ } if let Some(it) = &mut node.label { v.visit_label_mut(it); - }; + } v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] @@ -1327,10 +1332,10 @@ tokens_helper(v, &mut node.break_token.span); if let Some(it) = &mut node.label { v.visit_lifetime_mut(it); - }; + } if let Some(it) = &mut node.expr { v.visit_expr_mut(&mut **it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_call_mut(v: &mut V, node: &mut ExprCall) @@ -1370,15 +1375,15 @@ for it in &mut node.attrs { v.visit_attribute_mut(it); } - if let Some(it) = &mut node.asyncness { - tokens_helper(v, &mut it.span); - }; if let Some(it) = &mut node.movability { tokens_helper(v, &mut it.span); - }; + } + if let Some(it) = &mut node.asyncness { + tokens_helper(v, &mut it.span); + } if let Some(it) = &mut node.capture { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.or1_token.spans); for el in Punctuated::pairs_mut(&mut node.inputs) { let (it, p) = el.into_tuple(); @@ -1402,7 +1407,7 @@ tokens_helper(v, &mut node.continue_token.span); if let Some(it) = &mut node.label { v.visit_lifetime_mut(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_field_mut(v: &mut V, node: &mut ExprField) @@ -1426,7 +1431,7 @@ } if let Some(it) = &mut node.label { v.visit_label_mut(it); - }; + } tokens_helper(v, &mut node.for_token.span); v.visit_pat_mut(&mut node.pat); tokens_helper(v, &mut node.in_token.span); @@ -1458,7 +1463,7 @@ if let Some(it) = &mut node.else_branch { tokens_helper(v, &mut (it).0.span); v.visit_expr_mut(&mut *(it).1); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_index_mut(v: &mut V, node: &mut ExprIndex) @@ -1505,7 +1510,7 @@ } if let Some(it) = &mut node.label { v.visit_label_mut(it); - }; + } tokens_helper(v, &mut node.loop_token.span); v.visit_block_mut(&mut node.body); } @@ -1547,7 +1552,7 @@ v.visit_ident_mut(&mut node.method); if let Some(it) = &mut node.turbofish { v.visit_method_turbofish_mut(it); - }; + } tokens_helper(v, &mut node.paren_token.span); for el in Punctuated::pairs_mut(&mut node.args) { let (it, p) = el.into_tuple(); @@ -1578,7 +1583,7 @@ } if let Some(it) = &mut node.qself { v.visit_qself_mut(it); - }; + } v.visit_path_mut(&mut node.path); } #[cfg(feature = "full")] @@ -1591,11 +1596,11 @@ } if let Some(it) = &mut node.from { v.visit_expr_mut(&mut **it); - }; + } v.visit_range_limits_mut(&mut node.limits); if let Some(it) = &mut node.to { v.visit_expr_mut(&mut **it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_reference_mut(v: &mut V, node: &mut ExprReference) @@ -1608,7 +1613,7 @@ tokens_helper(v, &mut node.and_token.spans); if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_expr_mut(&mut *node.expr); } #[cfg(feature = "full")] @@ -1635,7 +1640,7 @@ tokens_helper(v, &mut node.return_token.span); if let Some(it) = &mut node.expr { v.visit_expr_mut(&mut **it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_struct_mut(v: &mut V, node: &mut ExprStruct) @@ -1656,10 +1661,10 @@ } if let Some(it) = &mut node.dot2_token { tokens_helper(v, &mut it.spans); - }; + } if let Some(it) = &mut node.rest { v.visit_expr_mut(&mut **it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_try_mut(v: &mut V, node: &mut ExprTry) @@ -1744,7 +1749,7 @@ } if let Some(it) = &mut node.label { v.visit_label_mut(it); - }; + } tokens_helper(v, &mut node.while_token.span); v.visit_expr_mut(&mut *node.cond); v.visit_block_mut(&mut node.body); @@ -1760,7 +1765,7 @@ tokens_helper(v, &mut node.yield_token.span); if let Some(it) = &mut node.expr { v.visit_expr_mut(&mut **it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_field_mut(v: &mut V, node: &mut Field) @@ -1773,10 +1778,10 @@ v.visit_visibility_mut(&mut node.vis); if let Some(it) = &mut node.ident { v.visit_ident_mut(it); - }; + } if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } v.visit_type_mut(&mut node.ty); } #[cfg(feature = "full")] @@ -1790,7 +1795,7 @@ v.visit_member_mut(&mut node.member); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } v.visit_pat_mut(&mut *node.pat); } #[cfg(feature = "full")] @@ -1804,7 +1809,7 @@ v.visit_member_mut(&mut node.member); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } v.visit_expr_mut(&mut node.expr); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1898,6 +1903,7 @@ ForeignItem::Verbatim(_binding_0) => { skip!(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1924,7 +1930,7 @@ v.visit_macro_mut(&mut node.mac); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_foreign_item_static_mut(v: &mut V, node: &mut ForeignItemStatic) @@ -1938,7 +1944,7 @@ tokens_helper(v, &mut node.static_token.span); if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_ident_mut(&mut node.ident); tokens_helper(v, &mut node.colon_token.spans); v.visit_type_mut(&mut *node.ty); @@ -2018,7 +2024,7 @@ { if let Some(it) = &mut node.lt_token { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.params) { let (it, p) = el.into_tuple(); v.visit_generic_param_mut(it); @@ -2028,10 +2034,10 @@ } if let Some(it) = &mut node.gt_token { tokens_helper(v, &mut it.spans); - }; + } if let Some(it) = &mut node.where_clause { v.visit_where_clause_mut(it); - }; + } } pub fn visit_ident_mut(v: &mut V, node: &mut Ident) where @@ -2062,6 +2068,7 @@ ImplItem::Verbatim(_binding_0) => { skip!(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2076,7 +2083,7 @@ v.visit_visibility_mut(&mut node.vis); if let Some(it) = &mut node.defaultness { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.const_token.span); v.visit_ident_mut(&mut node.ident); tokens_helper(v, &mut node.colon_token.spans); @@ -2096,7 +2103,7 @@ v.visit_macro_mut(&mut node.mac); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_impl_item_method_mut(v: &mut V, node: &mut ImplItemMethod) @@ -2109,7 +2116,7 @@ v.visit_visibility_mut(&mut node.vis); if let Some(it) = &mut node.defaultness { tokens_helper(v, &mut it.span); - }; + } v.visit_signature_mut(&mut node.sig); v.visit_block_mut(&mut node.block); } @@ -2124,7 +2131,7 @@ v.visit_visibility_mut(&mut node.vis); if let Some(it) = &mut node.defaultness { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.type_token.span); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); @@ -2197,6 +2204,7 @@ Item::Verbatim(_binding_0) => { skip!(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2253,7 +2261,7 @@ if let Some(it) = &mut node.rename { tokens_helper(v, &mut (it).0.span); v.visit_ident_mut(&mut (it).1); - }; + } tokens_helper(v, &mut node.semi_token.spans); } #[cfg(feature = "full")] @@ -2292,19 +2300,19 @@ } if let Some(it) = &mut node.defaultness { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.unsafety { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.impl_token.span); v.visit_generics_mut(&mut node.generics); if let Some(it) = &mut node.trait_ { if let Some(it) = &mut (it).0 { tokens_helper(v, &mut it.spans); - }; + } v.visit_path_mut(&mut (it).1); tokens_helper(v, &mut (it).2.span); - }; + } v.visit_type_mut(&mut *node.self_ty); tokens_helper(v, &mut node.brace_token.span); for it in &mut node.items { @@ -2321,11 +2329,11 @@ } if let Some(it) = &mut node.ident { v.visit_ident_mut(it); - }; + } v.visit_macro_mut(&mut node.mac); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_macro2_mut(v: &mut V, node: &mut ItemMacro2) @@ -2356,10 +2364,10 @@ for it in &mut (it).1 { v.visit_item_mut(it); } - }; + } if let Some(it) = &mut node.semi { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_static_mut(v: &mut V, node: &mut ItemStatic) @@ -2373,7 +2381,7 @@ tokens_helper(v, &mut node.static_token.span); if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_ident_mut(&mut node.ident); tokens_helper(v, &mut node.colon_token.spans); v.visit_type_mut(&mut *node.ty); @@ -2396,7 +2404,7 @@ v.visit_fields_mut(&mut node.fields); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_trait_mut(v: &mut V, node: &mut ItemTrait) @@ -2409,16 +2417,16 @@ v.visit_visibility_mut(&mut node.vis); if let Some(it) = &mut node.unsafety { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.auto_token { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.trait_token.span); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.supertraits) { let (it, p) = el.into_tuple(); v.visit_type_param_bound_mut(it); @@ -2495,7 +2503,7 @@ tokens_helper(v, &mut node.use_token.span); if let Some(it) = &mut node.leading_colon { tokens_helper(v, &mut it.spans); - }; + } v.visit_use_tree_mut(&mut node.tree); tokens_helper(v, &mut node.semi_token.spans); } @@ -2525,7 +2533,7 @@ v.visit_lifetime_mut(&mut node.lifetime); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.bounds) { let (it, p) = el.into_tuple(); v.visit_lifetime_mut(it); @@ -2575,33 +2583,27 @@ pub fn visit_lit_byte_mut(v: &mut V, node: &mut LitByte) where V: VisitMut + ?Sized, -{ -} +{} pub fn visit_lit_byte_str_mut(v: &mut V, node: &mut LitByteStr) where V: VisitMut + ?Sized, -{ -} +{} pub fn visit_lit_char_mut(v: &mut V, node: &mut LitChar) where V: VisitMut + ?Sized, -{ -} +{} pub fn visit_lit_float_mut(v: &mut V, node: &mut LitFloat) where V: VisitMut + ?Sized, -{ -} +{} pub fn visit_lit_int_mut(v: &mut V, node: &mut LitInt) where V: VisitMut + ?Sized, -{ -} +{} pub fn visit_lit_str_mut(v: &mut V, node: &mut LitStr) where V: VisitMut + ?Sized, -{ -} +{} #[cfg(feature = "full")] pub fn visit_local_mut(v: &mut V, node: &mut Local) where @@ -2615,7 +2617,7 @@ if let Some(it) = &mut node.init { tokens_helper(v, &mut (it).0.spans); v.visit_expr_mut(&mut *(it).1); - }; + } tokens_helper(v, &mut node.semi_token.spans); } #[cfg(any(feature = "derive", feature = "full"))] @@ -2734,7 +2736,8 @@ pub fn visit_parenthesized_generic_arguments_mut( v: &mut V, node: &mut ParenthesizedGenericArguments, -) where +) +where V: VisitMut + ?Sized, { tokens_helper(v, &mut node.paren_token.span); @@ -2801,6 +2804,7 @@ Pat::Wild(_binding_0) => { v.visit_pat_wild_mut(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2825,15 +2829,15 @@ } if let Some(it) = &mut node.by_ref { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_ident_mut(&mut node.ident); if let Some(it) = &mut node.subpat { tokens_helper(v, &mut (it).0.spans); v.visit_pat_mut(&mut *(it).1); - }; + } } #[cfg(feature = "full")] pub fn visit_pat_lit_mut(v: &mut V, node: &mut PatLit) @@ -2865,7 +2869,7 @@ } if let Some(it) = &mut node.leading_vert { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.cases) { let (it, p) = el.into_tuple(); v.visit_pat_mut(it); @@ -2884,7 +2888,7 @@ } if let Some(it) = &mut node.qself { v.visit_qself_mut(it); - }; + } v.visit_path_mut(&mut node.path); } #[cfg(feature = "full")] @@ -2910,7 +2914,7 @@ tokens_helper(v, &mut node.and_token.spans); if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_pat_mut(&mut *node.pat); } #[cfg(feature = "full")] @@ -2959,7 +2963,7 @@ } if let Some(it) = &mut node.dot2_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_pat_tuple_mut(v: &mut V, node: &mut PatTuple) @@ -3018,7 +3022,7 @@ { if let Some(it) = &mut node.leading_colon { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.segments) { let (it, p) = el.into_tuple(); v.visit_path_segment_mut(it); @@ -3081,7 +3085,7 @@ { if let Some(it) = &mut node.lifetimes { v.visit_bound_lifetimes_mut(it); - }; + } v.visit_type_mut(&mut node.bounded_ty); tokens_helper(v, &mut node.colon_token.spans); for el in Punctuated::pairs_mut(&mut node.bounds) { @@ -3102,7 +3106,7 @@ skip!(node.position); if let Some(it) = &mut node.as_token { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.gt_token.spans); } #[cfg(feature = "full")] @@ -3131,11 +3135,11 @@ tokens_helper(v, &mut (it).0.spans); if let Some(it) = &mut (it).1 { v.visit_lifetime_mut(it); - }; - }; + } + } if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } tokens_helper(v, &mut node.self_token.span); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3158,16 +3162,16 @@ { if let Some(it) = &mut node.constness { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.asyncness { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.unsafety { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.abi { v.visit_abi_mut(it); - }; + } tokens_helper(v, &mut node.fn_token.span); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); @@ -3181,14 +3185,13 @@ } if let Some(it) = &mut node.variadic { v.visit_variadic_mut(it); - }; + } v.visit_return_type_mut(&mut node.output); } pub fn visit_span_mut(v: &mut V, node: &mut Span) where V: VisitMut + ?Sized, -{ -} +{} #[cfg(feature = "full")] pub fn visit_stmt_mut(v: &mut V, node: &mut Stmt) where @@ -3217,11 +3220,11 @@ { if let Some(it) = &mut node.paren_token { tokens_helper(v, &mut it.span); - }; + } v.visit_trait_bound_modifier_mut(&mut node.modifier); if let Some(it) = &mut node.lifetimes { v.visit_bound_lifetimes_mut(it); - }; + } v.visit_path_mut(&mut node.path); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3257,6 +3260,7 @@ TraitItem::Verbatim(_binding_0) => { skip!(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -3275,7 +3279,7 @@ if let Some(it) = &mut node.default { tokens_helper(v, &mut (it).0.spans); v.visit_expr_mut(&mut (it).1); - }; + } tokens_helper(v, &mut node.semi_token.spans); } #[cfg(feature = "full")] @@ -3289,7 +3293,7 @@ v.visit_macro_mut(&mut node.mac); if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_trait_item_method_mut(v: &mut V, node: &mut TraitItemMethod) @@ -3302,10 +3306,10 @@ v.visit_signature_mut(&mut node.sig); if let Some(it) = &mut node.default { v.visit_block_mut(it); - }; + } if let Some(it) = &mut node.semi_token { tokens_helper(v, &mut it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_trait_item_type_mut(v: &mut V, node: &mut TraitItemType) @@ -3320,7 +3324,7 @@ v.visit_generics_mut(&mut node.generics); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound_mut(it); @@ -3331,7 +3335,7 @@ if let Some(it) = &mut node.default { tokens_helper(v, &mut (it).0.spans); v.visit_type_mut(&mut (it).1); - }; + } tokens_helper(v, &mut node.semi_token.spans); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3385,6 +3389,7 @@ Type::Verbatim(_binding_0) => { skip!(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -3405,13 +3410,13 @@ { if let Some(it) = &mut node.lifetimes { v.visit_bound_lifetimes_mut(it); - }; + } if let Some(it) = &mut node.unsafety { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.abi { v.visit_abi_mut(it); - }; + } tokens_helper(v, &mut node.fn_token.span); tokens_helper(v, &mut node.paren_token.span); for el in Punctuated::pairs_mut(&mut node.inputs) { @@ -3423,7 +3428,7 @@ } if let Some(it) = &mut node.variadic { v.visit_variadic_mut(it); - }; + } v.visit_return_type_mut(&mut node.output); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3480,7 +3485,7 @@ v.visit_ident_mut(&mut node.ident); if let Some(it) = &mut node.colon_token { tokens_helper(v, &mut it.spans); - }; + } for el in Punctuated::pairs_mut(&mut node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound_mut(it); @@ -3490,10 +3495,10 @@ } if let Some(it) = &mut node.eq_token { tokens_helper(v, &mut it.spans); - }; + } if let Some(it) = &mut node.default { v.visit_type_mut(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_type_param_bound_mut(v: &mut V, node: &mut TypeParamBound) @@ -3524,7 +3529,7 @@ { if let Some(it) = &mut node.qself { v.visit_qself_mut(it); - }; + } v.visit_path_mut(&mut node.path); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3535,10 +3540,10 @@ tokens_helper(v, &mut node.star_token.spans); if let Some(it) = &mut node.const_token { tokens_helper(v, &mut it.span); - }; + } if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3549,10 +3554,10 @@ tokens_helper(v, &mut node.and_token.spans); if let Some(it) = &mut node.lifetime { v.visit_lifetime_mut(it); - }; + } if let Some(it) = &mut node.mutability { tokens_helper(v, &mut it.span); - }; + } v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3570,7 +3575,7 @@ { if let Some(it) = &mut node.dyn_token { tokens_helper(v, &mut it.span); - }; + } for el in Punctuated::pairs_mut(&mut node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound_mut(it); @@ -3702,7 +3707,7 @@ if let Some(it) = &mut node.discriminant { tokens_helper(v, &mut (it).0.spans); v.visit_expr_mut(&mut (it).1); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_vis_crate_mut(v: &mut V, node: &mut VisCrate) @@ -3727,7 +3732,7 @@ tokens_helper(v, &mut node.paren_token.span); if let Some(it) = &mut node.in_token { tokens_helper(v, &mut it.span); - }; + } v.visit_path_mut(&mut *node.path); } #[cfg(any(feature = "derive", feature = "full"))] diff -Nru cargo-0.58.0/vendor/syn/src/gen/visit.rs cargo-0.60.0ubuntu1/vendor/syn/src/gen/visit.rs --- cargo-0.58.0/vendor/syn/src/gen/visit.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/gen/visit.rs 2022-04-20 13:48:09.000000000 +0000 @@ -36,7 +36,10 @@ visit_abi(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_angle_bracketed_generic_arguments(&mut self, i: &'ast AngleBracketedGenericArguments) { + fn visit_angle_bracketed_generic_arguments( + &mut self, + i: &'ast AngleBracketedGenericArguments, + ) { visit_angle_bracketed_generic_arguments(self, i); } #[cfg(feature = "full")] @@ -494,7 +497,10 @@ visit_nested_meta(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_parenthesized_generic_arguments(&mut self, i: &'ast ParenthesizedGenericArguments) { + fn visit_parenthesized_generic_arguments( + &mut self, + i: &'ast ParenthesizedGenericArguments, + ) { visit_parenthesized_generic_arguments(self, i); } #[cfg(feature = "full")] @@ -777,18 +783,19 @@ tokens_helper(v, &node.extern_token.span); if let Some(it) = &node.name { v.visit_lit_str(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_angle_bracketed_generic_arguments<'ast, V>( v: &mut V, node: &'ast AngleBracketedGenericArguments, -) where +) +where V: Visit<'ast> + ?Sized, { if let Some(it) = &node.colon2_token { tokens_helper(v, &it.spans); - }; + } tokens_helper(v, &node.lt_token.spans); for el in Punctuated::pairs(&node.args) { let (it, p) = el.into_tuple(); @@ -811,12 +818,12 @@ if let Some(it) = &node.guard { tokens_helper(v, &(it).0.span); v.visit_expr(&*(it).1); - }; + } tokens_helper(v, &node.fat_arrow_token.spans); v.visit_expr(&*node.body); if let Some(it) = &node.comma { tokens_helper(v, &it.spans); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_attr_style<'ast, V>(v: &mut V, node: &'ast AttrStyle) @@ -852,7 +859,7 @@ if let Some(it) = &node.name { v.visit_ident(&(it).0); tokens_helper(v, &(it).1.spans); - }; + } v.visit_type(&node.ty); } #[cfg(any(feature = "derive", feature = "full"))] @@ -996,10 +1003,10 @@ v.visit_type(&node.ty); if let Some(it) = &node.eq_token { tokens_helper(v, &it.spans); - }; + } if let Some(it) = &node.default { v.visit_expr(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_constraint<'ast, V>(v: &mut V, node: &'ast Constraint) @@ -1057,7 +1064,7 @@ v.visit_fields(&node.fields); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "derive")] pub fn visit_data_union<'ast, V>(v: &mut V, node: &'ast DataUnion) @@ -1206,6 +1213,7 @@ Expr::Yield(_binding_0) => { full!(v.visit_expr_yield(_binding_0)); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1261,7 +1269,7 @@ tokens_helper(v, &node.async_token.span); if let Some(it) = &node.capture { tokens_helper(v, &it.span); - }; + } v.visit_block(&node.block); } #[cfg(feature = "full")] @@ -1298,7 +1306,7 @@ } if let Some(it) = &node.label { v.visit_label(it); - }; + } v.visit_block(&node.block); } #[cfg(feature = "full")] @@ -1323,10 +1331,10 @@ tokens_helper(v, &node.break_token.span); if let Some(it) = &node.label { v.visit_lifetime(it); - }; + } if let Some(it) = &node.expr { v.visit_expr(&**it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_call<'ast, V>(v: &mut V, node: &'ast ExprCall) @@ -1366,15 +1374,15 @@ for it in &node.attrs { v.visit_attribute(it); } - if let Some(it) = &node.asyncness { - tokens_helper(v, &it.span); - }; if let Some(it) = &node.movability { tokens_helper(v, &it.span); - }; + } + if let Some(it) = &node.asyncness { + tokens_helper(v, &it.span); + } if let Some(it) = &node.capture { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.or1_token.spans); for el in Punctuated::pairs(&node.inputs) { let (it, p) = el.into_tuple(); @@ -1398,7 +1406,7 @@ tokens_helper(v, &node.continue_token.span); if let Some(it) = &node.label { v.visit_lifetime(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_field<'ast, V>(v: &mut V, node: &'ast ExprField) @@ -1422,7 +1430,7 @@ } if let Some(it) = &node.label { v.visit_label(it); - }; + } tokens_helper(v, &node.for_token.span); v.visit_pat(&node.pat); tokens_helper(v, &node.in_token.span); @@ -1454,7 +1462,7 @@ if let Some(it) = &node.else_branch { tokens_helper(v, &(it).0.span); v.visit_expr(&*(it).1); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_index<'ast, V>(v: &mut V, node: &'ast ExprIndex) @@ -1501,7 +1509,7 @@ } if let Some(it) = &node.label { v.visit_label(it); - }; + } tokens_helper(v, &node.loop_token.span); v.visit_block(&node.body); } @@ -1543,7 +1551,7 @@ v.visit_ident(&node.method); if let Some(it) = &node.turbofish { v.visit_method_turbofish(it); - }; + } tokens_helper(v, &node.paren_token.span); for el in Punctuated::pairs(&node.args) { let (it, p) = el.into_tuple(); @@ -1574,7 +1582,7 @@ } if let Some(it) = &node.qself { v.visit_qself(it); - }; + } v.visit_path(&node.path); } #[cfg(feature = "full")] @@ -1587,11 +1595,11 @@ } if let Some(it) = &node.from { v.visit_expr(&**it); - }; + } v.visit_range_limits(&node.limits); if let Some(it) = &node.to { v.visit_expr(&**it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_reference<'ast, V>(v: &mut V, node: &'ast ExprReference) @@ -1604,7 +1612,7 @@ tokens_helper(v, &node.and_token.spans); if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_expr(&*node.expr); } #[cfg(feature = "full")] @@ -1631,7 +1639,7 @@ tokens_helper(v, &node.return_token.span); if let Some(it) = &node.expr { v.visit_expr(&**it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_struct<'ast, V>(v: &mut V, node: &'ast ExprStruct) @@ -1652,10 +1660,10 @@ } if let Some(it) = &node.dot2_token { tokens_helper(v, &it.spans); - }; + } if let Some(it) = &node.rest { v.visit_expr(&**it); - }; + } } #[cfg(feature = "full")] pub fn visit_expr_try<'ast, V>(v: &mut V, node: &'ast ExprTry) @@ -1740,7 +1748,7 @@ } if let Some(it) = &node.label { v.visit_label(it); - }; + } tokens_helper(v, &node.while_token.span); v.visit_expr(&*node.cond); v.visit_block(&node.body); @@ -1756,7 +1764,7 @@ tokens_helper(v, &node.yield_token.span); if let Some(it) = &node.expr { v.visit_expr(&**it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_field<'ast, V>(v: &mut V, node: &'ast Field) @@ -1769,10 +1777,10 @@ v.visit_visibility(&node.vis); if let Some(it) = &node.ident { v.visit_ident(it); - }; + } if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } v.visit_type(&node.ty); } #[cfg(feature = "full")] @@ -1786,7 +1794,7 @@ v.visit_member(&node.member); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } v.visit_pat(&*node.pat); } #[cfg(feature = "full")] @@ -1800,7 +1808,7 @@ v.visit_member(&node.member); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } v.visit_expr(&node.expr); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1894,6 +1902,7 @@ ForeignItem::Verbatim(_binding_0) => { skip!(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -1920,7 +1929,7 @@ v.visit_macro(&node.mac); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_foreign_item_static<'ast, V>(v: &mut V, node: &'ast ForeignItemStatic) @@ -1934,7 +1943,7 @@ tokens_helper(v, &node.static_token.span); if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_ident(&node.ident); tokens_helper(v, &node.colon_token.spans); v.visit_type(&*node.ty); @@ -1977,7 +1986,10 @@ } } #[cfg(feature = "full")] -pub fn visit_generic_method_argument<'ast, V>(v: &mut V, node: &'ast GenericMethodArgument) +pub fn visit_generic_method_argument<'ast, V>( + v: &mut V, + node: &'ast GenericMethodArgument, +) where V: Visit<'ast> + ?Sized, { @@ -2014,7 +2026,7 @@ { if let Some(it) = &node.lt_token { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.params) { let (it, p) = el.into_tuple(); v.visit_generic_param(it); @@ -2024,10 +2036,10 @@ } if let Some(it) = &node.gt_token { tokens_helper(v, &it.spans); - }; + } if let Some(it) = &node.where_clause { v.visit_where_clause(it); - }; + } } pub fn visit_ident<'ast, V>(v: &mut V, node: &'ast Ident) where @@ -2056,6 +2068,7 @@ ImplItem::Verbatim(_binding_0) => { skip!(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2070,7 +2083,7 @@ v.visit_visibility(&node.vis); if let Some(it) = &node.defaultness { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.const_token.span); v.visit_ident(&node.ident); tokens_helper(v, &node.colon_token.spans); @@ -2090,7 +2103,7 @@ v.visit_macro(&node.mac); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_impl_item_method<'ast, V>(v: &mut V, node: &'ast ImplItemMethod) @@ -2103,7 +2116,7 @@ v.visit_visibility(&node.vis); if let Some(it) = &node.defaultness { tokens_helper(v, &it.span); - }; + } v.visit_signature(&node.sig); v.visit_block(&node.block); } @@ -2118,7 +2131,7 @@ v.visit_visibility(&node.vis); if let Some(it) = &node.defaultness { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.type_token.span); v.visit_ident(&node.ident); v.visit_generics(&node.generics); @@ -2191,6 +2204,7 @@ Item::Verbatim(_binding_0) => { skip!(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2247,7 +2261,7 @@ if let Some(it) = &node.rename { tokens_helper(v, &(it).0.span); v.visit_ident(&(it).1); - }; + } tokens_helper(v, &node.semi_token.spans); } #[cfg(feature = "full")] @@ -2286,19 +2300,19 @@ } if let Some(it) = &node.defaultness { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.unsafety { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.impl_token.span); v.visit_generics(&node.generics); if let Some(it) = &node.trait_ { if let Some(it) = &(it).0 { tokens_helper(v, &it.spans); - }; + } v.visit_path(&(it).1); tokens_helper(v, &(it).2.span); - }; + } v.visit_type(&*node.self_ty); tokens_helper(v, &node.brace_token.span); for it in &node.items { @@ -2315,11 +2329,11 @@ } if let Some(it) = &node.ident { v.visit_ident(it); - }; + } v.visit_macro(&node.mac); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_macro2<'ast, V>(v: &mut V, node: &'ast ItemMacro2) @@ -2350,10 +2364,10 @@ for it in &(it).1 { v.visit_item(it); } - }; + } if let Some(it) = &node.semi { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_static<'ast, V>(v: &mut V, node: &'ast ItemStatic) @@ -2367,7 +2381,7 @@ tokens_helper(v, &node.static_token.span); if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_ident(&node.ident); tokens_helper(v, &node.colon_token.spans); v.visit_type(&*node.ty); @@ -2390,7 +2404,7 @@ v.visit_fields(&node.fields); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_item_trait<'ast, V>(v: &mut V, node: &'ast ItemTrait) @@ -2403,16 +2417,16 @@ v.visit_visibility(&node.vis); if let Some(it) = &node.unsafety { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.auto_token { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.trait_token.span); v.visit_ident(&node.ident); v.visit_generics(&node.generics); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.supertraits) { let (it, p) = el.into_tuple(); v.visit_type_param_bound(it); @@ -2489,7 +2503,7 @@ tokens_helper(v, &node.use_token.span); if let Some(it) = &node.leading_colon { tokens_helper(v, &it.spans); - }; + } v.visit_use_tree(&node.tree); tokens_helper(v, &node.semi_token.spans); } @@ -2519,7 +2533,7 @@ v.visit_lifetime(&node.lifetime); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.bounds) { let (it, p) = el.into_tuple(); v.visit_lifetime(it); @@ -2569,33 +2583,27 @@ pub fn visit_lit_byte<'ast, V>(v: &mut V, node: &'ast LitByte) where V: Visit<'ast> + ?Sized, -{ -} +{} pub fn visit_lit_byte_str<'ast, V>(v: &mut V, node: &'ast LitByteStr) where V: Visit<'ast> + ?Sized, -{ -} +{} pub fn visit_lit_char<'ast, V>(v: &mut V, node: &'ast LitChar) where V: Visit<'ast> + ?Sized, -{ -} +{} pub fn visit_lit_float<'ast, V>(v: &mut V, node: &'ast LitFloat) where V: Visit<'ast> + ?Sized, -{ -} +{} pub fn visit_lit_int<'ast, V>(v: &mut V, node: &'ast LitInt) where V: Visit<'ast> + ?Sized, -{ -} +{} pub fn visit_lit_str<'ast, V>(v: &mut V, node: &'ast LitStr) where V: Visit<'ast> + ?Sized, -{ -} +{} #[cfg(feature = "full")] pub fn visit_local<'ast, V>(v: &mut V, node: &'ast Local) where @@ -2609,7 +2617,7 @@ if let Some(it) = &node.init { tokens_helper(v, &(it).0.spans); v.visit_expr(&*(it).1); - }; + } tokens_helper(v, &node.semi_token.spans); } #[cfg(any(feature = "derive", feature = "full"))] @@ -2728,7 +2736,8 @@ pub fn visit_parenthesized_generic_arguments<'ast, V>( v: &mut V, node: &'ast ParenthesizedGenericArguments, -) where +) +where V: Visit<'ast> + ?Sized, { tokens_helper(v, &node.paren_token.span); @@ -2795,6 +2804,7 @@ Pat::Wild(_binding_0) => { v.visit_pat_wild(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -2819,15 +2829,15 @@ } if let Some(it) = &node.by_ref { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_ident(&node.ident); if let Some(it) = &node.subpat { tokens_helper(v, &(it).0.spans); v.visit_pat(&*(it).1); - }; + } } #[cfg(feature = "full")] pub fn visit_pat_lit<'ast, V>(v: &mut V, node: &'ast PatLit) @@ -2859,7 +2869,7 @@ } if let Some(it) = &node.leading_vert { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.cases) { let (it, p) = el.into_tuple(); v.visit_pat(it); @@ -2878,7 +2888,7 @@ } if let Some(it) = &node.qself { v.visit_qself(it); - }; + } v.visit_path(&node.path); } #[cfg(feature = "full")] @@ -2904,7 +2914,7 @@ tokens_helper(v, &node.and_token.spans); if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_pat(&*node.pat); } #[cfg(feature = "full")] @@ -2953,7 +2963,7 @@ } if let Some(it) = &node.dot2_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_pat_tuple<'ast, V>(v: &mut V, node: &'ast PatTuple) @@ -3012,7 +3022,7 @@ { if let Some(it) = &node.leading_colon { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.segments) { let (it, p) = el.into_tuple(); v.visit_path_segment(it); @@ -3075,7 +3085,7 @@ { if let Some(it) = &node.lifetimes { v.visit_bound_lifetimes(it); - }; + } v.visit_type(&node.bounded_ty); tokens_helper(v, &node.colon_token.spans); for el in Punctuated::pairs(&node.bounds) { @@ -3096,7 +3106,7 @@ skip!(node.position); if let Some(it) = &node.as_token { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.gt_token.spans); } #[cfg(feature = "full")] @@ -3125,11 +3135,11 @@ tokens_helper(v, &(it).0.spans); if let Some(it) = &(it).1 { v.visit_lifetime(it); - }; - }; + } + } if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } tokens_helper(v, &node.self_token.span); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3152,16 +3162,16 @@ { if let Some(it) = &node.constness { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.asyncness { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.unsafety { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.abi { v.visit_abi(it); - }; + } tokens_helper(v, &node.fn_token.span); v.visit_ident(&node.ident); v.visit_generics(&node.generics); @@ -3175,14 +3185,13 @@ } if let Some(it) = &node.variadic { v.visit_variadic(it); - }; + } v.visit_return_type(&node.output); } pub fn visit_span<'ast, V>(v: &mut V, node: &Span) where V: Visit<'ast> + ?Sized, -{ -} +{} #[cfg(feature = "full")] pub fn visit_stmt<'ast, V>(v: &mut V, node: &'ast Stmt) where @@ -3211,11 +3220,11 @@ { if let Some(it) = &node.paren_token { tokens_helper(v, &it.span); - }; + } v.visit_trait_bound_modifier(&node.modifier); if let Some(it) = &node.lifetimes { v.visit_bound_lifetimes(it); - }; + } v.visit_path(&node.path); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3251,6 +3260,7 @@ TraitItem::Verbatim(_binding_0) => { skip!(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -3269,7 +3279,7 @@ if let Some(it) = &node.default { tokens_helper(v, &(it).0.spans); v.visit_expr(&(it).1); - }; + } tokens_helper(v, &node.semi_token.spans); } #[cfg(feature = "full")] @@ -3283,7 +3293,7 @@ v.visit_macro(&node.mac); if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_trait_item_method<'ast, V>(v: &mut V, node: &'ast TraitItemMethod) @@ -3296,10 +3306,10 @@ v.visit_signature(&node.sig); if let Some(it) = &node.default { v.visit_block(it); - }; + } if let Some(it) = &node.semi_token { tokens_helper(v, &it.spans); - }; + } } #[cfg(feature = "full")] pub fn visit_trait_item_type<'ast, V>(v: &mut V, node: &'ast TraitItemType) @@ -3314,7 +3324,7 @@ v.visit_generics(&node.generics); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound(it); @@ -3325,7 +3335,7 @@ if let Some(it) = &node.default { tokens_helper(v, &(it).0.spans); v.visit_type(&(it).1); - }; + } tokens_helper(v, &node.semi_token.spans); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3379,6 +3389,7 @@ Type::Verbatim(_binding_0) => { skip!(_binding_0); } + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -3399,13 +3410,13 @@ { if let Some(it) = &node.lifetimes { v.visit_bound_lifetimes(it); - }; + } if let Some(it) = &node.unsafety { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.abi { v.visit_abi(it); - }; + } tokens_helper(v, &node.fn_token.span); tokens_helper(v, &node.paren_token.span); for el in Punctuated::pairs(&node.inputs) { @@ -3417,7 +3428,7 @@ } if let Some(it) = &node.variadic { v.visit_variadic(it); - }; + } v.visit_return_type(&node.output); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3474,7 +3485,7 @@ v.visit_ident(&node.ident); if let Some(it) = &node.colon_token { tokens_helper(v, &it.spans); - }; + } for el in Punctuated::pairs(&node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound(it); @@ -3484,10 +3495,10 @@ } if let Some(it) = &node.eq_token { tokens_helper(v, &it.spans); - }; + } if let Some(it) = &node.default { v.visit_type(it); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_type_param_bound<'ast, V>(v: &mut V, node: &'ast TypeParamBound) @@ -3518,7 +3529,7 @@ { if let Some(it) = &node.qself { v.visit_qself(it); - }; + } v.visit_path(&node.path); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3529,10 +3540,10 @@ tokens_helper(v, &node.star_token.spans); if let Some(it) = &node.const_token { tokens_helper(v, &it.span); - }; + } if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3543,10 +3554,10 @@ tokens_helper(v, &node.and_token.spans); if let Some(it) = &node.lifetime { v.visit_lifetime(it); - }; + } if let Some(it) = &node.mutability { tokens_helper(v, &it.span); - }; + } v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3564,7 +3575,7 @@ { if let Some(it) = &node.dyn_token { tokens_helper(v, &it.span); - }; + } for el in Punctuated::pairs(&node.bounds) { let (it, p) = el.into_tuple(); v.visit_type_param_bound(it); @@ -3696,7 +3707,7 @@ if let Some(it) = &node.discriminant { tokens_helper(v, &(it).0.spans); v.visit_expr(&(it).1); - }; + } } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_vis_crate<'ast, V>(v: &mut V, node: &'ast VisCrate) @@ -3721,7 +3732,7 @@ tokens_helper(v, &node.paren_token.span); if let Some(it) = &node.in_token { tokens_helper(v, &it.span); - }; + } v.visit_path(&*node.path); } #[cfg(any(feature = "derive", feature = "full"))] diff -Nru cargo-0.58.0/vendor/syn/src/generics.rs cargo-0.60.0ubuntu1/vendor/syn/src/generics.rs --- cargo-0.58.0/vendor/syn/src/generics.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/generics.rs 2022-04-20 13:48:09.000000000 +0000 @@ -831,15 +831,43 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for TraitBound { fn parse(input: ParseStream) -> Result { + #[cfg(feature = "full")] + let tilde_const = if input.peek(Token![~]) && input.peek2(Token![const]) { + let tilde_token = input.parse::()?; + let const_token = input.parse::()?; + Some((tilde_token, const_token)) + } else { + None + }; + let modifier: TraitBoundModifier = input.parse()?; let lifetimes: Option = input.parse()?; let mut path: Path = input.parse()?; - if path.segments.last().unwrap().arguments.is_empty() && input.peek(token::Paren) { - let parenthesized = PathArguments::Parenthesized(input.parse()?); + if path.segments.last().unwrap().arguments.is_empty() + && (input.peek(token::Paren) || input.peek(Token![::]) && input.peek3(token::Paren)) + { + input.parse::>()?; + let args: ParenthesizedGenericArguments = input.parse()?; + let parenthesized = PathArguments::Parenthesized(args); path.segments.last_mut().unwrap().arguments = parenthesized; } + #[cfg(feature = "full")] + { + if let Some((tilde_token, const_token)) = tilde_const { + path.segments.insert( + 0, + PathSegment { + ident: Ident::new("const", const_token.span), + arguments: PathArguments::None, + }, + ); + let (_const, punct) = path.segments.pairs_mut().next().unwrap().into_tuple(); + *punct.unwrap() = Token![::](tilde_token.span); + } + } + Ok(TraitBound { paren_token: None, modifier, @@ -994,6 +1022,8 @@ use super::*; use crate::attr::FilterAttrs; use crate::print::TokensOrDefault; + #[cfg(feature = "full")] + use crate::punctuated::Pair; use proc_macro2::TokenStream; #[cfg(feature = "full")] use proc_macro2::TokenTree; @@ -1214,9 +1244,26 @@ impl ToTokens for TraitBound { fn to_tokens(&self, tokens: &mut TokenStream) { let to_tokens = |tokens: &mut TokenStream| { + #[cfg(feature = "full")] + let skip = match self.path.segments.pairs().next() { + Some(Pair::Punctuated(t, p)) if t.ident == "const" => { + Token![~](p.spans[0]).to_tokens(tokens); + t.to_tokens(tokens); + 1 + } + _ => 0, + }; self.modifier.to_tokens(tokens); self.lifetimes.to_tokens(tokens); - self.path.to_tokens(tokens); + #[cfg(feature = "full")] + { + self.path.leading_colon.to_tokens(tokens); + tokens.append_all(self.path.segments.pairs().skip(skip)); + } + #[cfg(not(feature = "full"))] + { + self.path.to_tokens(tokens); + } }; match &self.paren_token { Some(paren) => paren.surround(tokens, to_tokens), diff -Nru cargo-0.58.0/vendor/syn/src/item.rs cargo-0.60.0ubuntu1/vendor/syn/src/item.rs --- cargo-0.58.0/vendor/syn/src/item.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/item.rs 2022-04-20 13:48:09.000000000 +0000 @@ -17,6 +17,7 @@ /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] pub enum Item { /// A constant item: `const MAX: u16 = 65535`. Const(ItemConst), @@ -71,18 +72,17 @@ /// Tokens forming an item not interpreted by Syn. Verbatim(TokenStream), - // The following is the only supported idiom for exhaustive matching of - // this enum. + // Not public API. // - // match expr { - // Item::Const(e) => {...} - // Item::Enum(e) => {...} + // For testing exhaustiveness in downstream code, use the following idiom: + // + // match item { + // Item::Const(item) => {...} + // Item::Enum(item) => {...} // ... - // Item::Verbatim(e) => {...} + // Item::Verbatim(item) => {...} // - // #[cfg(test)] - // Item::__TestExhaustive(_) => unimplemented!(), - // #[cfg(not(test))] + // #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))] // _ => { /* some sane fallback */ } // } // @@ -90,12 +90,9 @@ // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - // - // Once `deny(reachable)` is available in rustc, Item will be - // reimplemented as a non_exhaustive enum. - // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237 + #[cfg(syn_no_non_exhaustive)] #[doc(hidden)] - __TestExhaustive(crate::private), + __NonExhaustive, } } @@ -381,9 +378,7 @@ | Item::Macro2(ItemMacro2 { attrs, .. }) => mem::replace(attrs, new), Item::Verbatim(_) => Vec::new(), - #[cfg(test)] - Item::__TestExhaustive(_) => unimplemented!(), - #[cfg(not(test))] + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), } } @@ -564,6 +559,7 @@ /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] pub enum ForeignItem { /// A foreign function in an `extern` block. Fn(ForeignItemFn), @@ -580,18 +576,17 @@ /// Tokens in an `extern` block not interpreted by Syn. Verbatim(TokenStream), - // The following is the only supported idiom for exhaustive matching of - // this enum. + // Not public API. + // + // For testing exhaustiveness in downstream code, use the following idiom: // - // match expr { - // ForeignItem::Fn(e) => {...} - // ForeignItem::Static(e) => {...} + // match item { + // ForeignItem::Fn(item) => {...} + // ForeignItem::Static(item) => {...} // ... - // ForeignItem::Verbatim(e) => {...} + // ForeignItem::Verbatim(item) => {...} // - // #[cfg(test)] - // ForeignItem::__TestExhaustive(_) => unimplemented!(), - // #[cfg(not(test))] + // #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))] // _ => { /* some sane fallback */ } // } // @@ -599,12 +594,9 @@ // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - // - // Once `deny(reachable)` is available in rustc, ForeignItem will be - // reimplemented as a non_exhaustive enum. - // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237 + #[cfg(syn_no_non_exhaustive)] #[doc(hidden)] - __TestExhaustive(crate::private), + __NonExhaustive, } } @@ -675,6 +667,7 @@ /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] pub enum TraitItem { /// An associated constant within the definition of a trait. Const(TraitItemConst), @@ -691,18 +684,17 @@ /// Tokens within the definition of a trait not interpreted by Syn. Verbatim(TokenStream), - // The following is the only supported idiom for exhaustive matching of - // this enum. + // Not public API. + // + // For testing exhaustiveness in downstream code, use the following idiom: // - // match expr { - // TraitItem::Const(e) => {...} - // TraitItem::Method(e) => {...} + // match item { + // TraitItem::Const(item) => {...} + // TraitItem::Method(item) => {...} // ... - // TraitItem::Verbatim(e) => {...} + // TraitItem::Verbatim(item) => {...} // - // #[cfg(test)] - // TraitItem::__TestExhaustive(_) => unimplemented!(), - // #[cfg(not(test))] + // #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))] // _ => { /* some sane fallback */ } // } // @@ -710,12 +702,9 @@ // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - // - // Once `deny(reachable)` is available in rustc, TraitItem will be - // reimplemented as a non_exhaustive enum. - // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237 + #[cfg(syn_no_non_exhaustive)] #[doc(hidden)] - __TestExhaustive(crate::private), + __NonExhaustive, } } @@ -788,6 +777,7 @@ /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] pub enum ImplItem { /// An associated constant within an impl block. Const(ImplItemConst), @@ -804,18 +794,17 @@ /// Tokens within an impl block not interpreted by Syn. Verbatim(TokenStream), - // The following is the only supported idiom for exhaustive matching of - // this enum. + // Not public API. + // + // For testing exhaustiveness in downstream code, use the following idiom: // - // match expr { - // ImplItem::Const(e) => {...} - // ImplItem::Method(e) => {...} + // match item { + // ImplItem::Const(item) => {...} + // ImplItem::Method(item) => {...} // ... - // ImplItem::Verbatim(e) => {...} + // ImplItem::Verbatim(item) => {...} // - // #[cfg(test)] - // ImplItem::__TestExhaustive(_) => unimplemented!(), - // #[cfg(not(test))] + // #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))] // _ => { /* some sane fallback */ } // } // @@ -823,12 +812,9 @@ // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - // - // Once `deny(reachable)` is available in rustc, ImplItem will be - // reimplemented as a non_exhaustive enum. - // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237 + #[cfg(syn_no_non_exhaustive)] #[doc(hidden)] - __TestExhaustive(crate::private), + __NonExhaustive, } } @@ -1177,14 +1163,25 @@ semi_token: Token![;], } - impl Parse for FlexibleItemType { - fn parse(input: ParseStream) -> Result { + enum WhereClauseLocation { + // type Ty where T: 'static = T; + BeforeEq, + // type Ty = T where T: 'static; + #[allow(dead_code)] + AfterEq, + // TODO: goes away once the migration period on rust-lang/rust#89122 is over + Both, + } + + impl FlexibleItemType { + fn parse(input: ParseStream, where_clause_location: WhereClauseLocation) -> Result { let vis: Visibility = input.parse()?; let defaultness: Option = input.parse()?; let type_token: Token![type] = input.parse()?; let ident: Ident = input.parse()?; let mut generics: Generics = input.parse()?; let colon_token: Option = input.parse()?; + let mut bounds = Punctuated::new(); if colon_token.is_some() { loop { @@ -1198,12 +1195,29 @@ bounds.push_punct(input.parse::()?); } } - generics.where_clause = input.parse()?; + + match where_clause_location { + WhereClauseLocation::BeforeEq | WhereClauseLocation::Both => { + generics.where_clause = input.parse()?; + } + _ => {} + } + let ty = if let Some(eq_token) = input.parse()? { Some((eq_token, input.parse::()?)) } else { None }; + + match where_clause_location { + WhereClauseLocation::AfterEq | WhereClauseLocation::Both + if generics.where_clause.is_none() => + { + generics.where_clause = input.parse()?; + } + _ => {} + } + let semi_token: Token![;] = input.parse()?; Ok(FlexibleItemType { @@ -1800,9 +1814,7 @@ ForeignItem::Macro(item) => &mut item.attrs, ForeignItem::Verbatim(_) => return Ok(item), - #[cfg(test)] - ForeignItem::__TestExhaustive(_) => unimplemented!(), - #[cfg(not(test))] + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), }; attrs.append(item_attrs); @@ -1868,7 +1880,7 @@ bounds: _, ty, semi_token, - } = input.parse()?; + } = FlexibleItemType::parse(input, WhereClauseLocation::BeforeEq)?; if defaultness.is_some() || generics.lt_token.is_some() @@ -1937,7 +1949,7 @@ bounds: _, ty, semi_token, - } = input.parse()?; + } = FlexibleItemType::parse(input, WhereClauseLocation::BeforeEq)?; if defaultness.is_some() || colon_token.is_some() || ty.is_none() { Ok(Item::Verbatim(verbatim::between(begin, input))) @@ -1959,13 +1971,12 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ItemStruct { fn parse(input: ParseStream) -> Result { - let mut attrs = input.call(Attribute::parse_outer)?; + let attrs = input.call(Attribute::parse_outer)?; let vis = input.parse::()?; let struct_token = input.parse::()?; let ident = input.parse::()?; let generics = input.parse::()?; - let (where_clause, fields, semi_token) = - derive::parsing::data_struct(input, &mut attrs)?; + let (where_clause, fields, semi_token) = derive::parsing::data_struct(input)?; Ok(ItemStruct { attrs, vis, @@ -1984,13 +1995,12 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ItemEnum { fn parse(input: ParseStream) -> Result { - let mut attrs = input.call(Attribute::parse_outer)?; + let attrs = input.call(Attribute::parse_outer)?; let vis = input.parse::()?; let enum_token = input.parse::()?; let ident = input.parse::()?; let generics = input.parse::()?; - let (where_clause, brace_token, variants) = - derive::parsing::data_enum(input, &mut attrs)?; + let (where_clause, brace_token, variants) = derive::parsing::data_enum(input)?; Ok(ItemEnum { attrs, vis, @@ -2009,12 +2019,12 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ItemUnion { fn parse(input: ParseStream) -> Result { - let mut attrs = input.call(Attribute::parse_outer)?; + let attrs = input.call(Attribute::parse_outer)?; let vis = input.parse::()?; let union_token = input.parse::()?; let ident = input.parse::()?; let generics = input.parse::()?; - let (where_clause, fields) = derive::parsing::data_union(input, &mut attrs)?; + let (where_clause, fields) = derive::parsing::data_union(input)?; Ok(ItemUnion { attrs, vis, @@ -2238,9 +2248,7 @@ TraitItem::Macro(item) => &mut item.attrs, TraitItem::Verbatim(_) => unreachable!(), - #[cfg(test)] - TraitItem::__TestExhaustive(_) => unimplemented!(), - #[cfg(not(test))] + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), }; attrs.append(item_attrs); @@ -2328,7 +2336,6 @@ } } - generics.where_clause = input.parse()?; let default = if input.peek(Token![=]) { let eq_token: Token![=] = input.parse()?; let default: Type = input.parse()?; @@ -2336,6 +2343,8 @@ } else { None }; + + generics.where_clause = input.parse()?; let semi_token: Token![;] = input.parse()?; Ok(TraitItemType { @@ -2362,7 +2371,7 @@ bounds, ty, semi_token, - } = input.parse()?; + } = FlexibleItemType::parse(input, WhereClauseLocation::Both)?; if defaultness.is_some() || vis.is_some() { Ok(TraitItem::Verbatim(verbatim::between(begin, input))) @@ -2455,7 +2464,7 @@ while let Type::Group(ty) = first_ty_ref { first_ty_ref = &ty.elem; } - if let Type::Path(_) = first_ty_ref { + if let Type::Path(TypePath { qself: None, .. }) = first_ty_ref { while let Type::Group(ty) = first_ty { first_ty = *ty.elem; } @@ -2580,9 +2589,7 @@ ImplItem::Macro(item) => &mut item.attrs, ImplItem::Verbatim(_) => return Ok(item), - #[cfg(test)] - ImplItem::__TestExhaustive(_) => unimplemented!(), - #[cfg(not(test))] + #[cfg(syn_no_non_exhaustive)] _ => unreachable!(), }; attrs.append(item_attrs); @@ -2661,20 +2668,26 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ImplItemType { fn parse(input: ParseStream) -> Result { + let attrs = input.call(Attribute::parse_outer)?; + let vis: Visibility = input.parse()?; + let defaultness: Option = input.parse()?; + let type_token: Token![type] = input.parse()?; + let ident: Ident = input.parse()?; + let mut generics: Generics = input.parse()?; + let eq_token: Token![=] = input.parse()?; + let ty: Type = input.parse()?; + generics.where_clause = input.parse()?; + let semi_token: Token![;] = input.parse()?; Ok(ImplItemType { - attrs: input.call(Attribute::parse_outer)?, - vis: input.parse()?, - defaultness: input.parse()?, - type_token: input.parse()?, - ident: input.parse()?, - generics: { - let mut generics: Generics = input.parse()?; - generics.where_clause = input.parse()?; - generics - }, - eq_token: input.parse()?, - ty: input.parse()?, - semi_token: input.parse()?, + attrs, + vis, + defaultness, + type_token, + ident, + generics, + eq_token, + ty, + semi_token, }) } } @@ -2690,7 +2703,7 @@ bounds: _, ty, semi_token, - } = input.parse()?; + } = FlexibleItemType::parse(input, WhereClauseLocation::Both)?; if colon_token.is_some() || ty.is_none() { Ok(ImplItem::Verbatim(verbatim::between(begin, input))) @@ -3106,11 +3119,11 @@ TokensOrDefault(&self.colon_token).to_tokens(tokens); self.bounds.to_tokens(tokens); } - self.generics.where_clause.to_tokens(tokens); if let Some((eq_token, default)) = &self.default { eq_token.to_tokens(tokens); default.to_tokens(tokens); } + self.generics.where_clause.to_tokens(tokens); self.semi_token.to_tokens(tokens); } } @@ -3171,9 +3184,9 @@ self.type_token.to_tokens(tokens); self.ident.to_tokens(tokens); self.generics.to_tokens(tokens); - self.generics.where_clause.to_tokens(tokens); self.eq_token.to_tokens(tokens); self.ty.to_tokens(tokens); + self.generics.where_clause.to_tokens(tokens); self.semi_token.to_tokens(tokens); } } diff -Nru cargo-0.58.0/vendor/syn/src/lib.rs cargo-0.60.0ubuntu1/vendor/syn/src/lib.rs --- cargo-0.58.0/vendor/syn/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -250,22 +250,26 @@ //! dynamic library libproc_macro from rustc toolchain. // Syn types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/syn/1.0.77")] +#![doc(html_root_url = "https://docs.rs/syn/1.0.91")] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![allow(non_camel_case_types)] // Ignored clippy lints. #![allow( + clippy::cast_lossless, clippy::collapsible_match, // https://github.com/rust-lang/rust-clippy/issues/7575 clippy::doc_markdown, clippy::eval_order_dependence, clippy::inherent_to_string, clippy::large_enum_variant, + clippy::let_underscore_drop, + clippy::manual_assert, clippy::manual_map, // https://github.com/rust-lang/rust-clippy/issues/6795 clippy::match_on_vec_items, clippy::missing_panics_doc, clippy::needless_doctest_main, clippy::needless_pass_by_value, clippy::never_loop, + clippy::return_self_not_must_use, clippy::too_many_arguments, clippy::trivially_copy_pass_by_ref, clippy::unnecessary_unwrap, @@ -281,6 +285,8 @@ clippy::empty_enum, clippy::expl_impl_clone_on_copy, clippy::if_not_else, + // clippy bug: https://github.com/rust-lang/rust-clippy/issues/8285 + clippy::iter_not_returning_iterator, clippy::match_same_arms, // clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984 clippy::match_wildcard_for_single_variants, @@ -823,8 +829,6 @@ #[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))] mod print; -use crate::__private::private; - //////////////////////////////////////////////////////////////////////////////// // https://github.com/rust-lang/rust/issues/62830 diff -Nru cargo-0.58.0/vendor/syn/src/lit.rs cargo-0.60.0ubuntu1/vendor/syn/src/lit.rs --- cargo-0.58.0/vendor/syn/src/lit.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/lit.rs 2022-04-20 13:48:09.000000000 +0000 @@ -3,12 +3,9 @@ #[cfg(feature = "parsing")] use crate::parse::{Parse, Parser}; use crate::{Error, Result}; -#[cfg(feature = "printing")] -use proc_macro2::Ident; +use proc_macro2::{Ident, Literal, Span}; #[cfg(feature = "parsing")] -use proc_macro2::TokenStream; -use proc_macro2::TokenTree; -use proc_macro2::{Literal, Span}; +use proc_macro2::{TokenStream, TokenTree}; use std::fmt::{self, Display}; #[cfg(feature = "extra-traits")] use std::hash::{Hash, Hasher}; @@ -244,6 +241,10 @@ pub fn suffix(&self) -> &str { &self.repr.suffix } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl LitByteStr { @@ -275,6 +276,10 @@ pub fn suffix(&self) -> &str { &self.repr.suffix } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl LitByte { @@ -306,6 +311,10 @@ pub fn suffix(&self) -> &str { &self.repr.suffix } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl LitChar { @@ -337,6 +346,10 @@ pub fn suffix(&self) -> &str { &self.repr.suffix } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl LitInt { @@ -408,6 +421,10 @@ pub fn set_span(&mut self, span: Span) { self.repr.token.set_span(span); } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl From for LitInt { @@ -480,6 +497,10 @@ pub fn set_span(&mut self, span: Span) { self.repr.token.set_span(span); } + + pub fn token(&self) -> Literal { + self.repr.token.clone() + } } impl From for LitFloat { @@ -521,6 +542,11 @@ pub fn set_span(&mut self, span: Span) { self.span = span; } + + pub fn token(&self) -> Ident { + let s = if self.value { "true" } else { "false" }; + Ident::new(s, self.span) + } } #[cfg(feature = "extra-traits")] @@ -916,8 +942,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for LitBool { fn to_tokens(&self, tokens: &mut TokenStream) { - let s = if self.value { "true" } else { "false" }; - tokens.append(Ident::new(s, self.span)); + tokens.append(self.token()); } } } @@ -925,7 +950,6 @@ mod value { use super::*; use crate::bigint::BigInt; - use proc_macro2::TokenStream; use std::char; use std::ops::{Index, RangeFrom}; @@ -1540,35 +1564,37 @@ } } + #[allow(clippy::unnecessary_wraps)] pub fn to_literal(repr: &str, digits: &str, suffix: &str) -> Option { - if repr.starts_with('-') { - let f64_parse_finite = || digits.parse().ok().filter(|x: &f64| x.is_finite()); - let f32_parse_finite = || digits.parse().ok().filter(|x: &f32| x.is_finite()); - if suffix == "f64" { - f64_parse_finite().map(Literal::f64_suffixed) - } else if suffix == "f32" { - f32_parse_finite().map(Literal::f32_suffixed) - } else if suffix == "i64" { - digits.parse().ok().map(Literal::i64_suffixed) - } else if suffix == "i32" { - digits.parse().ok().map(Literal::i32_suffixed) - } else if suffix == "i16" { - digits.parse().ok().map(Literal::i16_suffixed) - } else if suffix == "i8" { - digits.parse().ok().map(Literal::i8_suffixed) - } else if !suffix.is_empty() { - None - } else if digits.contains('.') { - f64_parse_finite().map(Literal::f64_unsuffixed) - } else { - digits.parse().ok().map(Literal::i64_unsuffixed) - } - } else { - let stream = repr.parse::().unwrap(); - match stream.into_iter().next().unwrap() { - TokenTree::Literal(l) => Some(l), - _ => unreachable!(), - } - } + #[cfg(syn_no_negative_literal_parse)] + { + // Rustc older than https://github.com/rust-lang/rust/pull/87262. + if repr.starts_with('-') { + let f64_parse_finite = || digits.parse().ok().filter(|x: &f64| x.is_finite()); + let f32_parse_finite = || digits.parse().ok().filter(|x: &f32| x.is_finite()); + return if suffix == "f64" { + f64_parse_finite().map(Literal::f64_suffixed) + } else if suffix == "f32" { + f32_parse_finite().map(Literal::f32_suffixed) + } else if suffix == "i64" { + digits.parse().ok().map(Literal::i64_suffixed) + } else if suffix == "i32" { + digits.parse().ok().map(Literal::i32_suffixed) + } else if suffix == "i16" { + digits.parse().ok().map(Literal::i16_suffixed) + } else if suffix == "i8" { + digits.parse().ok().map(Literal::i8_suffixed) + } else if !suffix.is_empty() { + None + } else if digits.contains('.') { + f64_parse_finite().map(Literal::f64_unsuffixed) + } else { + digits.parse().ok().map(Literal::i64_unsuffixed) + }; + } + } + let _ = digits; + let _ = suffix; + Some(repr.parse::().unwrap()) } } diff -Nru cargo-0.58.0/vendor/syn/src/lookahead.rs cargo-0.60.0ubuntu1/vendor/syn/src/lookahead.rs --- cargo-0.58.0/vendor/syn/src/lookahead.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/lookahead.rs 2022-04-20 13:48:09.000000000 +0000 @@ -18,6 +18,9 @@ /// [`ParseStream::peek`]: crate::parse::ParseBuffer::peek /// [`ParseStream::lookahead1`]: crate::parse::ParseBuffer::lookahead1 /// +/// Consuming tokens from the source stream after constructing a lookahead +/// object does not also advance the lookahead object. +/// /// # Example /// /// ``` diff -Nru cargo-0.58.0/vendor/syn/src/macros.rs cargo-0.60.0ubuntu1/vendor/syn/src/macros.rs --- cargo-0.58.0/vendor/syn/src/macros.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/macros.rs 2022-04-20 13:48:09.000000000 +0000 @@ -76,7 +76,8 @@ ( $pub:ident $enum:ident $name:ident { $( - $(#[$variant_attr:meta])* + $(#[cfg $cfg_attr:tt])* + $(#[doc $($doc_attr:tt)*])* $variant:ident $( ($($member:ident)::+) )*, )* } @@ -95,7 +96,13 @@ $($remaining)* () tokens - $name { $($variant $($($member)::+)*,)* } + $name { + $( + $(#[cfg $cfg_attr])* + $(#[doc $($doc_attr)*])* + $variant $($($member)::+)*, + )* + } } }; } @@ -104,9 +111,6 @@ // No From for verbatim variants. ($name:ident::Verbatim, $member:ident) => {}; - // No From for private variants. - ($name:ident::$variant:ident, crate::private) => {}; - ($name:ident::$variant:ident, $member:ident) => { impl From<$member> for $name { fn from(e: $member) -> $name { @@ -120,23 +124,30 @@ macro_rules! generate_to_tokens { (do_not_generate_to_tokens $($foo:tt)*) => (); - (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident, $($next:tt)*}) => { - generate_to_tokens!( - ($($arms)* $name::$variant => {}) - $tokens $name { $($next)* } - ); - }; - - (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident $member:ident, $($next:tt)*}) => { + ( + ($($arms:tt)*) $tokens:ident $name:ident { + $(#[cfg $cfg_attr:tt])* + $(#[doc $($doc_attr:tt)*])* + $variant:ident, + $($next:tt)* + } + ) => { generate_to_tokens!( - ($($arms)* $name::$variant(_e) => _e.to_tokens($tokens),) + ($($arms)* $(#[cfg $cfg_attr])* $name::$variant => {}) $tokens $name { $($next)* } ); }; - (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident crate::private, $($next:tt)*}) => { + ( + ($($arms:tt)*) $tokens:ident $name:ident { + $(#[cfg $cfg_attr:tt])* + $(#[doc $($doc_attr:tt)*])* + $variant:ident $member:ident, + $($next:tt)* + } + ) => { generate_to_tokens!( - ($($arms)* $name::$variant(_) => unreachable!(),) + ($($arms)* $(#[cfg $cfg_attr])* $name::$variant(_e) => _e.to_tokens($tokens),) $tokens $name { $($next)* } ); }; diff -Nru cargo-0.58.0/vendor/syn/src/parse_quote.rs cargo-0.60.0ubuntu1/vendor/syn/src/parse_quote.rs --- cargo-0.58.0/vendor/syn/src/parse_quote.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/parse_quote.rs 2022-04-20 13:48:09.000000000 +0000 @@ -58,7 +58,6 @@ /// `P` with optional trailing punctuation /// - [`Vec`] — parses the same as `Block::parse_within` /// -/// [`Punctuated`]: crate::punctuated::Punctuated /// [`Vec`]: Block::parse_within /// /// # Panics @@ -66,18 +65,43 @@ /// Panics if the tokens fail to parse as the expected syntax tree type. The /// caller is responsible for ensuring that the input tokens are syntactically /// valid. -// -// TODO: allow Punctuated to be inferred as intra doc link, currently blocked on -// https://github.com/rust-lang/rust/issues/62834 #[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "printing"))))] #[macro_export] macro_rules! parse_quote { ($($tt:tt)*) => { - $crate::parse_quote::parse( - $crate::__private::From::from( - $crate::__private::quote::quote!($($tt)*) - ) - ) + $crate::parse_quote::parse($crate::__private::quote::quote!($($tt)*)) + }; +} + +/// This macro is [`parse_quote!`] + [`quote_spanned!`][quote::quote_spanned]. +/// +/// Please refer to each of their documentation. +/// +/// # Example +/// +/// ``` +/// use quote::{quote, quote_spanned}; +/// use syn::spanned::Spanned; +/// use syn::{parse_quote_spanned, ReturnType, Signature}; +/// +/// // Changes `fn()` to `fn() -> Pin>>`, +/// // and `fn() -> T` to `fn() -> Pin>>`, +/// // without introducing any call_site() spans. +/// fn make_ret_pinned_future(sig: &mut Signature) { +/// let ret = match &sig.output { +/// ReturnType::Default => quote_spanned!(sig.paren_token.span=> ()), +/// ReturnType::Type(_, ret) => quote!(#ret), +/// }; +/// sig.output = parse_quote_spanned! {ret.span()=> +/// -> ::std::pin::Pin<::std::boxed::Box>> +/// }; +/// } +/// ``` +#[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "printing"))))] +#[macro_export] +macro_rules! parse_quote_spanned { + ($span:expr=> $($tt:tt)*) => { + $crate::parse_quote::parse($crate::__private::quote::quote_spanned!($span=> $($tt)*)) }; } diff -Nru cargo-0.58.0/vendor/syn/src/parse.rs cargo-0.60.0ubuntu1/vendor/syn/src/parse.rs --- cargo-0.58.0/vendor/syn/src/parse.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/parse.rs 2022-04-20 13:48:09.000000000 +0000 @@ -199,6 +199,8 @@ use proc_macro2::{self, Delimiter, Group, Literal, Punct, Span, TokenStream, TokenTree}; use std::cell::Cell; use std::fmt::{self, Debug, Display}; +#[cfg(feature = "extra-traits")] +use std::hash::{Hash, Hasher}; use std::marker::PhantomData; use std::mem; use std::ops::Deref; @@ -1285,3 +1287,29 @@ Ok(Nothing) } } + +#[cfg(feature = "extra-traits")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for Nothing { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("Nothing") + } +} + +#[cfg(feature = "extra-traits")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for Nothing {} + +#[cfg(feature = "extra-traits")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for Nothing { + fn eq(&self, _other: &Self) -> bool { + true + } +} + +#[cfg(feature = "extra-traits")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for Nothing { + fn hash(&self, _state: &mut H) {} +} diff -Nru cargo-0.58.0/vendor/syn/src/path.rs cargo-0.60.0ubuntu1/vendor/syn/src/path.rs --- cargo-0.58.0/vendor/syn/src/path.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/path.rs 2022-04-20 13:48:09.000000000 +0000 @@ -231,7 +231,38 @@ } if input.peek(Ident) && input.peek2(Token![=]) { - return Ok(GenericArgument::Binding(input.parse()?)); + let ident: Ident = input.parse()?; + let eq_token: Token![=] = input.parse()?; + + let ty = if input.peek(Lit) { + let begin = input.fork(); + input.parse::()?; + Type::Verbatim(verbatim::between(begin, input)) + } else if input.peek(token::Brace) { + let begin = input.fork(); + + #[cfg(feature = "full")] + { + input.parse::()?; + } + + #[cfg(not(feature = "full"))] + { + let content; + braced!(content in input); + content.parse::()?; + } + + Type::Verbatim(verbatim::between(begin, input)) + } else { + input.parse()? + }; + + return Ok(GenericArgument::Binding(Binding { + ident, + eq_token, + ty, + })); } #[cfg(feature = "full")] @@ -589,7 +620,7 @@ path: &mut Self, expr_style: bool, ) -> Result<()> { - while input.peek(Token![::]) { + while input.peek(Token![::]) && !input.peek3(token::Paren) { let punct: Token![::] = input.parse()?; path.segments.push_punct(punct); let value = PathSegment::parse_helper(input, expr_style)?; @@ -653,7 +684,7 @@ } #[cfg(feature = "printing")] -mod printing { +pub(crate) mod printing { use super::*; use crate::print::TokensOrDefault; use proc_macro2::TokenStream; @@ -804,39 +835,37 @@ } } - impl private { - pub(crate) fn print_path(tokens: &mut TokenStream, qself: &Option, path: &Path) { - let qself = match qself { - Some(qself) => qself, - None => { - path.to_tokens(tokens); - return; - } - }; - qself.lt_token.to_tokens(tokens); - qself.ty.to_tokens(tokens); - - let pos = cmp::min(qself.position, path.segments.len()); - let mut segments = path.segments.pairs(); - if pos > 0 { - TokensOrDefault(&qself.as_token).to_tokens(tokens); - path.leading_colon.to_tokens(tokens); - for (i, segment) in segments.by_ref().take(pos).enumerate() { - if i + 1 == pos { - segment.value().to_tokens(tokens); - qself.gt_token.to_tokens(tokens); - segment.punct().to_tokens(tokens); - } else { - segment.to_tokens(tokens); - } + pub(crate) fn print_path(tokens: &mut TokenStream, qself: &Option, path: &Path) { + let qself = match qself { + Some(qself) => qself, + None => { + path.to_tokens(tokens); + return; + } + }; + qself.lt_token.to_tokens(tokens); + qself.ty.to_tokens(tokens); + + let pos = cmp::min(qself.position, path.segments.len()); + let mut segments = path.segments.pairs(); + if pos > 0 { + TokensOrDefault(&qself.as_token).to_tokens(tokens); + path.leading_colon.to_tokens(tokens); + for (i, segment) in segments.by_ref().take(pos).enumerate() { + if i + 1 == pos { + segment.value().to_tokens(tokens); + qself.gt_token.to_tokens(tokens); + segment.punct().to_tokens(tokens); + } else { + segment.to_tokens(tokens); } - } else { - qself.gt_token.to_tokens(tokens); - path.leading_colon.to_tokens(tokens); - } - for segment in segments { - segment.to_tokens(tokens); } + } else { + qself.gt_token.to_tokens(tokens); + path.leading_colon.to_tokens(tokens); + } + for segment in segments { + segment.to_tokens(tokens); } } } diff -Nru cargo-0.58.0/vendor/syn/src/pat.rs cargo-0.60.0ubuntu1/vendor/syn/src/pat.rs --- cargo-0.58.0/vendor/syn/src/pat.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/pat.rs 2022-04-20 13:48:09.000000000 +0000 @@ -14,6 +14,7 @@ /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] pub enum Pat { /// A box pattern: `box v`. Box(PatBox), @@ -72,18 +73,17 @@ /// A pattern that matches any value: `_`. Wild(PatWild), - // The following is the only supported idiom for exhaustive matching of - // this enum. + // Not public API. // - // match expr { - // Pat::Box(e) => {...} - // Pat::Ident(e) => {...} + // For testing exhaustiveness in downstream code, use the following idiom: + // + // match pat { + // Pat::Box(pat) => {...} + // Pat::Ident(pat) => {...} // ... - // Pat::Wild(e) => {...} + // Pat::Wild(pat) => {...} // - // #[cfg(test)] - // Pat::__TestExhaustive(_) => unimplemented!(), - // #[cfg(not(test))] + // #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))] // _ => { /* some sane fallback */ } // } // @@ -91,12 +91,9 @@ // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - // - // Once `deny(reachable)` is available in rustc, Pat will be - // reimplemented as a non_exhaustive enum. - // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237 + #[cfg(syn_no_non_exhaustive)] #[doc(hidden)] - __TestExhaustive(crate::private), + __NonExhaustive, } } @@ -654,7 +651,7 @@ fn pat_lit_expr(input: ParseStream) -> Result>> { if input.is_empty() || input.peek(Token![|]) - || input.peek(Token![=>]) + || input.peek(Token![=]) || input.peek(Token![:]) && !input.peek(Token![::]) || input.peek(Token![,]) || input.peek(Token![;]) @@ -827,7 +824,7 @@ impl ToTokens for PatPath { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); - private::print_path(tokens, &self.qself, &self.path); + path::printing::print_path(tokens, &self.qself, &self.path); } } @@ -881,10 +878,7 @@ fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); self.lo.to_tokens(tokens); - match &self.limits { - RangeLimits::HalfOpen(t) => t.to_tokens(tokens), - RangeLimits::Closed(t) => t.to_tokens(tokens), - } + self.limits.to_tokens(tokens); self.hi.to_tokens(tokens); } } diff -Nru cargo-0.58.0/vendor/syn/src/punctuated.rs cargo-0.60.0ubuntu1/vendor/syn/src/punctuated.rs --- cargo-0.58.0/vendor/syn/src/punctuated.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/punctuated.rs 2022-04-20 13:48:09.000000000 +0000 @@ -193,7 +193,7 @@ if self.last.is_some() { self.last.take().map(|t| Pair::End(*t)) } else { - self.inner.pop().map(|(t, d)| Pair::Punctuated(t, d)) + self.inner.pop().map(|(t, p)| Pair::Punctuated(t, p)) } } @@ -937,16 +937,16 @@ /// the final one and there is no trailing punctuation. pub fn punct(&self) -> Option<&P> { match self { - Pair::Punctuated(_, d) => Some(d), + Pair::Punctuated(_, p) => Some(p), Pair::End(_) => None, } } /// Creates a punctuated pair out of a syntax tree node and an optional /// following punctuation. - pub fn new(t: T, d: Option

) -> Self { - match d { - Some(d) => Pair::Punctuated(t, d), + pub fn new(t: T, p: Option

) -> Self { + match p { + Some(p) => Pair::Punctuated(t, p), None => Pair::End(t), } } @@ -955,7 +955,7 @@ /// optional following punctuation. pub fn into_tuple(self) -> (T, Option

) { match self { - Pair::Punctuated(t, d) => (t, Some(d)), + Pair::Punctuated(t, p) => (t, Some(p)), Pair::End(t) => (t, None), } } diff -Nru cargo-0.58.0/vendor/syn/src/stmt.rs cargo-0.60.0ubuntu1/vendor/syn/src/stmt.rs --- cargo-0.58.0/vendor/syn/src/stmt.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/stmt.rs 2022-04-20 13:48:09.000000000 +0000 @@ -50,7 +50,7 @@ pub mod parsing { use super::*; use crate::parse::discouraged::Speculative; - use crate::parse::{Parse, ParseStream, Result}; + use crate::parse::{Parse, ParseBuffer, ParseStream, Result}; use proc_macro2::TokenStream; impl Block { @@ -152,6 +152,7 @@ } fn parse_stmt(input: ParseStream, allow_nosemi: bool) -> Result { + let begin = input.fork(); let mut attrs = input.call(Attribute::parse_outer)?; // brace-style macros; paren and bracket macros get parsed as @@ -169,7 +170,7 @@ } if input.peek(Token![let]) { - stmt_local(input, attrs) + stmt_local(input, attrs, begin) } else if input.peek(Token![pub]) || input.peek(Token![crate]) && !input.peek2(Token![::]) || input.peek(Token![extern]) @@ -222,9 +223,7 @@ }))) } - fn stmt_local(input: ParseStream, attrs: Vec) -> Result { - let begin = input.fork(); - + fn stmt_local(input: ParseStream, attrs: Vec, begin: ParseBuffer) -> Result { let let_token: Token![let] = input.parse()?; let mut pat: Pat = pat::parsing::multi_pat_with_leading_vert(input)?; diff -Nru cargo-0.58.0/vendor/syn/src/ty.rs cargo-0.60.0ubuntu1/vendor/syn/src/ty.rs --- cargo-0.58.0/vendor/syn/src/ty.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/src/ty.rs 2022-04-20 13:48:09.000000000 +0000 @@ -14,6 +14,7 @@ /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] pub enum Type { /// A fixed size array type: `[T; n]`. Array(TypeArray), @@ -63,18 +64,17 @@ /// Tokens in type position not interpreted by Syn. Verbatim(TokenStream), - // The following is the only supported idiom for exhaustive matching of - // this enum. + // Not public API. // - // match expr { - // Type::Array(e) => {...} - // Type::BareFn(e) => {...} + // For testing exhaustiveness in downstream code, use the following idiom: + // + // match ty { + // Type::Array(ty) => {...} + // Type::BareFn(ty) => {...} // ... - // Type::Verbatim(e) => {...} + // Type::Verbatim(ty) => {...} // - // #[cfg(test)] - // Type::__TestExhaustive(_) => unimplemented!(), - // #[cfg(not(test))] + // #[cfg_attr(test, deny(non_exhaustive_omitted_patterns))] // _ => { /* some sane fallback */ } // } // @@ -82,12 +82,9 @@ // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - // - // Once `deny(reachable)` is available in rustc, Type will be - // reimplemented as a non_exhaustive enum. - // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237 + #[cfg(syn_no_non_exhaustive)] #[doc(hidden)] - __TestExhaustive(crate::private), + __NonExhaustive, } } @@ -541,7 +538,7 @@ || lookahead.peek(Token![<]) { if input.peek(Token![dyn]) { - let trait_object: TypeTraitObject = input.parse()?; + let trait_object = TypeTraitObject::parse(input, allow_plus)?; return Ok(Type::TraitObject(trait_object)); } @@ -586,7 +583,12 @@ if allow_plus { while input.peek(Token![+]) { bounds.push_punct(input.parse()?); - if input.peek(Token![>]) { + if !(input.peek(Ident::peek_any) + || input.peek(Token![::]) + || input.peek(Token![?]) + || input.peek(Lifetime) + || input.peek(token::Paren)) + { break; } bounds.push_value(input.parse()?); @@ -623,7 +625,7 @@ } else if lookahead.peek(Token![!]) && !input.peek(Token![=]) { input.parse().map(Type::Never) } else if lookahead.peek(Token![impl]) { - input.parse().map(Type::ImplTrait) + TypeImplTrait::parse(input, allow_plus).map(Type::ImplTrait) } else if lookahead.peek(Token![_]) { input.parse().map(Type::Infer) } else if lookahead.peek(Lifetime) { @@ -735,7 +737,10 @@ break; } - inputs.push_punct(args.parse()?); + let comma = args.parse()?; + if !has_mut_self { + inputs.push_punct(comma); + } } inputs @@ -816,7 +821,10 @@ fn parse(input: ParseStream) -> Result { let (qself, mut path) = path::parsing::qpath(input, false)?; - if path.segments.last().unwrap().arguments.is_empty() && input.peek(token::Paren) { + if path.segments.last().unwrap().arguments.is_empty() + && (input.peek(token::Paren) || input.peek(Token![::]) && input.peek3(token::Paren)) + { + input.parse::>()?; let args: ParenthesizedGenericArguments = input.parse()?; let parenthesized = PathArguments::Parenthesized(args); path.segments.last_mut().unwrap().arguments = parenthesized; @@ -827,13 +835,13 @@ } impl ReturnType { + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn without_plus(input: ParseStream) -> Result { let allow_plus = false; Self::parse(input, allow_plus) } - #[doc(hidden)] - pub fn parse(input: ParseStream, allow_plus: bool) -> Result { + pub(crate) fn parse(input: ParseStream, allow_plus: bool) -> Result { if input.peek(Token![->]) { let arrow = input.parse()?; let ty = ambig_ty(input, allow_plus)?; @@ -847,14 +855,16 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ReturnType { fn parse(input: ParseStream) -> Result { - Self::parse(input, true) + let allow_plus = true; + Self::parse(input, allow_plus) } } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for TypeTraitObject { fn parse(input: ParseStream) -> Result { - Self::parse(input, true) + let allow_plus = true; + Self::parse(input, allow_plus) } } @@ -868,60 +878,67 @@ } impl TypeTraitObject { + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn without_plus(input: ParseStream) -> Result { let allow_plus = false; Self::parse(input, allow_plus) } // Only allow multiple trait references if allow_plus is true. - #[doc(hidden)] - pub fn parse(input: ParseStream, allow_plus: bool) -> Result { + pub(crate) fn parse(input: ParseStream, allow_plus: bool) -> Result { Ok(TypeTraitObject { dyn_token: input.parse()?, - bounds: { - let mut bounds = Punctuated::new(); - if allow_plus { - loop { - bounds.push_value(input.parse()?); - if !input.peek(Token![+]) { - break; - } - bounds.push_punct(input.parse()?); - if input.peek(Token![>]) { - break; - } - } - } else { - bounds.push_value(input.parse()?); - } - // Just lifetimes like `'a + 'b` is not a TraitObject. - if !at_least_one_type(&bounds) { - return Err(input.error("expected at least one type")); - } - bounds - }, + bounds: Self::parse_bounds(input, allow_plus)?, }) } + + fn parse_bounds( + input: ParseStream, + allow_plus: bool, + ) -> Result> { + let mut bounds = Punctuated::new(); + loop { + bounds.push_value(input.parse()?); + if !(allow_plus && input.peek(Token![+])) { + break; + } + bounds.push_punct(input.parse()?); + if !(input.peek(Ident::peek_any) + || input.peek(Token![::]) + || input.peek(Token![?]) + || input.peek(Lifetime) + || input.peek(token::Paren)) + { + break; + } + } + // Just lifetimes like `'a + 'b` is not a TraitObject. + if !at_least_one_type(&bounds) { + return Err(input.error("expected at least one type")); + } + Ok(bounds) + } } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for TypeImplTrait { fn parse(input: ParseStream) -> Result { + let allow_plus = true; + Self::parse(input, allow_plus) + } + } + + impl TypeImplTrait { + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn without_plus(input: ParseStream) -> Result { + let allow_plus = false; + Self::parse(input, allow_plus) + } + + pub(crate) fn parse(input: ParseStream, allow_plus: bool) -> Result { Ok(TypeImplTrait { impl_token: input.parse()?, - // NOTE: rust-lang/rust#34511 includes discussion about whether - // or not + should be allowed in ImplTrait directly without (). - bounds: { - let mut bounds = Punctuated::new(); - loop { - bounds.push_value(input.parse()?); - if !input.peek(Token![+]) { - break; - } - bounds.push_punct(input.parse()?); - } - bounds - }, + bounds: TypeTraitObject::parse_bounds(input, allow_plus)?, }) } } @@ -1143,7 +1160,7 @@ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for TypePath { fn to_tokens(&self, tokens: &mut TokenStream) { - private::print_path(tokens, &self.qself, &self.path); + path::printing::print_path(tokens, &self.qself, &self.path); } } diff -Nru cargo-0.58.0/vendor/syn/tests/common/eq.rs cargo-0.60.0ubuntu1/vendor/syn/tests/common/eq.rs --- cargo-0.58.0/vendor/syn/tests/common/eq.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/common/eq.rs 2022-04-20 13:48:09.000000000 +0000 @@ -3,22 +3,21 @@ extern crate rustc_span; use rustc_ast::ast::{ - AngleBracketedArg, AngleBracketedArgs, AnonConst, Arm, AssocItemKind, AssocTyConstraint, - AssocTyConstraintKind, Async, AttrId, AttrItem, AttrKind, AttrStyle, Attribute, BareFnTy, - BinOpKind, BindingMode, Block, BlockCheckMode, BorrowKind, CaptureBy, Const, Crate, CrateSugar, - Defaultness, EnumDef, Expr, ExprField, ExprKind, Extern, FieldDef, FloatTy, FnDecl, FnHeader, - FnKind, FnRetTy, FnSig, ForeignItemKind, ForeignMod, GenericArg, GenericArgs, GenericBound, - GenericParam, GenericParamKind, Generics, ImplKind, ImplPolarity, Inline, InlineAsm, + AngleBracketedArg, AngleBracketedArgs, AnonConst, Arm, AssocConstraint, AssocConstraintKind, + AssocItemKind, Async, AttrId, AttrItem, AttrKind, AttrStyle, Attribute, BareFnTy, BinOpKind, + BindingMode, Block, BlockCheckMode, BorrowKind, CaptureBy, Const, Crate, CrateSugar, + Defaultness, EnumDef, Expr, ExprField, ExprKind, Extern, FieldDef, FloatTy, Fn, FnDecl, + FnHeader, FnRetTy, FnSig, ForeignItemKind, ForeignMod, GenericArg, GenericArgs, GenericBound, + GenericParam, GenericParamKind, Generics, Impl, ImplPolarity, Inline, InlineAsm, InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass, InlineAsmTemplatePiece, IntTy, - IsAuto, Item, ItemKind, Label, Lifetime, Lit, LitFloatType, LitIntType, LitKind, - LlvmAsmDialect, LlvmInlineAsm, LlvmInlineAsmOutput, Local, LocalKind, MacArgs, MacCall, - MacCallStmt, MacDelimiter, MacStmtStyle, MacroDef, ModKind, Movability, MutTy, Mutability, - NodeId, Param, ParenthesizedArgs, Pat, PatField, PatKind, Path, PathSegment, PolyTraitRef, - QSelf, RangeEnd, RangeLimits, RangeSyntax, Stmt, StmtKind, StrLit, StrStyle, StructExpr, - StructRest, TraitBoundModifier, TraitKind, TraitObjectSyntax, TraitRef, Ty, TyAliasKind, - TyKind, UintTy, UnOp, Unsafe, UnsafeSource, UseTree, UseTreeKind, Variant, VariantData, - Visibility, VisibilityKind, WhereBoundPredicate, WhereClause, WhereEqPredicate, WherePredicate, - WhereRegionPredicate, + IsAuto, Item, ItemKind, Label, Lifetime, Lit, LitFloatType, LitIntType, LitKind, Local, + LocalKind, MacArgs, MacCall, MacCallStmt, MacDelimiter, MacStmtStyle, MacroDef, ModKind, + ModSpans, Movability, MutTy, Mutability, NodeId, Param, ParenthesizedArgs, Pat, PatField, + PatKind, Path, PathSegment, PolyTraitRef, QSelf, RangeEnd, RangeLimits, RangeSyntax, Stmt, + StmtKind, StrLit, StrStyle, StructExpr, StructRest, Term, Trait, TraitBoundModifier, + TraitObjectSyntax, TraitRef, Ty, TyAlias, TyAliasWhereClause, TyKind, UintTy, UnOp, Unsafe, + UnsafeSource, UseTree, UseTreeKind, Variant, VariantData, Visibility, VisibilityKind, + WhereBoundPredicate, WhereClause, WhereEqPredicate, WherePredicate, WhereRegionPredicate, }; use rustc_ast::ptr::P; use rustc_ast::token::{self, CommentKind, DelimToken, Nonterminal, Token, TokenKind}; @@ -296,37 +295,36 @@ spanless_eq_struct!(AngleBracketedArgs; span args); spanless_eq_struct!(AnonConst; id value); spanless_eq_struct!(Arm; attrs pat guard body span id is_placeholder); -spanless_eq_struct!(AssocTyConstraint; id ident gen_args kind span); +spanless_eq_struct!(AssocConstraint; id ident gen_args kind span); spanless_eq_struct!(AttrAnnotatedTokenStream; 0); spanless_eq_struct!(AttrItem; path args tokens); spanless_eq_struct!(Attribute; kind id style span); spanless_eq_struct!(AttributesData; attrs tokens); spanless_eq_struct!(BareFnTy; unsafety ext generic_params decl); spanless_eq_struct!(Block; stmts id rules span tokens could_be_bare_literal); -spanless_eq_struct!(Crate; attrs items span); +spanless_eq_struct!(Crate; attrs items spans id is_placeholder); spanless_eq_struct!(EnumDef; variants); spanless_eq_struct!(Expr; id kind span attrs !tokens); spanless_eq_struct!(ExprField; attrs id span ident expr is_shorthand is_placeholder); spanless_eq_struct!(FieldDef; attrs id span vis ident ty is_placeholder); spanless_eq_struct!(FnDecl; inputs output); spanless_eq_struct!(FnHeader; constness asyncness unsafety ext); -spanless_eq_struct!(FnKind; 0 1 2 3); +spanless_eq_struct!(Fn; defaultness generics sig body); spanless_eq_struct!(FnSig; header decl span); spanless_eq_struct!(ForeignMod; unsafety abi items); spanless_eq_struct!(GenericParam; id ident attrs bounds is_placeholder kind); spanless_eq_struct!(Generics; params where_clause span); -spanless_eq_struct!(ImplKind; unsafety polarity defaultness constness generics of_trait self_ty items); -spanless_eq_struct!(InlineAsm; template template_strs operands clobber_abi options line_spans); +spanless_eq_struct!(Impl; defaultness unsafety generics constness polarity of_trait self_ty items); +spanless_eq_struct!(InlineAsm; template template_strs operands clobber_abis options line_spans); spanless_eq_struct!(Item; attrs id span vis ident kind !tokens); spanless_eq_struct!(Label; ident); spanless_eq_struct!(Lifetime; id ident); spanless_eq_struct!(Lit; token kind span); -spanless_eq_struct!(LlvmInlineAsm; asm asm_str_style outputs inputs clobbers volatile alignstack dialect); -spanless_eq_struct!(LlvmInlineAsmOutput; constraint expr is_rw is_indirect); spanless_eq_struct!(Local; pat ty kind id span attrs !tokens); spanless_eq_struct!(MacCall; path args prior_type_ascription); spanless_eq_struct!(MacCallStmt; mac style attrs tokens); spanless_eq_struct!(MacroDef; body macro_rules); +spanless_eq_struct!(ModSpans; !inner_span !inject_use_span); spanless_eq_struct!(MutTy; ty mutbl); spanless_eq_struct!(ParenthesizedArgs; span inputs inputs_span output); spanless_eq_struct!(Pat; id kind span tokens); @@ -339,10 +337,11 @@ spanless_eq_struct!(StrLit; style symbol suffix span symbol_unescaped); spanless_eq_struct!(StructExpr; qself path fields rest); spanless_eq_struct!(Token; kind span); -spanless_eq_struct!(TraitKind; 0 1 2 3 4); +spanless_eq_struct!(Trait; unsafety is_auto generics bounds items); spanless_eq_struct!(TraitRef; path ref_id); spanless_eq_struct!(Ty; id kind span tokens); -spanless_eq_struct!(TyAliasKind; 0 1 2 3); +spanless_eq_struct!(TyAlias; defaultness generics where_clauses !where_predicates_split bounds ty); +spanless_eq_struct!(TyAliasWhereClause; !0 1); spanless_eq_struct!(UseTree; prefix kind span); spanless_eq_struct!(Variant; attrs id span !vis ident data disr_expr is_placeholder); spanless_eq_struct!(Visibility; kind span tokens); @@ -353,7 +352,7 @@ spanless_eq_struct!(token::Lit; kind symbol suffix); spanless_eq_enum!(AngleBracketedArg; Arg(0) Constraint(0)); spanless_eq_enum!(AssocItemKind; Const(0 1 2) Fn(0) TyAlias(0) MacCall(0)); -spanless_eq_enum!(AssocTyConstraintKind; Equality(ty) Bound(bounds)); +spanless_eq_enum!(AssocConstraintKind; Equality(term) Bound(bounds)); spanless_eq_enum!(Async; Yes(span closure_id return_impl_trait_id) No); spanless_eq_enum!(AttrAnnotatedTokenTree; Token(0) Delimited(0 1 2) Attributes(0)); spanless_eq_enum!(AttrStyle; Outer Inner); @@ -381,7 +380,6 @@ spanless_eq_enum!(IsAuto; Yes No); spanless_eq_enum!(LitFloatType; Suffixed(0) Unsuffixed); spanless_eq_enum!(LitIntType; Signed(0) Unsigned(0) Unsuffixed); -spanless_eq_enum!(LlvmAsmDialect; Att Intel); spanless_eq_enum!(LocalKind; Decl Init(0) InitElse(0 1)); spanless_eq_enum!(MacArgs; Empty Delimited(0 1 2) Eq(0 1)); spanless_eq_enum!(MacDelimiter; Parenthesis Bracket Brace); @@ -394,6 +392,7 @@ spanless_eq_enum!(StmtKind; Local(0) Item(0) Expr(0) Semi(0) Empty MacCall(0)); spanless_eq_enum!(StrStyle; Cooked Raw(0)); spanless_eq_enum!(StructRest; Base(0) Rest(0) None); +spanless_eq_enum!(Term; Ty(0) Const(0)); spanless_eq_enum!(TokenTree; Token(0) Delimited(0 1 2)); spanless_eq_enum!(TraitBoundModifier; None Maybe MaybeConst MaybeConstMaybe); spanless_eq_enum!(TraitObjectSyntax; Dyn None); @@ -411,8 +410,7 @@ Closure(0 1 2 3 4 5) Block(0 1) Async(0 1 2) Await(0) TryBlock(0) Assign(0 1 2) AssignOp(0 1 2) Field(0 1) Index(0 1) Underscore Range(0 1 2) Path(0 1) AddrOf(0 1 2) Break(0 1) Continue(0) Ret(0) InlineAsm(0) - LlvmInlineAsm(0) MacCall(0) Struct(0) Repeat(0 1) Paren(0) Try(0) Yield(0) - Err); + MacCall(0) Struct(0) Repeat(0 1) Paren(0) Try(0) Yield(0) Err); spanless_eq_enum!(InlineAsmOperand; In(reg expr) Out(reg late expr) InOut(reg late expr) SplitInOut(reg late in_expr out_expr) Const(anon_const) Sym(expr)); @@ -528,7 +526,7 @@ } } -fn doc_comment<'a>( +fn doc_comment( style: AttrStyle, unescaped: Symbol, trees: &mut impl Iterator, diff -Nru cargo-0.58.0/vendor/syn/tests/common/mod.rs cargo-0.60.0ubuntu1/vendor/syn/tests/common/mod.rs --- cargo-0.58.0/vendor/syn/tests/common/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/common/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,4 +1,5 @@ #![allow(dead_code)] +#![allow(clippy::module_name_repetitions, clippy::shadow_unrelated)] use rayon::ThreadPoolBuilder; use std::env; diff -Nru cargo-0.58.0/vendor/syn/tests/debug/gen.rs cargo-0.60.0ubuntu1/vendor/syn/tests/debug/gen.rs --- cargo-0.58.0/vendor/syn/tests/debug/gen.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/debug/gen.rs 2022-04-20 13:48:09.000000000 +0000 @@ -591,29 +591,29 @@ if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.asyncness { + if let Some(val) = &_val.movability { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Async); + struct Print(syn::token::Static); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("Some")?; Ok(()) } } - formatter.field("asyncness", Print::ref_cast(val)); + formatter.field("movability", Print::ref_cast(val)); } - if let Some(val) = &_val.movability { + if let Some(val) = &_val.asyncness { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Static); + struct Print(syn::token::Async); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("Some")?; Ok(()) } } - formatter.field("movability", Print::ref_cast(val)); + formatter.field("asyncness", Print::ref_cast(val)); } if let Some(val) = &_val.capture { #[derive(RefCast)] @@ -1294,29 +1294,29 @@ if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.asyncness { + if let Some(val) = &_val.movability { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Async); + struct Print(syn::token::Static); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("Some")?; Ok(()) } } - formatter.field("asyncness", Print::ref_cast(val)); + formatter.field("movability", Print::ref_cast(val)); } - if let Some(val) = &_val.movability { + if let Some(val) = &_val.asyncness { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Static); + struct Print(syn::token::Async); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("Some")?; Ok(()) } } - formatter.field("movability", Print::ref_cast(val)); + formatter.field("asyncness", Print::ref_cast(val)); } if let Some(val) = &_val.capture { #[derive(RefCast)] @@ -2672,8 +2672,7 @@ fn fmt( &self, formatter: &mut fmt::Formatter, - ) -> fmt::Result - { + ) -> fmt::Result { match &self.0 { Some(_val) => { formatter.write_str("Some")?; @@ -3082,7 +3081,10 @@ #[repr(transparent)] struct Print(Option); impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt( + &self, + formatter: &mut fmt::Formatter, + ) -> fmt::Result { match &self.0 { Some(_val) => { formatter.write_str("Some")?; @@ -3424,24 +3426,12 @@ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let _val = &self.value; match _val { - syn::Lit::Str(_val) => { - write!(formatter, "{:?}", _val.value()) - } - syn::Lit::ByteStr(_val) => { - write!(formatter, "{:?}", _val.value()) - } - syn::Lit::Byte(_val) => { - write!(formatter, "{:?}", _val.value()) - } - syn::Lit::Char(_val) => { - write!(formatter, "{:?}", _val.value()) - } - syn::Lit::Int(_val) => { - write!(formatter, "{}", _val) - } - syn::Lit::Float(_val) => { - write!(formatter, "{}", _val) - } + syn::Lit::Str(_val) => write!(formatter, "{:?}", _val.value()), + syn::Lit::ByteStr(_val) => write!(formatter, "{:?}", _val.value()), + syn::Lit::Byte(_val) => write!(formatter, "{:?}", _val.value()), + syn::Lit::Char(_val) => write!(formatter, "{:?}", _val.value()), + syn::Lit::Int(_val) => write!(formatter, "{}", _val), + syn::Lit::Float(_val) => write!(formatter, "{}", _val), syn::Lit::Bool(_val) => { let mut formatter = formatter.debug_struct("Lit::Bool"); formatter.field("value", Lite(&_val.value)); @@ -4202,7 +4192,8 @@ match _val { syn::PathArguments::None => formatter.write_str("None"), syn::PathArguments::AngleBracketed(_val) => { - let mut formatter = formatter.debug_struct("PathArguments::AngleBracketed"); + let mut formatter = formatter + .debug_struct("PathArguments::AngleBracketed"); if let Some(val) = &_val.colon2_token { #[derive(RefCast)] #[repr(transparent)] @@ -4221,7 +4212,8 @@ formatter.finish() } syn::PathArguments::Parenthesized(_val) => { - let mut formatter = formatter.debug_struct("PathArguments::Parenthesized"); + let mut formatter = formatter + .debug_struct("PathArguments::Parenthesized"); if !_val.inputs.is_empty() { formatter.field("inputs", Lite(&_val.inputs)); } @@ -4345,7 +4337,10 @@ #[repr(transparent)] struct Print(Option); impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt( + &self, + formatter: &mut fmt::Formatter, + ) -> fmt::Result { match &self.0 { Some(_val) => { formatter.write_str("Some")?; diff -Nru cargo-0.58.0/vendor/syn/tests/debug/mod.rs cargo-0.60.0ubuntu1/vendor/syn/tests/debug/mod.rs --- cargo-0.58.0/vendor/syn/tests/debug/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/debug/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,10 @@ +#![allow( + clippy::no_effect_underscore_binding, + clippy::too_many_lines, + clippy::used_underscore_binding +)] + +#[rustfmt::skip] mod gen; use proc_macro2::{Ident, Literal, TokenStream}; diff -Nru cargo-0.58.0/vendor/syn/tests/macros/mod.rs cargo-0.60.0ubuntu1/vendor/syn/tests/macros/mod.rs --- cargo-0.58.0/vendor/syn/tests/macros/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/macros/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -39,18 +39,24 @@ (($expr:ident) as $t:ty, @$snapshot:literal) => { let $expr = crate::macros::Tokens::parse::<$t>($expr).unwrap(); let debug = crate::macros::debug::Lite(&$expr); - insta::assert_debug_snapshot!(debug, @$snapshot); + if !cfg!(miri) { + insta::assert_debug_snapshot!(debug, @$snapshot); + } }; (($($expr:tt)*) as $t:ty, @$snapshot:literal) => {{ let syntax_tree = crate::macros::Tokens::parse::<$t>($($expr)*).unwrap(); let debug = crate::macros::debug::Lite(&syntax_tree); - insta::assert_debug_snapshot!(debug, @$snapshot); + if !cfg!(miri) { + insta::assert_debug_snapshot!(debug, @$snapshot); + } syntax_tree }}; (($($expr:tt)*) , @$snapshot:literal) => {{ let syntax_tree = $($expr)*; let debug = crate::macros::debug::Lite(&syntax_tree); - insta::assert_debug_snapshot!(debug, @$snapshot); + if !cfg!(miri) { + insta::assert_debug_snapshot!(debug, @$snapshot); + } syntax_tree }}; (($($expr:tt)*) $next:tt $($rest:tt)*) => { diff -Nru cargo-0.58.0/vendor/syn/tests/regression/issue1108.rs cargo-0.60.0ubuntu1/vendor/syn/tests/regression/issue1108.rs --- cargo-0.58.0/vendor/syn/tests/regression/issue1108.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/regression/issue1108.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +#[test] +fn issue1108() { + let data = "impl>::x for"; + let _ = syn::parse_file(data); +} diff -Nru cargo-0.58.0/vendor/syn/tests/regression.rs cargo-0.60.0ubuntu1/vendor/syn/tests/regression.rs --- cargo-0.58.0/vendor/syn/tests/regression.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/regression.rs 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,5 @@ +#![allow(clippy::let_underscore_drop)] + +mod regression { + automod::dir!("tests/regression"); +} diff -Nru cargo-0.58.0/vendor/syn/tests/repo/mod.rs cargo-0.60.0ubuntu1/vendor/syn/tests/repo/mod.rs --- cargo-0.58.0/vendor/syn/tests/repo/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/repo/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,5 @@ +#![allow(clippy::manual_assert)] + mod progress; use self::progress::Progress; @@ -8,7 +10,7 @@ use tar::Archive; use walkdir::DirEntry; -const REVISION: &str = "ac2d9fc509e36d1b32513744adf58c34bcc4f43c"; +const REVISION: &str = "e95b10ba4ac4564ed25f7eef143e3182c33b3902"; #[rustfmt::skip] static EXCLUDE: &[&str] = &[ @@ -16,13 +18,6 @@ // https://github.com/dtolnay/syn/issues/1051 "src/test/ui/rfc-2632-const-trait-impl/syntax.rs", - // TODO: ~const in where-clause - // https://github.com/dtolnay/syn/issues/1051 - "library/alloc/src/borrow.rs", - "src/test/ui/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs", - "src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs", - "src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs", - // Compile-fail expr parameter in const generic position: f::<1 + 2>() "src/test/ui/const-generics/early/closing-args-token.rs", "src/test/ui/const-generics/early/const-expression-parameter.rs", @@ -51,16 +46,31 @@ "src/tools/rustfmt/tests/target/configs/spaces_around_ranges/true.rs", "src/tools/rustfmt/tests/target/type.rs", + // Clippy lint lists represented as expressions + "src/tools/clippy/clippy_lints/src/lib.deprecated.rs", + "src/tools/clippy/clippy_lints/src/lib.register_all.rs", + "src/tools/clippy/clippy_lints/src/lib.register_cargo.rs", + "src/tools/clippy/clippy_lints/src/lib.register_complexity.rs", + "src/tools/clippy/clippy_lints/src/lib.register_correctness.rs", + "src/tools/clippy/clippy_lints/src/lib.register_internal.rs", + "src/tools/clippy/clippy_lints/src/lib.register_lints.rs", + "src/tools/clippy/clippy_lints/src/lib.register_nursery.rs", + "src/tools/clippy/clippy_lints/src/lib.register_pedantic.rs", + "src/tools/clippy/clippy_lints/src/lib.register_perf.rs", + "src/tools/clippy/clippy_lints/src/lib.register_restriction.rs", + "src/tools/clippy/clippy_lints/src/lib.register_style.rs", + "src/tools/clippy/clippy_lints/src/lib.register_suspicious.rs", + // Not actually test cases "src/test/rustdoc-ui/test-compile-fail2.rs", "src/test/rustdoc-ui/test-compile-fail3.rs", - "src/test/ui/include-single-expr-helper.rs", - "src/test/ui/include-single-expr-helper-1.rs", "src/test/ui/json-bom-plus-crlf-multifile-aux.rs", "src/test/ui/lint/expansion-time-include.rs", "src/test/ui/macros/auxiliary/macro-comma-support.rs", "src/test/ui/macros/auxiliary/macro-include-items-expr.rs", - "src/test/ui/parser/auxiliary/issue-21146-inc.rs", + "src/test/ui/macros/include-single-expr-helper.rs", + "src/test/ui/macros/include-single-expr-helper-1.rs", + "src/test/ui/parser/issues/auxiliary/issue-21146-inc.rs", ]; pub fn base_dir_filter(entry: &DirEntry) -> bool { @@ -68,7 +78,7 @@ if path.is_dir() { return true; // otherwise walkdir does not visit the files } - if path.extension().map(|e| e != "rs").unwrap_or(true) { + if path.extension().map_or(true, |e| e != "rs") { return false; } @@ -132,7 +142,7 @@ "https://github.com/rust-lang/rust/archive/{}.tar.gz", REVISION ); - let response = reqwest::get(&url)?.error_for_status()?; + let response = reqwest::blocking::get(&url)?.error_for_status()?; let progress = Progress::new(response); let decoder = GzDecoder::new(progress); let mut archive = Archive::new(decoder); diff -Nru cargo-0.58.0/vendor/syn/tests/test_derive_input.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_derive_input.rs --- cargo-0.58.0/vendor/syn/tests/test_derive_input.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_derive_input.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,5 @@ +#![allow(clippy::too_many_lines)] + #[macro_use] mod macros; diff -Nru cargo-0.58.0/vendor/syn/tests/test_expr.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_expr.rs --- cargo-0.58.0/vendor/syn/tests/test_expr.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_expr.rs 2022-04-20 13:48:09.000000000 +0000 @@ -318,3 +318,9 @@ } "###); } + +#[test] +fn test_postfix_operator_after_cast() { + syn::parse_str::("|| &x as T[0]").unwrap_err(); + syn::parse_str::("|| () as ()()").unwrap_err(); +} diff -Nru cargo-0.58.0/vendor/syn/tests/test_generics.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_generics.rs --- cargo-0.58.0/vendor/syn/tests/test_generics.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_generics.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,5 @@ +#![allow(clippy::too_many_lines)] + #[macro_use] mod macros; diff -Nru cargo-0.58.0/vendor/syn/tests/test_item.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_item.rs --- cargo-0.58.0/vendor/syn/tests/test_item.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_item.rs 2022-04-20 13:48:09.000000000 +0000 @@ -299,3 +299,38 @@ self_ty: Type::Tuple, }"###); } + +#[test] +fn test_impl_trait_trailing_plus() { + let tokens = quote! { + fn f() -> impl Sized + {} + }; + + snapshot!(tokens as Item, @r###" + Item::Fn { + vis: Inherited, + sig: Signature { + ident: "f", + generics: Generics, + output: Type( + Type::ImplTrait { + bounds: [ + Trait(TraitBound { + modifier: None, + path: Path { + segments: [ + PathSegment { + ident: "Sized", + arguments: None, + }, + ], + }, + }), + ], + }, + ), + }, + block: Block, + } + "###); +} diff -Nru cargo-0.58.0/vendor/syn/tests/test_lit.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_lit.rs --- cargo-0.58.0/vendor/syn/tests/test_lit.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_lit.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,5 @@ +#![allow(clippy::float_cmp, clippy::non_ascii_literal)] + #[macro_use] mod macros; @@ -176,7 +178,6 @@ #[test] fn floats() { - #[cfg_attr(feature = "cargo-clippy", allow(float_cmp))] fn test_float(s: &str, value: f64, suffix: &str) { match lit(s) { Lit::Float(lit) => { @@ -215,12 +216,6 @@ } #[test] -fn negative_overflow() { - assert!(syn::parse_str::("-1.0e99f64").is_ok()); - assert!(syn::parse_str::("-1.0e999f64").is_err()); -} - -#[test] fn suffix() { fn get_suffix(token: &str) -> String { let lit = syn::parse_str::(token).unwrap(); diff -Nru cargo-0.58.0/vendor/syn/tests/test_meta.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_meta.rs --- cargo-0.58.0/vendor/syn/tests/test_meta.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_meta.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,5 @@ +#![allow(clippy::shadow_unrelated, clippy::too_many_lines)] + #[macro_use] mod macros; diff -Nru cargo-0.58.0/vendor/syn/tests/test_parse_buffer.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_parse_buffer.rs --- cargo-0.58.0/vendor/syn/tests/test_parse_buffer.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_parse_buffer.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,5 @@ +#![allow(clippy::non_ascii_literal)] + use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenStream, TokenTree}; use std::iter::FromIterator; use syn::parse::{discouraged::Speculative, Parse, ParseStream, Parser, Result}; @@ -10,7 +12,7 @@ impl Parse for BreakRules { fn parse(input1: ParseStream) -> Result { let nested = |input2: ParseStream| { - input1.advance_to(&input2); + input1.advance_to(input2); Ok(Self) }; nested.parse_str("") diff -Nru cargo-0.58.0/vendor/syn/tests/test_path.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_path.rs --- cargo-0.58.0/vendor/syn/tests/test_path.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_path.rs 2022-04-20 13:48:09.000000000 +0000 @@ -102,3 +102,25 @@ "###); assert!(ty.path.segments.pop().is_none()); } + +#[test] +fn parse_parenthesized_path_arguments_with_disambiguator() { + #[rustfmt::skip] + let tokens = quote!(FnOnce::() -> !); + snapshot!(tokens as Type, @r###" + Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "FnOnce", + arguments: PathArguments::Parenthesized { + output: Type( + Type::Never, + ), + }, + }, + ], + }, + } + "###); +} diff -Nru cargo-0.58.0/vendor/syn/tests/test_precedence.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_precedence.rs --- cargo-0.58.0/vendor/syn/tests/test_precedence.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_precedence.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,6 +1,13 @@ #![cfg(not(syn_disable_nightly_tests))] +#![cfg(not(miri))] #![recursion_limit = "1024"] #![feature(rustc_private)] +#![allow( + clippy::explicit_deref_methods, + clippy::manual_assert, + clippy::match_wildcard_for_single_variants, + clippy::too_many_lines +)] //! The tests in this module do the following: //! @@ -128,16 +135,16 @@ l_failed ); - passed.fetch_add(l_passed, Ordering::SeqCst); - let prev_failed = failed.fetch_add(l_failed, Ordering::SeqCst); + passed.fetch_add(l_passed, Ordering::Relaxed); + let prev_failed = failed.fetch_add(l_failed, Ordering::Relaxed); if prev_failed + l_failed >= abort_after { process::exit(1); } }); - let passed = passed.load(Ordering::SeqCst); - let failed = failed.load(Ordering::SeqCst); + let passed = passed.load(Ordering::Relaxed); + let failed = failed.load(Ordering::Relaxed); errorf!("\n===== Precedence Test Results =====\n"); errorf!("{} passed | {} failed\n", passed, failed); @@ -340,8 +347,8 @@ /// reveal the precedence of the parsed expressions, and produce a stringified /// form of the resulting expression. fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr { - use syn::fold::*; - use syn::*; + use syn::fold::{fold_expr, fold_generic_argument, fold_generic_method_argument, Fold}; + use syn::{token, Expr, ExprParen, GenericArgument, GenericMethodArgument, Pat, Stmt, Type}; struct ParenthesizeEveryExpr; impl Fold for ParenthesizeEveryExpr { @@ -417,9 +424,9 @@ /// Walk through a crate collecting all expressions we can find in it. fn collect_exprs(file: syn::File) -> Vec { - use syn::fold::*; + use syn::fold::Fold; use syn::punctuated::Punctuated; - use syn::*; + use syn::{token, Expr, ExprTuple, Path}; struct CollectExprs(Vec); impl Fold for CollectExprs { @@ -435,6 +442,11 @@ paren_token: token::Paren::default(), }) } + + fn fold_path(&mut self, path: Path) -> Path { + // Skip traversing into const generic path arguments + path + } } let mut folder = CollectExprs(vec![]); diff -Nru cargo-0.58.0/vendor/syn/tests/test_round_trip.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_round_trip.rs --- cargo-0.58.0/vendor/syn/tests/test_round_trip.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_round_trip.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,6 +1,8 @@ #![cfg(not(syn_disable_nightly_tests))] +#![cfg(not(miri))] #![recursion_limit = "1024"] #![feature(rustc_private)] +#![allow(clippy::manual_assert)] extern crate rustc_ast; extern crate rustc_errors; @@ -62,7 +64,7 @@ } }); - let failed = failed.load(Ordering::SeqCst); + let failed = failed.load(Ordering::Relaxed); if failed > 0 { panic!("{} failures", failed); } @@ -76,7 +78,7 @@ Ok(krate) => (krate, start.elapsed()), Err(msg) => { errorf!("=== {}: syn failed to parse\n{:?}\n", path.display(), msg); - let prev_failed = failed.fetch_add(1, Ordering::SeqCst); + let prev_failed = failed.fetch_add(1, Ordering::Relaxed); if prev_failed + 1 >= abort_after { process::exit(1); } @@ -91,8 +93,7 @@ let sess = ParseSess::new(FilePathMapping::empty()); let before = match librustc_parse(content, &sess) { Ok(before) => before, - Err(mut diagnostic) => { - diagnostic.cancel(); + Err(diagnostic) => { if diagnostic .message() .starts_with("file not found for module") @@ -105,6 +106,7 @@ diagnostic.message(), ); } + diagnostic.cancel(); return Err(true); } }; @@ -145,7 +147,7 @@ } }; if !equal { - let prev_failed = failed.fetch_add(1, Ordering::SeqCst); + let prev_failed = failed.fetch_add(1, Ordering::Relaxed); if prev_failed + 1 >= abort_after { process::exit(1); } diff -Nru cargo-0.58.0/vendor/syn/tests/test_size.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_size.rs --- cargo-0.58.0/vendor/syn/tests/test_size.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_size.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,7 +1,7 @@ #![cfg(target_pointer_width = "64")] use std::mem; -use syn::*; +use syn::{Expr, Item, Lit, Pat, Type}; #[test] fn test_expr_size() { diff -Nru cargo-0.58.0/vendor/syn/tests/test_stmt.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_stmt.rs --- cargo-0.58.0/vendor/syn/tests/test_stmt.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_stmt.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,7 +1,10 @@ +#![allow(clippy::non_ascii_literal)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; +use quote::quote; use std::iter::FromIterator; use syn::Stmt; @@ -72,3 +75,19 @@ }) "###); } + +#[test] +fn test_let_dot_dot() { + let tokens = quote! { + let .. = 10; + }; + + snapshot!(tokens as Stmt, @r###" + Local(Local { + pat: Pat::Rest, + init: Some(Expr::Lit { + lit: 10, + }), + }) + "###); +} diff -Nru cargo-0.58.0/vendor/syn/tests/test_ty.rs cargo-0.60.0ubuntu1/vendor/syn/tests/test_ty.rs --- cargo-0.58.0/vendor/syn/tests/test_ty.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/syn/tests/test_ty.rs 2022-04-20 13:48:09.000000000 +0000 @@ -9,6 +9,7 @@ #[test] fn test_mut_self() { syn::parse_str::("fn(mut self)").unwrap(); + syn::parse_str::("fn(mut self,)").unwrap(); syn::parse_str::("fn(mut self: ())").unwrap(); syn::parse_str::("fn(mut self: ...)").unwrap_err(); syn::parse_str::("fn(mut self: mut self)").unwrap_err(); @@ -285,3 +286,67 @@ syn::parse_str::("for<'a> dyn Trait<'a>").unwrap_err(); syn::parse_str::("dyn for<'a> 'a + Trait").unwrap_err(); } + +#[test] +fn test_trailing_plus() { + #[rustfmt::skip] + let tokens = quote!(impl Trait +); + snapshot!(tokens as Type, @r###" + Type::ImplTrait { + bounds: [ + Trait(TraitBound { + modifier: None, + path: Path { + segments: [ + PathSegment { + ident: "Trait", + arguments: None, + }, + ], + }, + }), + ], + } + "###); + + #[rustfmt::skip] + let tokens = quote!(dyn Trait +); + snapshot!(tokens as Type, @r###" + Type::TraitObject { + dyn_token: Some, + bounds: [ + Trait(TraitBound { + modifier: None, + path: Path { + segments: [ + PathSegment { + ident: "Trait", + arguments: None, + }, + ], + }, + }), + ], + } + "###); + + #[rustfmt::skip] + let tokens = quote!(Trait +); + snapshot!(tokens as Type, @r###" + Type::TraitObject { + bounds: [ + Trait(TraitBound { + modifier: None, + path: Path { + segments: [ + PathSegment { + ident: "Trait", + arguments: None, + }, + ], + }, + }), + ], + } + "###); +} diff -Nru cargo-0.58.0/vendor/tar/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/tar/.cargo-checksum.json --- cargo-0.58.0/vendor/tar/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"d6f5515d3add52e0bbdcad7b83c388bb36ba7b754dda3b5f5bc2d38640cdba5c"} \ No newline at end of file +{"files":{},"package":"4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/tar/Cargo.lock cargo-0.60.0ubuntu1/vendor/tar/Cargo.lock --- cargo-0.58.0/vendor/tar/Cargo.lock 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -4,9 +4,9 @@ [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cfg-if" @@ -16,9 +16,9 @@ [[package]] name = "filetime" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8" +checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98" dependencies = [ "cfg-if", "libc", @@ -28,9 +28,9 @@ [[package]] name = "getrandom" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if", "libc", @@ -39,9 +39,9 @@ [[package]] name = "libc" -version = "0.2.86" +version = "0.2.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c" +checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" [[package]] name = "ppv-lite86" @@ -51,9 +51,9 @@ [[package]] name = "rand" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" dependencies = [ "libc", "rand_chacha", @@ -63,9 +63,9 @@ [[package]] name = "rand_chacha" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core", @@ -73,27 +73,27 @@ [[package]] name = "rand_core" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ "getrandom", ] [[package]] name = "rand_hc" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" dependencies = [ "rand_core", ] [[package]] name = "redox_syscall" -version = "0.2.5" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ "bitflags", ] @@ -109,7 +109,7 @@ [[package]] name = "tar" -version = "0.4.37" +version = "0.4.38" dependencies = [ "filetime", "libc", diff -Nru cargo-0.58.0/vendor/tar/Cargo.toml cargo-0.60.0ubuntu1/vendor/tar/Cargo.toml --- cargo-0.58.0/vendor/tar/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -3,17 +3,16 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "tar" -version = "0.4.37" +version = "0.4.38" authors = ["Alex Crichton "] exclude = ["tests/archives/*"] description = "A Rust implementation of a TAR file reader and writer. This library does not\ncurrently handle compression, but it is abstract over all I/O readers and\nwriters. Additionally, great lengths are taken to ensure that the entire\ncontents are never required to be entirely resident in memory all at once.\n" diff -Nru cargo-0.58.0/vendor/tar/debian/patches/disable-tests.diff cargo-0.60.0ubuntu1/vendor/tar/debian/patches/disable-tests.diff --- cargo-0.58.0/vendor/tar/debian/patches/disable-tests.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/debian/patches/disable-tests.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,380 @@ +Description: Disable tests that rely on test tarballs + The test tarballs are not included in the crate on crates.io and hence are not + included in the Debian package. I figure that it is better to run some of the + tests than none of the tests. +Author: Peter Michael Green + +--- rust-tar-0.4.37.orig/tests/all.rs ++++ rust-tar-0.4.37/tests/all.rs +@@ -33,7 +33,7 @@ mod header; + + /// test that we can concatenate the simple.tar archive and extract the same entries twice when we + /// use the ignore_zeros option. +-#[test] ++/*#[test] + fn simple_concat() { + let bytes = tar!("simple.tar"); + let mut archive_bytes = Vec::new(); +@@ -76,9 +76,9 @@ fn simple_concat() { + + names + } +-} ++}*/ + +-#[test] ++/*#[test] + fn header_impls() { + let mut ar = Archive::new(Cursor::new(tar!("simple.tar"))); + let hn = Header::new_old(); +@@ -91,9 +91,9 @@ fn header_impls() { + let h2b = h2.as_bytes(); + assert!(h1b[..] == h2b[..] && h2b[..] != hnb[..]) + } +-} ++}*/ + +-#[test] ++/*#[test] + fn header_impls_missing_last_header() { + let mut ar = Archive::new(Cursor::new(tar!("simple_missing_last_header.tar"))); + let hn = Header::new_old(); +@@ -106,9 +106,9 @@ fn header_impls_missing_last_header() { + let h2b = h2.as_bytes(); + assert!(h1b[..] == h2b[..] && h2b[..] != hnb[..]) + } +-} ++}*/ + +-#[test] ++/*#[test] + fn reading_files() { + let rdr = Cursor::new(tar!("reading_files.tar")); + let mut ar = Archive::new(rdr); +@@ -127,7 +127,7 @@ fn reading_files() { + assert_eq!(s, "b\nb\nb\nb\nb\nb\nb\nb\nb\nb\nb\n"); + + assert!(entries.next().is_none()); +-} ++}*/ + + #[test] + fn writing_files() { +@@ -203,7 +203,7 @@ fn large_filename() { + assert!(entries.next().is_none()); + } + +-#[test] ++/*#[test] + fn reading_entries() { + let rdr = Cursor::new(tar!("reading_files.tar")); + let mut ar = Archive::new(rdr); +@@ -223,7 +223,7 @@ fn reading_entries() { + t!(b.read_to_string(&mut s)); + assert_eq!(s, "b\nb\nb\nb\nb\nb\nb\nb\nb\nb\nb\n"); + assert!(entries.next().is_none()); +-} ++}*/ + + fn check_dirtree(td: &TempDir) { + let dir_a = td.path().join("a"); +@@ -234,16 +234,16 @@ fn check_dirtree(td: &TempDir) { + assert!(fs::metadata(&file_c).map(|m| m.is_file()).unwrap_or(false)); + } + +-#[test] ++/*#[test] + fn extracting_directories() { + let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); + let rdr = Cursor::new(tar!("directory.tar")); + let mut ar = Archive::new(rdr); + t!(ar.unpack(td.path())); + check_dirtree(&td); +-} ++}*/ + +-#[test] ++/*#[test] + fn extracting_duplicate_file_fail() { + let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); + let path_present = td.path().join("a"); +@@ -263,9 +263,9 @@ fn extracting_duplicate_file_fail() { + "unpack() should have returned an error of kind {:?}, returned Ok", + std::io::ErrorKind::AlreadyExists + ) +-} ++}*/ + +-#[test] ++/*#[test] + fn extracting_duplicate_file_succeed() { + let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); + let path_present = td.path().join("a"); +@@ -275,9 +275,9 @@ fn extracting_duplicate_file_succeed() { + let mut ar = Archive::new(rdr); + ar.set_overwrite(true); + t!(ar.unpack(td.path())); +-} ++}*/ + +-#[test] ++/*#[test] + #[cfg(unix)] + fn extracting_duplicate_link_fail() { + let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); +@@ -298,9 +298,9 @@ fn extracting_duplicate_link_fail() { + "unpack() should have returned an error of kind {:?}, returned Ok", + std::io::ErrorKind::AlreadyExists + ) +-} ++}*/ + +-#[test] ++/*#[test] + #[cfg(unix)] + fn extracting_duplicate_link_succeed() { + let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); +@@ -311,9 +311,9 @@ fn extracting_duplicate_link_succeed() { + let mut ar = Archive::new(rdr); + ar.set_overwrite(true); + t!(ar.unpack(td.path())); +-} ++}*/ + +-#[test] ++/*#[test] + #[cfg(all(unix, feature = "xattr"))] + fn xattrs() { + // If /tmp is a tmpfs, xattr will fail +@@ -326,9 +326,9 @@ fn xattrs() { + + let val = xattr::get(td.path().join("a/b"), "user.pax.flags").unwrap(); + assert_eq!(val.unwrap(), "epm".as_bytes()); +-} ++}*/ + +-#[test] ++/*#[test] + #[cfg(all(unix, feature = "xattr"))] + fn no_xattrs() { + // If /tmp is a tmpfs, xattr will fail +@@ -343,7 +343,7 @@ fn no_xattrs() { + xattr::get(td.path().join("a/b"), "user.pax.flags").unwrap(), + None + ); +-} ++}*/ + + #[test] + fn writing_and_extracting_directories() { +@@ -436,7 +436,7 @@ fn append_dir_all_does_not_work_on_non_d + assert!(result.is_err()); + } + +-#[test] ++/*#[test] + fn extracting_duplicate_dirs() { + let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); + let rdr = Cursor::new(tar!("duplicate_dirs.tar")); +@@ -445,7 +445,7 @@ fn extracting_duplicate_dirs() { + + let some_dir = td.path().join("some_dir"); + assert!(fs::metadata(&some_dir).map(|m| m.is_dir()).unwrap_or(false)); +-} ++}*/ + + #[test] + fn unpack_old_style_bsd_dir() { +@@ -584,7 +584,7 @@ fn extracting_malicious_tarball() { + .unwrap_or(false)); + } + +-#[test] ++/*#[test] + fn octal_spaces() { + let rdr = Cursor::new(tar!("spaces.tar")); + let mut ar = Archive::new(rdr); +@@ -596,7 +596,7 @@ fn octal_spaces() { + assert_eq!(entry.header().size().unwrap(), 2); + assert_eq!(entry.header().mtime().unwrap(), 0o12440016664); + assert_eq!(entry.header().cksum().unwrap(), 0o4253); +-} ++}*/ + + #[test] + fn extracting_malformed_tar_null_blocks() { +@@ -621,15 +621,15 @@ fn extracting_malformed_tar_null_blocks( + assert!(ar.unpack(td.path()).is_ok()); + } + +-#[test] ++/*#[test] + fn empty_filename() { + let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); + let rdr = Cursor::new(tar!("empty_filename.tar")); + let mut ar = Archive::new(rdr); + assert!(ar.unpack(td.path()).is_ok()); +-} ++}*/ + +-#[test] ++/*#[test] + fn file_times() { + let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); + let rdr = Cursor::new(tar!("file_times.tar")); +@@ -643,7 +643,7 @@ fn file_times() { + assert_eq!(mtime.nanoseconds(), 0); + assert_eq!(atime.unix_seconds(), 1000000000); + assert_eq!(atime.nanoseconds(), 0); +-} ++}*/ + + #[test] + fn zero_file_times() { +@@ -713,7 +713,7 @@ fn nul_bytes_in_path() { + assert!(err.to_string().contains("contains a nul byte")); + } + +-#[test] ++/*#[test] + fn links() { + let mut ar = Archive::new(Cursor::new(tar!("link.tar"))); + let mut entries = t!(ar.entries()); +@@ -724,9 +724,9 @@ fn links() { + ); + let other = t!(entries.next().unwrap()); + assert!(t!(other.header().link_name()).is_none()); +-} ++}*/ + +-#[test] ++/*#[test] + #[cfg(unix)] // making symlinks on windows is hard + fn unpack_links() { + let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); +@@ -740,9 +740,9 @@ fn unpack_links() { + Path::new("file") + ); + t!(File::open(td.path().join("lnk"))); +-} ++}*/ + +-#[test] ++/*#[test] + fn pax_size() { + let mut ar = Archive::new(tar!("pax_size.tar")); + let mut entries = t!(ar.entries()); +@@ -760,9 +760,9 @@ fn pax_size() { + + assert_eq!(entry.header().size().unwrap(), 0); + assert_eq!(entry.size(), 4); +-} ++}*/ + +-#[test] ++/*#[test] + fn pax_simple() { + let mut ar = Archive::new(tar!("pax.tar")); + let mut entries = t!(ar.entries()); +@@ -780,18 +780,18 @@ fn pax_simple() { + assert_eq!(second.value(), Ok("1453251915.24892486")); + assert_eq!(third.key(), Ok("ctime")); + assert_eq!(third.value(), Ok("1453146164.953123768")); +-} ++}*/ + +-#[test] ++/*#[test] + fn pax_path() { + let mut ar = Archive::new(tar!("pax2.tar")); + let mut entries = t!(ar.entries()); + + let first = t!(entries.next().unwrap()); + assert!(first.path().unwrap().ends_with("aaaaaaaaaaaaaaa")); +-} ++}*/ + +-#[test] ++/*#[test] + fn pax_linkpath() { + let mut ar = Archive::new(tar!("pax2.tar")); + let mut links = t!(ar.entries()).skip(3).take(2); +@@ -805,7 +805,7 @@ fn pax_linkpath() { + let link_name = long_hardlink.link_name().unwrap().unwrap(); + assert!(link_name.to_str().unwrap().len() > 99); + assert!(link_name.ends_with("ccccccccccccccc")); +-} ++}*/ + + #[test] + fn long_name_trailing_nul() { +@@ -880,7 +880,7 @@ fn encoded_long_name_has_trailing_nul() + assert!(header_name.starts_with(b"././@LongLink\x00")); + } + +-#[test] ++/*#[test] + fn reading_sparse() { + let rdr = Cursor::new(tar!("sparse.tar")); + let mut ar = Archive::new(rdr); +@@ -928,9 +928,9 @@ fn reading_sparse() { + assert!(s[0x2fa0 + 6..0x4000].chars().all(|x| x == '\u{0}')); + + assert!(entries.next().is_none()); +-} ++}*/ + +-#[test] ++/*#[test] + fn extract_sparse() { + let rdr = Cursor::new(tar!("sparse.tar")); + let mut ar = Archive::new(rdr); +@@ -969,9 +969,9 @@ fn extract_sparse() { + assert!(s[0x1000 + 6..0x2fa0].chars().all(|x| x == '\u{0}')); + assert_eq!(&s[0x2fa0..0x2fa0 + 6], "world\n"); + assert!(s[0x2fa0 + 6..0x4000].chars().all(|x| x == '\u{0}')); +-} ++}*/ + +-#[test] ++/*#[test] + fn sparse_with_trailing() { + let rdr = Cursor::new(tar!("sparse-1.tar")); + let mut ar = Archive::new(rdr); +@@ -983,7 +983,7 @@ fn sparse_with_trailing() { + assert_eq!(&s[..0xc], "0MB through\n"); + assert!(s[0xc..0x100_000].chars().all(|x| x == '\u{0}')); + assert_eq!(&s[0x100_000..], "1MB through\n"); +-} ++}*/ + + #[test] + fn path_separators() { +@@ -1153,15 +1153,15 @@ fn tar_directory_containing_symlink_to_d + ar.finish().unwrap(); + } + +-#[test] ++/*#[test] + fn long_path() { + let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); + let rdr = Cursor::new(tar!("7z_long_path.tar")); + let mut ar = Archive::new(rdr); + assert!(ar.unpack(td.path()).is_ok()); +-} ++}*/ + +-#[test] ++/*#[test] + fn unpack_path_larger_than_windows_max_path() { + let dir_name = "iamaprettylongnameandtobepreciseiam91characterslongwhichsomethinkisreallylongandothersdonot"; + // 183 character directory name +@@ -1172,7 +1172,7 @@ fn unpack_path_larger_than_windows_max_p + let mut ar = Archive::new(rdr); + // should unpack path greater than windows MAX_PATH length of 260 characters + assert!(ar.unpack(td.path()).is_ok()); +-} ++}*/ + + #[test] + fn append_long_multibyte() { diff -Nru cargo-0.58.0/vendor/tar/debian/patches/series cargo-0.60.0ubuntu1/vendor/tar/debian/patches/series --- cargo-0.58.0/vendor/tar/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/debian/patches/series 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1 @@ +test-skip-loop0-if-nonexistent.diff diff -Nru cargo-0.58.0/vendor/tar/debian/patches/test-skip-loop0-if-nonexistent.diff cargo-0.60.0ubuntu1/vendor/tar/debian/patches/test-skip-loop0-if-nonexistent.diff --- cargo-0.58.0/vendor/tar/debian/patches/test-skip-loop0-if-nonexistent.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/debian/patches/test-skip-loop0-if-nonexistent.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,17 @@ +Description: Skip using loop0 if it doesn't exist (apparently it doesn't on Debian CI) +Author: Peter Michael Green + +--- rust-tar-0.4.37.orig/tests/all.rs ++++ rust-tar-0.4.37/tests/all.rs +@@ -1240,7 +1240,10 @@ fn tar_directory_containing_special_file + // unfortunately, block device file cannot be created by non-root users + // as a substitute, just test the file that exists on most Unix systems + t!(env::set_current_dir("/dev/")); +- t!(ar.append_path("loop0")); ++ // debian CI apprently doesn't have loop0, skip testing it if it doesn't exist. ++ if std::path::Path::new("loop0").exists() { ++ t!(ar.append_path("loop0")); ++ } + // CI systems seem to have issues with creating a chr device + t!(ar.append_path("null")); + t!(ar.finish()); diff -Nru cargo-0.58.0/vendor/tar/src/archive.rs cargo-0.60.0ubuntu1/vendor/tar/src/archive.rs --- cargo-0.58.0/vendor/tar/src/archive.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/src/archive.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,8 +1,9 @@ use std::cell::{Cell, RefCell}; use std::cmp; +use std::convert::TryFrom; use std::fs; -use std::io; use std::io::prelude::*; +use std::io::{self, SeekFrom}; use std::marker; use std::path::Path; @@ -35,8 +36,12 @@ _ignored: marker::PhantomData<&'a Archive>, } +trait SeekRead: Read + Seek {} +impl SeekRead for R {} + struct EntriesFields<'a> { archive: &'a Archive, + seekable_archive: Option<&'a Archive>, next: u64, done: bool, raw: bool, @@ -71,7 +76,7 @@ /// corrupted. pub fn entries(&mut self) -> io::Result> { let me: &mut Archive = self; - me._entries().map(|fields| Entries { + me._entries(None).map(|fields| Entries { fields: fields, _ignored: marker::PhantomData, }) @@ -143,8 +148,29 @@ } } -impl<'a> Archive { - fn _entries(&mut self) -> io::Result { +impl Archive { + /// Construct an iterator over the entries in this archive for a seekable + /// reader. Seek will be used to efficiently skip over file contents. + /// + /// Note that care must be taken to consider each entry within an archive in + /// sequence. If entries are processed out of sequence (from what the + /// iterator returns), then the contents read for each entry may be + /// corrupted. + pub fn entries_with_seek(&mut self) -> io::Result> { + let me: &Archive = self; + let me_seekable: &Archive = self; + me._entries(Some(me_seekable)).map(|fields| Entries { + fields: fields, + _ignored: marker::PhantomData, + }) + } +} + +impl Archive { + fn _entries<'a>( + &'a self, + seekable_archive: Option<&'a Archive>, + ) -> io::Result> { if self.inner.pos.get() != 0 { return Err(other( "cannot call entries unless archive is at \ @@ -153,6 +179,7 @@ } Ok(EntriesFields { archive: self, + seekable_archive, done: false, next: 0, raw: false, @@ -162,7 +189,7 @@ fn _unpack(&mut self, dst: &Path) -> io::Result<()> { if dst.symlink_metadata().is_err() { fs::create_dir_all(&dst) - .map_err(|e| TarError::new(&format!("failed to create `{}`", dst.display()), e))?; + .map_err(|e| TarError::new(format!("failed to create `{}`", dst.display()), e))?; } // Canonicalizing the dst directory will prepend the path with '\\?\' @@ -176,7 +203,7 @@ // descendants), to ensure that directory permissions do not interfer with descendant // extraction. let mut directories = Vec::new(); - for entry in self._entries()? { + for entry in self._entries(None)? { let mut file = entry.map_err(|e| TarError::new("failed to iterate over archive", e))?; if file.header().entry_type() == crate::EntryType::Directory { directories.push(file); @@ -190,19 +217,6 @@ Ok(()) } - - fn skip(&self, mut amt: u64) -> io::Result<()> { - let mut buf = [0u8; 4096 * 8]; - while amt > 0 { - let n = cmp::min(amt, buf.len() as u64); - let n = (&self.inner).read(&mut buf[..n as usize])?; - if n == 0 { - return Err(other("unexpected EOF during skip")); - } - amt -= n as u64; - } - Ok(()) - } } impl<'a, R: Read> Entries<'a, R> { @@ -241,7 +255,7 @@ loop { // Seek to the start of the next header in the archive let delta = self.next - self.archive.inner.pos.get(); - self.archive.skip(delta)?; + self.skip(delta)?; // EOF is an indicator that we are at the end of the archive. if !try_read_all(&mut &self.archive.inner, header.as_mut_bytes())? { @@ -298,8 +312,13 @@ // Store where the next entry is, rounding up by 512 bytes (the size of // a header); - let size = (size + 511) & !(512 - 1); - self.next += size; + let size = size + .checked_add(511) + .ok_or_else(|| other("size overflow"))?; + self.next = self + .next + .checked_add(size & !(512 - 1)) + .ok_or_else(|| other("size overflow"))?; Ok(Some(ret.into_entry())) } @@ -476,6 +495,26 @@ } Ok(()) } + + fn skip(&mut self, mut amt: u64) -> io::Result<()> { + if let Some(seekable_archive) = self.seekable_archive { + let pos = io::SeekFrom::Current( + i64::try_from(amt).map_err(|_| other("seek position out of bounds"))?, + ); + (&seekable_archive.inner).seek(pos)?; + } else { + let mut buf = [0u8; 4096 * 8]; + while amt > 0 { + let n = cmp::min(amt, buf.len() as u64); + let n = (&self.archive.inner).read(&mut buf[..n as usize])?; + if n == 0 { + return Err(other("unexpected EOF during skip")); + } + amt -= n as u64; + } + } + Ok(()) + } } impl<'a> Iterator for EntriesFields<'a> { @@ -502,10 +541,17 @@ impl<'a, R: ?Sized + Read> Read for &'a ArchiveInner { fn read(&mut self, into: &mut [u8]) -> io::Result { - self.obj.borrow_mut().read(into).map(|i| { - self.pos.set(self.pos.get() + i as u64); - i - }) + let i = self.obj.borrow_mut().read(into)?; + self.pos.set(self.pos.get() + i as u64); + Ok(i) + } +} + +impl<'a, R: ?Sized + Seek> Seek for &'a ArchiveInner { + fn seek(&mut self, pos: SeekFrom) -> io::Result { + let pos = self.obj.borrow_mut().seek(pos)?; + self.pos.set(pos); + Ok(pos) } } diff -Nru cargo-0.58.0/vendor/tar/src/builder.rs cargo-0.60.0ubuntu1/vendor/tar/src/builder.rs --- cargo-0.58.0/vendor/tar/src/builder.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/src/builder.rs 2022-04-20 13:48:09.000000000 +0000 @@ -162,6 +162,54 @@ self.append(&header, data) } + /// Adds a new link (symbolic or hard) entry to this archive with the specified path and target. + /// + /// This function is similar to [`Self::append_data`] which supports long filenames, + /// but also supports long link targets using GNU extensions if necessary. + /// You must set the entry type to either [`EntryType::Link`] or [`EntryType::Symlink`]. + /// The `set_cksum` method will be invoked after setting the path. No other metadata in the + /// header will be modified. + /// + /// If you are intending to use GNU extensions, you must use this method over calling + /// [`Header::set_link_name`] because that function will fail on long links. + /// + /// Similar constraints around the position of the archive and completion + /// apply as with [`Self::append_data`]. + /// + /// # Errors + /// + /// This function will return an error for any intermittent I/O error which + /// occurs when either reading or writing. + /// + /// # Examples + /// + /// ``` + /// use tar::{Builder, Header, EntryType}; + /// + /// let mut ar = Builder::new(Vec::new()); + /// let mut header = Header::new_gnu(); + /// header.set_username("foo"); + /// header.set_entry_type(EntryType::Symlink); + /// header.set_size(0); + /// ar.append_link(&mut header, "really/long/path/to/foo", "other/really/long/target").unwrap(); + /// let data = ar.into_inner().unwrap(); + /// ``` + pub fn append_link, T: AsRef>( + &mut self, + header: &mut Header, + path: P, + target: T, + ) -> io::Result<()> { + self._append_link(header, path.as_ref(), target.as_ref()) + } + + fn _append_link(&mut self, header: &mut Header, path: &Path, target: &Path) -> io::Result<()> { + prepare_header_path(self.get_mut(), header, path)?; + prepare_header_link(self.get_mut(), header, target)?; + header.set_cksum(); + self.append(&header, std::io::empty()) + } + /// Adds a file on the local filesystem to this archive. /// /// This function will open the file specified by `path` and insert the file diff -Nru cargo-0.58.0/vendor/tar/src/entry.rs cargo-0.60.0ubuntu1/vendor/tar/src/entry.rs --- cargo-0.58.0/vendor/tar/src/entry.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/src/entry.rs 2022-04-20 13:48:09.000000000 +0000 @@ -13,7 +13,6 @@ use crate::error::TarError; use crate::header::bytes2path; use crate::other; -use crate::pax::pax_extensions; use crate::{Archive, Header, PaxExtensions}; /// A read-only view into an entry of an archive. @@ -300,7 +299,7 @@ } None => { if let Some(ref pax) = self.pax_extensions { - let pax = pax_extensions(pax) + let pax = PaxExtensions::new(pax) .filter_map(|f| f.ok()) .find(|f| f.key_bytes() == b"path") .map(|f| f.value_bytes()); @@ -336,7 +335,7 @@ } None => { if let Some(ref pax) = self.pax_extensions { - let pax = pax_extensions(pax) + let pax = PaxExtensions::new(pax) .filter_map(|f| f.ok()) .find(|f| f.key_bytes() == b"linkpath") .map(|f| f.value_bytes()); @@ -358,7 +357,9 @@ } self.pax_extensions = Some(self.read_all()?); } - Ok(Some(pax_extensions(self.pax_extensions.as_ref().unwrap()))) + Ok(Some(PaxExtensions::new( + self.pax_extensions.as_ref().unwrap(), + ))) } fn unpack_in(&mut self, dst: &Path) -> io::Result { @@ -379,7 +380,7 @@ { let path = self.path().map_err(|e| { TarError::new( - &format!("invalid path in entry header: {}", self.path_lossy()), + format!("invalid path in entry header: {}", self.path_lossy()), e, ) })?; @@ -414,12 +415,12 @@ }; self.ensure_dir_created(&dst, parent) - .map_err(|e| TarError::new(&format!("failed to create `{}`", parent.display()), e))?; + .map_err(|e| TarError::new(format!("failed to create `{}`", parent.display()), e))?; let canon_target = self.validate_inside_dst(&dst, parent)?; self.unpack(Some(&canon_target), &file_dst) - .map_err(|e| TarError::new(&format!("failed to unpack `{}`", file_dst.display()), e))?; + .map_err(|e| TarError::new(format!("failed to unpack `{}`", file_dst.display()), e))?; Ok(true) } @@ -607,7 +608,7 @@ .map_err(|e| { let header = self.header.path_bytes(); TarError::new( - &format!( + format!( "failed to unpack `{}` into `{}`", String::from_utf8_lossy(&header), dst.display() @@ -627,7 +628,7 @@ let mtime = if mtime == 0 { 1 } else { mtime }; let mtime = FileTime::from_unix_time(mtime as i64, 0); filetime::set_file_handle_times(&f, Some(mtime), Some(mtime)).map_err(|e| { - TarError::new(&format!("failed to set mtime for `{}`", dst.display()), e) + TarError::new(format!("failed to set mtime for `{}`", dst.display()), e) })?; } } @@ -647,7 +648,7 @@ ) -> Result<(), TarError> { _set_perms(dst, f, mode, preserve).map_err(|e| { TarError::new( - &format!( + format!( "failed to set permissions to {:o} \ for `{}`", mode, @@ -735,7 +736,7 @@ for (key, value) in exts { xattr::set(dst, key, value).map_err(|e| { TarError::new( - &format!( + format!( "failed to set extended \ attributes to {}. \ Xattrs: key={:?}, value={:?}.", @@ -794,7 +795,7 @@ })?; if !canon_parent.starts_with(&canon_target) { let err = TarError::new( - &format!( + format!( "trying to unpack outside of destination path: {}", canon_target.display() ), diff -Nru cargo-0.58.0/vendor/tar/src/error.rs cargo-0.60.0ubuntu1/vendor/tar/src/error.rs --- cargo-0.58.0/vendor/tar/src/error.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/src/error.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,17 +1,18 @@ +use std::borrow::Cow; use std::error; use std::fmt; use std::io::{self, Error}; #[derive(Debug)] pub struct TarError { - desc: String, + desc: Cow<'static, str>, io: io::Error, } impl TarError { - pub fn new(desc: &str, err: Error) -> TarError { + pub fn new(desc: impl Into>, err: Error) -> TarError { TarError { - desc: desc.to_string(), + desc: desc.into(), io: err, } } diff -Nru cargo-0.58.0/vendor/tar/src/header.rs cargo-0.60.0ubuntu1/vendor/tar/src/header.rs --- cargo-0.58.0/vendor/tar/src/header.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/src/header.rs 2022-04-20 13:48:09.000000000 +0000 @@ -420,6 +420,8 @@ /// in the appropriate format. May fail if the link name is too long or if /// the path specified is not Unicode and this is a Windows platform. Will /// strip out any "." path component, which signifies the current directory. + /// + /// To use GNU long link names, prefer instead [`crate::Builder::append_link`]. pub fn set_link_name>(&mut self, p: P) -> io::Result<()> { self._set_link_name(p.as_ref()) } @@ -433,6 +435,18 @@ }) } + /// Sets the link name for this header without any transformation. + /// + /// This function is like [`Self::set_link_name`] but accepts an arbitrary byte array. + /// Hence it will not perform any canonicalization, such as replacing duplicate `//` with `/`. + pub fn set_link_name_literal>(&mut self, p: P) -> io::Result<()> { + self._set_link_name_literal(p.as_ref()) + } + + fn _set_link_name_literal(&mut self, bytes: &[u8]) -> io::Result<()> { + copy_into(&mut self.as_old_mut().linkname, bytes) + } + /// Returns the mode bits for this file /// /// May return an error if the field is corrupted. @@ -741,8 +755,9 @@ // // We just need things to be deterministic here so just pick // something that isn't zero. This time, chosen after careful - // deliberation, corresponds to Nov 29, 1973. - self.set_mtime(123456789); + // deliberation, corresponds to Jul 23, 2006 -- the date of the + // first commit for what would become Rust. + self.set_mtime(1153704088); self.set_uid(0); self.set_gid(0); diff -Nru cargo-0.58.0/vendor/tar/src/pax.rs cargo-0.60.0ubuntu1/vendor/tar/src/pax.rs --- cargo-0.58.0/vendor/tar/src/pax.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/src/pax.rs 2022-04-20 13:48:09.000000000 +0000 @@ -12,23 +12,26 @@ data: slice::Split<'entry, u8, fn(&u8) -> bool>, } +impl<'entry> PaxExtensions<'entry> { + /// Create new pax extensions iterator from the given entry data. + pub fn new(a: &'entry [u8]) -> Self { + fn is_newline(a: &u8) -> bool { + *a == b'\n' + } + PaxExtensions { + data: a.split(is_newline), + } + } +} + /// A key/value pair corresponding to a pax extension. pub struct PaxExtension<'entry> { key: &'entry [u8], value: &'entry [u8], } -pub fn pax_extensions(a: &[u8]) -> PaxExtensions { - fn is_newline(a: &u8) -> bool { - *a == b'\n' - } - PaxExtensions { - data: a.split(is_newline), - } -} - pub fn pax_extensions_size(a: &[u8]) -> Option { - for extension in pax_extensions(a) { + for extension in PaxExtensions::new(a) { let current_extension = match extension { Ok(ext) => ext, Err(_) => return None, diff -Nru cargo-0.58.0/vendor/tar/tests/all.rs cargo-0.60.0ubuntu1/vendor/tar/tests/all.rs --- cargo-0.58.0/vendor/tar/tests/all.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tar/tests/all.rs 2022-04-20 13:48:09.000000000 +0000 @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf}; use filetime::FileTime; -use tar::{Archive, Builder, EntryType, Header, HeaderMode}; +use tar::{Archive, Builder, Entries, EntryType, Header, HeaderMode}; use tempfile::{Builder as TempBuilder, TempDir}; macro_rules! t { @@ -203,11 +203,7 @@ assert!(entries.next().is_none()); } -#[test] -fn reading_entries() { - let rdr = Cursor::new(tar!("reading_files.tar")); - let mut ar = Archive::new(rdr); - let mut entries = t!(ar.entries()); +fn reading_entries_common(mut entries: Entries) { let mut a = t!(entries.next().unwrap()); assert_eq!(&*a.header().path_bytes(), b"a"); let mut s = String::new(); @@ -216,8 +212,8 @@ s.truncate(0); t!(a.read_to_string(&mut s)); assert_eq!(s, ""); - let mut b = t!(entries.next().unwrap()); + let mut b = t!(entries.next().unwrap()); assert_eq!(&*b.header().path_bytes(), b"b"); s.truncate(0); t!(b.read_to_string(&mut s)); @@ -225,6 +221,67 @@ assert!(entries.next().is_none()); } +#[test] +fn reading_entries() { + let rdr = Cursor::new(tar!("reading_files.tar")); + let mut ar = Archive::new(rdr); + reading_entries_common(t!(ar.entries())); +} + +#[test] +fn reading_entries_with_seek() { + let rdr = Cursor::new(tar!("reading_files.tar")); + let mut ar = Archive::new(rdr); + reading_entries_common(t!(ar.entries_with_seek())); +} + +struct LoggingReader { + inner: R, + read_bytes: u64, +} + +impl LoggingReader { + fn new(reader: R) -> LoggingReader { + LoggingReader { + inner: reader, + read_bytes: 0, + } + } +} + +impl Read for LoggingReader { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + self.inner.read(buf).map(|i| { + self.read_bytes += i as u64; + i + }) + } +} + +impl Seek for LoggingReader { + fn seek(&mut self, pos: io::SeekFrom) -> io::Result { + self.inner.seek(pos) + } +} + +#[test] +fn skipping_entries_with_seek() { + let mut reader = LoggingReader::new(Cursor::new(tar!("reading_files.tar"))); + let mut ar_reader = Archive::new(&mut reader); + let files: Vec<_> = t!(ar_reader.entries()) + .map(|entry| entry.unwrap().path().unwrap().to_path_buf()) + .collect(); + + let mut seekable_reader = LoggingReader::new(Cursor::new(tar!("reading_files.tar"))); + let mut ar_seekable_reader = Archive::new(&mut seekable_reader); + let files_seekable: Vec<_> = t!(ar_seekable_reader.entries_with_seek()) + .map(|entry| entry.unwrap().path().unwrap().to_path_buf()) + .collect(); + + assert!(files == files_seekable); + assert!(seekable_reader.read_bytes < reader.read_bytes); +} + fn check_dirtree(td: &TempDir) { let dir_a = td.path().join("a"); let dir_b = td.path().join("a/b"); @@ -858,6 +915,49 @@ } #[test] +fn long_linkname_gnu() { + for t in [tar::EntryType::Symlink, tar::EntryType::Link] { + let mut b = Builder::new(Vec::::new()); + let mut h = Header::new_gnu(); + h.set_entry_type(t); + h.set_size(0); + let path = "usr/lib/.build-id/05/159ed904e45ff5100f7acd3d3b99fa7e27e34f"; + let target = "../../../../usr/lib64/qt5/plugins/wayland-graphics-integration-server/libqt-wayland-compositor-xcomposite-egl.so"; + t!(b.append_link(&mut h, path, target)); + + let contents = t!(b.into_inner()); + let mut a = Archive::new(&contents[..]); + + let e = &t!(t!(a.entries()).next().unwrap()); + assert_eq!(e.header().entry_type(), t); + assert_eq!(e.path().unwrap().to_str().unwrap(), path); + assert_eq!(e.link_name().unwrap().unwrap().to_str().unwrap(), target); + } +} + +#[test] +fn linkname_literal() { + for t in [tar::EntryType::Symlink, tar::EntryType::Link] { + let mut b = Builder::new(Vec::::new()); + let mut h = Header::new_gnu(); + h.set_entry_type(t); + h.set_size(0); + let path = "usr/lib/systemd/systemd-sysv-install"; + let target = "../../..//sbin/chkconfig"; + h.set_link_name_literal(target).unwrap(); + t!(b.append_data(&mut h, path, std::io::empty())); + + let contents = t!(b.into_inner()); + let mut a = Archive::new(&contents[..]); + + let e = &t!(t!(a.entries()).next().unwrap()); + assert_eq!(e.header().entry_type(), t); + assert_eq!(e.path().unwrap().to_str().unwrap(), path); + assert_eq!(e.link_name().unwrap().unwrap().to_str().unwrap(), target); + } +} + +#[test] fn encoded_long_name_has_trailing_nul() { let td = t!(TempBuilder::new().prefix("tar-rs").tempdir()); let path = td.path().join("foo"); @@ -1240,8 +1340,51 @@ // unfortunately, block device file cannot be created by non-root users // as a substitute, just test the file that exists on most Unix systems t!(env::set_current_dir("/dev/")); - t!(ar.append_path("loop0")); + // debian CI apprently doesn't have loop0, skip testing it if it doesn't exist. + if std::path::Path::new("loop0").exists() { + t!(ar.append_path("loop0")); + } // CI systems seem to have issues with creating a chr device t!(ar.append_path("null")); t!(ar.finish()); } + +#[test] +fn header_size_overflow() { + // maximal file size doesn't overflow anything + let mut ar = Builder::new(Vec::new()); + let mut header = Header::new_gnu(); + header.set_size(u64::MAX); + header.set_cksum(); + ar.append(&mut header, "x".as_bytes()).unwrap(); + let result = t!(ar.into_inner()); + let mut ar = Archive::new(&result[..]); + let mut e = ar.entries().unwrap(); + let err = e.next().unwrap().err().unwrap(); + assert!( + err.to_string().contains("size overflow"), + "bad error: {}", + err + ); + + // back-to-back entries that would overflow also don't panic + let mut ar = Builder::new(Vec::new()); + let mut header = Header::new_gnu(); + header.set_size(1_000); + header.set_cksum(); + ar.append(&mut header, &[0u8; 1_000][..]).unwrap(); + let mut header = Header::new_gnu(); + header.set_size(u64::MAX - 513); + header.set_cksum(); + ar.append(&mut header, "x".as_bytes()).unwrap(); + let result = t!(ar.into_inner()); + let mut ar = Archive::new(&result[..]); + let mut e = ar.entries().unwrap(); + e.next().unwrap().unwrap(); + let err = e.next().unwrap().err().unwrap(); + assert!( + err.to_string().contains("size overflow"), + "bad error: {}", + err + ); +} diff -Nru cargo-0.58.0/vendor/tempfile/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/tempfile/.cargo-checksum.json --- cargo-0.58.0/vendor/tempfile/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"} \ No newline at end of file +{"files":{},"package":"5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/tempfile/Cargo.toml cargo-0.60.0ubuntu1/vendor/tempfile/Cargo.toml --- cargo-0.58.0/vendor/tempfile/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -3,17 +3,16 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "tempfile" -version = "3.2.0" +version = "3.3.0" authors = ["Steven Allen ", "The Rust Project Developers", "Ashley Mannix ", "Jason White "] exclude = ["/.travis.yml", "/appveyor.yml"] description = "A library for managing temporary files and directories." @@ -25,15 +24,20 @@ [dependencies.cfg-if] version = "1" -[dependencies.rand] -version = "0.8" +[dependencies.fastrand] +version = "1.6.0" [dependencies.remove_dir_all] version = "0.5" -[target."cfg(target_os = \"redox\")".dependencies.redox_syscall] -version = "0.2" -[target."cfg(unix)".dependencies.libc] +[dev-dependencies.doc-comment] +version = "0.3" + +[features] +nightly = [] +[target."cfg(any(unix, target_os = \"wasi\"))".dependencies.libc] version = "0.2.27" +[target."cfg(target_os = \"redox\")".dependencies.redox_syscall] +version = "0.2.9" [target."cfg(windows)".dependencies.winapi] version = "0.3" features = ["fileapi", "handleapi", "winbase"] diff -Nru cargo-0.58.0/vendor/tempfile/debian/patches/relax-dep.diff cargo-0.60.0ubuntu1/vendor/tempfile/debian/patches/relax-dep.diff --- cargo-0.58.0/vendor/tempfile/debian/patches/relax-dep.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/debian/patches/relax-dep.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,13 @@ +Index: tempfile/Cargo.toml +=================================================================== +--- tempfile.orig/Cargo.toml ++++ tempfile/Cargo.toml +@@ -31,7 +31,7 @@ version = "0.7" + [dependencies.remove_dir_all] + version = "0.5" + [target."cfg(target_os = \"redox\")".dependencies.redox_syscall] +-version = "0.2" ++version = ">= 0.2, < 0.3" + [target."cfg(unix)".dependencies.libc] + version = "0.2.27" + [target."cfg(windows)".dependencies.winapi] diff -Nru cargo-0.58.0/vendor/tempfile/NEWS cargo-0.60.0ubuntu1/vendor/tempfile/NEWS --- cargo-0.58.0/vendor/tempfile/NEWS 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/NEWS 2022-04-20 13:48:09.000000000 +0000 @@ -1,3 +1,18 @@ +3.3.0 +===== + +Features: + +* Replace rand with fastrand for a significantly smaller dependency tree. Cryptographic randomness + isn't necessary for temporary file names, and isn't all that helpful either. +* Add limited WASI support. +* Add a function to extract the inner data from a `SpooledTempFile`. + +Bug Fixes: + +* Make it possible to persist unnamed temporary files on linux by removing the `O_EXCL` flag. +* Fix redox minimum crate version. + 3.2.0 ===== diff -Nru cargo-0.58.0/vendor/tempfile/README.md cargo-0.60.0ubuntu1/vendor/tempfile/README.md --- cargo-0.58.0/vendor/tempfile/README.md 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -2,8 +2,7 @@ ======== [![Crate](https://img.shields.io/crates/v/tempfile.svg)](https://crates.io/crates/tempfile) -[![Build Status](https://travis-ci.org/Stebalien/tempfile.svg?branch=master)](https://travis-ci.org/Stebalien/tempfile) -[![Build status](https://ci.appveyor.com/api/projects/status/5q00b8rvvg46i5tf/branch/master?svg=true)](https://ci.appveyor.com/project/Stebalien/tempfile/branch/master) +[![Build Status](https://github.com/Stebalien/tempfile/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Stebalien/tempfile/actions/workflows/ci.yml?query=branch%3Amaster) A secure, cross-platform, temporary file library for Rust. In addition to creating temporary files, this library also allows users to securely open multiple diff -Nru cargo-0.58.0/vendor/tempfile/src/dir.rs cargo-0.60.0ubuntu1/vendor/tempfile/src/dir.rs --- cargo-0.58.0/vendor/tempfile/src/dir.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/src/dir.rs 2022-04-20 13:48:09.000000000 +0000 @@ -9,6 +9,7 @@ // except according to those terms. use remove_dir_all::remove_dir_all; +use std::mem; use std::path::{self, Path, PathBuf}; use std::{fmt, fs, io}; @@ -192,7 +193,7 @@ /// [`std::fs`]: http://doc.rust-lang.org/std/fs/index.html /// [`std::process::exit()`]: http://doc.rust-lang.org/std/process/fn.exit.html pub struct TempDir { - path: Option, + path: Box, } impl TempDir { @@ -292,7 +293,7 @@ /// # } /// ``` pub fn path(&self) -> &path::Path { - self.path.as_ref().unwrap() + self.path.as_ref() } /// Persist the temporary directory to disk, returning the [`PathBuf`] where it is located. @@ -322,8 +323,13 @@ /// # Ok(()) /// # } /// ``` - pub fn into_path(mut self) -> PathBuf { - self.path.take().unwrap() + pub fn into_path(self) -> PathBuf { + // Prevent the Drop impl from being called. + let mut this = mem::ManuallyDrop::new(self); + + // replace this.path with an empty Box, since an empty Box does not + // allocate any heap memory. + mem::replace(&mut this.path, PathBuf::new().into_boxed_path()).into() } /// Closes and removes the temporary directory, returning a `Result`. @@ -369,8 +375,12 @@ pub fn close(mut self) -> io::Result<()> { let result = remove_dir_all(self.path()).with_err_path(|| self.path()); - // Prevent the Drop impl from removing the dir a second time. - self.path = None; + // Set self.path to empty Box to release the memory, since an empty + // Box does not allocate any heap memory. + self.path = PathBuf::new().into_boxed_path(); + + // Prevent the Drop impl from being called. + mem::forget(self); result } @@ -392,15 +402,14 @@ impl Drop for TempDir { fn drop(&mut self) { - // Path is `None` if `close()` or `into_path()` has been called. - if let Some(ref p) = self.path { - let _ = remove_dir_all(p); - } + let _ = remove_dir_all(self.path()); } } pub(crate) fn create(path: PathBuf) -> io::Result { fs::create_dir(&path) .with_err_path(|| &path) - .map(|_| TempDir { path: Some(path) }) + .map(|_| TempDir { + path: path.into_boxed_path(), + }) } diff -Nru cargo-0.58.0/vendor/tempfile/src/file/imp/mod.rs cargo-0.60.0ubuntu1/vendor/tempfile/src/file/imp/mod.rs --- cargo-0.58.0/vendor/tempfile/src/file/imp/mod.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/src/file/imp/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,5 +1,5 @@ -cfg_if! { - if #[cfg(any(unix, target_os = "redox"))] { +cfg_if::cfg_if! { + if #[cfg(any(unix, target_os = "redox", target_os = "wasi"))] { mod unix; pub use self::unix::*; } else if #[cfg(windows)] { diff -Nru cargo-0.58.0/vendor/tempfile/src/file/imp/unix.rs cargo-0.60.0ubuntu1/vendor/tempfile/src/file/imp/unix.rs --- cargo-0.58.0/vendor/tempfile/src/file/imp/unix.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/src/file/imp/unix.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,10 +2,18 @@ use std::ffi::{CString, OsStr}; use std::fs::{self, File, OpenOptions}; use std::io; -use std::os::unix::ffi::OsStrExt; -use std::os::unix::fs::{MetadataExt, OpenOptionsExt}; -use std::path::Path; +cfg_if::cfg_if! { + if #[cfg(not(target_os = "wasi"))] { + use std::os::unix::ffi::OsStrExt; + use std::os::unix::fs::{MetadataExt, OpenOptionsExt}; + } else { + use std::os::wasi::ffi::OsStrExt; + #[cfg(feature = "nightly")] + use std::os::wasi::fs::MetadataExt; + } +} use crate::util; +use std::path::Path; #[cfg(not(target_os = "redox"))] use libc::{c_char, c_int, link, rename, unlink}; @@ -33,12 +41,14 @@ } pub fn create_named(path: &Path, open_options: &mut OpenOptions) -> io::Result { - open_options - .read(true) - .write(true) - .create_new(true) - .mode(0o600) - .open(path) + open_options.read(true).write(true).create_new(true); + + #[cfg(not(target_os = "wasi"))] + { + open_options.mode(0o600); + } + + open_options.open(path) } fn create_unlinked(path: &Path) -> io::Result { @@ -60,11 +70,11 @@ #[cfg(target_os = "linux")] pub fn create(dir: &Path) -> io::Result { - use libc::{EISDIR, ENOENT, EOPNOTSUPP, O_EXCL, O_TMPFILE}; + use libc::{EISDIR, ENOENT, EOPNOTSUPP, O_TMPFILE}; OpenOptions::new() .read(true) .write(true) - .custom_flags(O_TMPFILE | O_EXCL) // do not mix with `create_new(true)` + .custom_flags(O_TMPFILE) // do not mix with `create_new(true)` .open(dir) .or_else(|e| { match e.raw_os_error() { @@ -90,6 +100,7 @@ ) } +#[cfg(any(not(target_os = "wasi"), feature = "nightly"))] pub fn reopen(file: &File, path: &Path) -> io::Result { let new_file = OpenOptions::new().read(true).write(true).open(path)?; let old_meta = file.metadata()?; @@ -103,6 +114,14 @@ Ok(new_file) } +#[cfg(all(target_os = "wasi", not(feature = "nightly")))] +pub fn reopen(_file: &File, _path: &Path) -> io::Result { + return Err(io::Error::new( + io::ErrorKind::Other, + "this operation is supported on WASI only on nightly Rust (with `nightly` feature enabled)", + )); +} + #[cfg(not(target_os = "redox"))] pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> { unsafe { diff -Nru cargo-0.58.0/vendor/tempfile/src/file/mod.rs cargo-0.60.0ubuntu1/vendor/tempfile/src/file/mod.rs --- cargo-0.58.0/vendor/tempfile/src/file/mod.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/src/file/mod.rs 2022-04-20 13:48:09.000000000 +0000 @@ -138,7 +138,7 @@ /// /// When dropped, the temporary file is deleted. pub struct TempPath { - path: PathBuf, + path: Box, } impl TempPath { @@ -176,8 +176,8 @@ /// # } /// ``` pub fn close(mut self) -> io::Result<()> { - let result = fs::remove_file(&self.path).with_err_path(|| &self.path); - self.path = PathBuf::new(); + let result = fs::remove_file(&self.path).with_err_path(|| &*self.path); + self.path = PathBuf::new().into_boxed_path(); mem::forget(self); result } @@ -231,7 +231,7 @@ // Don't drop `self`. We don't want to try deleting the old // temporary file path. (It'll fail, but the failure is never // seen.) - self.path = PathBuf::new(); + self.path = PathBuf::new().into_boxed_path(); mem::forget(self); Ok(()) } @@ -293,7 +293,7 @@ // Don't drop `self`. We don't want to try deleting the old // temporary file path. (It'll fail, but the failure is never // seen.) - self.path = PathBuf::new(); + self.path = PathBuf::new().into_boxed_path(); mem::forget(self); Ok(()) } @@ -341,9 +341,9 @@ // Don't drop `self`. We don't want to try deleting the old // temporary file path. (It'll fail, but the failure is never // seen.) - let path = mem::replace(&mut self.path, PathBuf::new()); + let path = mem::replace(&mut self.path, PathBuf::new().into_boxed_path()); mem::forget(self); - Ok(path) + Ok(path.into()) } Err(e) => Err(PathPersistError { error: e, @@ -351,6 +351,18 @@ }), } } + + /// Create a new TempPath from an existing path. This can be done even if no + /// file exists at the given path. + /// + /// This is mostly useful for interacting with libraries and external + /// components that provide files to be consumed or expect a path with no + /// existing file to be given. + pub fn from_path(path: impl Into) -> Self { + Self { + path: path.into().into_boxed_path(), + } + } } impl fmt::Debug for TempPath { @@ -953,7 +965,9 @@ imp::create_named(&path, open_options) .with_err_path(|| path.clone()) .map(|file| NamedTempFile { - path: TempPath { path }, + path: TempPath { + path: path.into_boxed_path(), + }, file, }) } diff -Nru cargo-0.58.0/vendor/tempfile/src/lib.rs cargo-0.60.0ubuntu1/vendor/tempfile/src/lib.rs --- cargo-0.58.0/vendor/tempfile/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -27,6 +27,42 @@ //! rely on file paths for _some_ operations. See the security documentation on //! the `NamedTempFile` type for more information. //! +//! ## Early drop pitfall +//! +//! Because `TempDir` and `NamedTempFile` rely on their destructors for cleanup, this can lead +//! to an unexpected early removal of the directory/file, usually when working with APIs which are +//! generic over `AsRef`. Consider the following example: +//! +//! ```no_run +//! # use tempfile::tempdir; +//! # use std::io; +//! # use std::process::Command; +//! # fn main() { +//! # if let Err(_) = run() { +//! # ::std::process::exit(1); +//! # } +//! # } +//! # fn run() -> Result<(), io::Error> { +//! // Create a directory inside of `std::env::temp_dir()`. +//! let temp_dir = tempdir()?; +//! +//! // Spawn the `touch` command inside the temporary directory and collect the exit status +//! // Note that `temp_dir` is **not** moved into `current_dir`, but passed as a reference +//! let exit_status = Command::new("touch").arg("tmp").current_dir(&temp_dir).status()?; +//! assert!(exit_status.success()); +//! +//! # Ok(()) +//! # } +//! ``` +//! +//! This works because a reference to `temp_dir` is passed to `current_dir`, resulting in the +//! destructor of `temp_dir` being run after the `Command` has finished execution. Moving the +//! `TempDir` into the `current_dir` call would result in the `TempDir` being converted into +//! an internal representation, with the original value being dropped and the directory thus +//! being deleted, before the command can be executed. +//! +//! The `touch` command would fail with an `No such file or directory` error. +//! //! ## Examples //! //! Create a temporary file and write some data into it: @@ -125,9 +161,10 @@ #![cfg_attr(test, deny(warnings))] #![deny(rust_2018_idioms)] #![allow(clippy::redundant_field_names)] +#![cfg_attr(feature = "nightly", feature(wasi_ext))] -#[macro_use] -extern crate cfg_if; +#[cfg(doctest)] +doc_comment::doctest!("../README.md"); const NUM_RETRIES: u32 = 1 << 31; const NUM_RAND_CHARS: usize = 6; diff -Nru cargo-0.58.0/vendor/tempfile/src/spooled.rs cargo-0.60.0ubuntu1/vendor/tempfile/src/spooled.rs --- cargo-0.58.0/vendor/tempfile/src/spooled.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/src/spooled.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,8 +2,9 @@ use std::fs::File; use std::io::{self, Cursor, Read, Seek, SeekFrom, Write}; +/// A wrapper for the two states of a `SpooledTempFile`. #[derive(Debug)] -enum SpooledInner { +pub enum SpooledData { InMemory(Cursor>), OnDisk(File), } @@ -15,7 +16,7 @@ #[derive(Debug)] pub struct SpooledTempFile { max_size: usize, - inner: SpooledInner, + inner: SpooledData, } /// Create a new spooled temporary file. @@ -66,15 +67,15 @@ pub fn new(max_size: usize) -> SpooledTempFile { SpooledTempFile { max_size: max_size, - inner: SpooledInner::InMemory(Cursor::new(Vec::new())), + inner: SpooledData::InMemory(Cursor::new(Vec::new())), } } /// Returns true if the file has been rolled over to disk. pub fn is_rolled(&self) -> bool { match self.inner { - SpooledInner::InMemory(_) => false, - SpooledInner::OnDisk(_) => true, + SpooledData::InMemory(_) => false, + SpooledData::OnDisk(_) => true, } } @@ -83,11 +84,11 @@ pub fn roll(&mut self) -> io::Result<()> { if !self.is_rolled() { let mut file = tempfile()?; - if let SpooledInner::InMemory(ref mut cursor) = self.inner { + if let SpooledData::InMemory(ref mut cursor) = self.inner { file.write_all(cursor.get_ref())?; file.seek(SeekFrom::Start(cursor.position()))?; } - self.inner = SpooledInner::OnDisk(file); + self.inner = SpooledData::OnDisk(file); } Ok(()) } @@ -97,20 +98,25 @@ self.roll()?; // does nothing if already rolled over } match self.inner { - SpooledInner::InMemory(ref mut cursor) => { + SpooledData::InMemory(ref mut cursor) => { cursor.get_mut().resize(size as usize, 0); Ok(()) } - SpooledInner::OnDisk(ref mut file) => file.set_len(size), + SpooledData::OnDisk(ref mut file) => file.set_len(size), } } + + /// Consumes and returns the inner `SpooledData` type. + pub fn into_inner(self) -> SpooledData { + self.inner + } } impl Read for SpooledTempFile { fn read(&mut self, buf: &mut [u8]) -> io::Result { match self.inner { - SpooledInner::InMemory(ref mut cursor) => cursor.read(buf), - SpooledInner::OnDisk(ref mut file) => file.read(buf), + SpooledData::InMemory(ref mut cursor) => cursor.read(buf), + SpooledData::OnDisk(ref mut file) => file.read(buf), } } } @@ -119,7 +125,7 @@ fn write(&mut self, buf: &[u8]) -> io::Result { // roll over to file if necessary let mut rolling = false; - if let SpooledInner::InMemory(ref mut cursor) = self.inner { + if let SpooledData::InMemory(ref mut cursor) = self.inner { rolling = cursor.position() as usize + buf.len() > self.max_size; } if rolling { @@ -128,16 +134,16 @@ // write the bytes match self.inner { - SpooledInner::InMemory(ref mut cursor) => cursor.write(buf), - SpooledInner::OnDisk(ref mut file) => file.write(buf), + SpooledData::InMemory(ref mut cursor) => cursor.write(buf), + SpooledData::OnDisk(ref mut file) => file.write(buf), } } #[inline] fn flush(&mut self) -> io::Result<()> { match self.inner { - SpooledInner::InMemory(ref mut cursor) => cursor.flush(), - SpooledInner::OnDisk(ref mut file) => file.flush(), + SpooledData::InMemory(ref mut cursor) => cursor.flush(), + SpooledData::OnDisk(ref mut file) => file.flush(), } } } @@ -145,8 +151,8 @@ impl Seek for SpooledTempFile { fn seek(&mut self, pos: SeekFrom) -> io::Result { match self.inner { - SpooledInner::InMemory(ref mut cursor) => cursor.seek(pos), - SpooledInner::OnDisk(ref mut file) => file.seek(pos), + SpooledData::InMemory(ref mut cursor) => cursor.seek(pos), + SpooledData::OnDisk(ref mut file) => file.seek(pos), } } } diff -Nru cargo-0.58.0/vendor/tempfile/src/util.rs cargo-0.60.0ubuntu1/vendor/tempfile/src/util.rs --- cargo-0.58.0/vendor/tempfile/src/util.rs 2022-01-21 02:47:39.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/src/util.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,23 +1,16 @@ -use rand::distributions::Alphanumeric; -use rand::{self, Rng}; +use fastrand; use std::ffi::{OsStr, OsString}; use std::path::{Path, PathBuf}; -use std::{io, str}; +use std::{io, iter::repeat_with}; use crate::error::IoResultExt; fn tmpname(prefix: &OsStr, suffix: &OsStr, rand_len: usize) -> OsString { let mut buf = OsString::with_capacity(prefix.len() + suffix.len() + rand_len); buf.push(prefix); - - // Push each character in one-by-one. Unfortunately, this is the only - // safe(ish) simple way to do this without allocating a temporary - // String/Vec. - unsafe { - rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(rand_len) - .for_each(|b| buf.push(str::from_utf8_unchecked(&[b as u8]))) + let mut char_buf = [0u8; 4]; + for c in repeat_with(fastrand::alphanumeric).take(rand_len) { + buf.push(c.encode_utf8(&mut char_buf)); } buf.push(suffix); buf diff -Nru cargo-0.58.0/vendor/tempfile/tests/namedtempfile.rs cargo-0.60.0ubuntu1/vendor/tempfile/tests/namedtempfile.rs --- cargo-0.58.0/vendor/tempfile/tests/namedtempfile.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/tests/namedtempfile.rs 2022-04-20 13:48:09.000000000 +0000 @@ -1,10 +1,11 @@ #![deny(rust_2018_idioms)] use std::env; +use std::ffi::{OsStr, OsString}; use std::fs::File; use std::io::{Read, Seek, SeekFrom, Write}; -use std::path::Path; -use tempfile::{Builder, NamedTempFile}; +use std::path::{Path, PathBuf}; +use tempfile::{tempdir, Builder, NamedTempFile, TempPath}; fn exists>(path: P) -> bool { std::fs::metadata(path.as_ref()).is_ok() @@ -217,6 +218,50 @@ } #[test] +fn temp_path_from_existing() { + let tmp_dir = tempdir().unwrap(); + let tmp_file_path_1 = tmp_dir.path().join("testfile1"); + let tmp_file_path_2 = tmp_dir.path().join("testfile2"); + + File::create(&tmp_file_path_1).unwrap(); + assert!(tmp_file_path_1.exists(), "Test file 1 hasn't been created"); + + File::create(&tmp_file_path_2).unwrap(); + assert!(tmp_file_path_2.exists(), "Test file 2 hasn't been created"); + + let tmp_path = TempPath::from_path(&tmp_file_path_1); + assert!( + tmp_file_path_1.exists(), + "Test file has been deleted before dropping TempPath" + ); + + drop(tmp_path); + assert!( + !tmp_file_path_1.exists(), + "Test file exists after dropping TempPath" + ); + assert!( + tmp_file_path_2.exists(), + "Test file 2 has been deleted before dropping TempDir" + ); +} + +#[test] +#[allow(unreachable_code)] +fn temp_path_from_argument_types() { + // This just has to compile + return; + + TempPath::from_path(""); + TempPath::from_path(String::new()); + TempPath::from_path(OsStr::new("")); + TempPath::from_path(OsString::new()); + TempPath::from_path(Path::new("")); + TempPath::from_path(PathBuf::new()); + TempPath::from_path(PathBuf::new().into_boxed_path()); +} + +#[test] fn test_write_after_close() { let path = NamedTempFile::new().unwrap().into_temp_path(); File::create(path).unwrap().write_all(b"test").unwrap(); diff -Nru cargo-0.58.0/vendor/tempfile/tests/tempfile.rs cargo-0.60.0ubuntu1/vendor/tempfile/tests/tempfile.rs --- cargo-0.58.0/vendor/tempfile/tests/tempfile.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/tempfile/tests/tempfile.rs 2022-04-20 13:48:09.000000000 +0000 @@ -26,6 +26,8 @@ assert!(num_files == 0); } +// Only run this test on Linux. MacOS doesn't like us creating so many files, apparently. +#[cfg(target_os = "linux")] #[test] fn test_pathological_cleaner() { let tmpdir = tempfile::tempdir().unwrap(); diff -Nru cargo-0.58.0/vendor/termcolor/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/termcolor/.cargo-checksum.json --- cargo-0.58.0/vendor/termcolor/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/termcolor/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"} \ No newline at end of file +{"files":{},"package":"bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/termcolor/Cargo.toml cargo-0.60.0ubuntu1/vendor/termcolor/Cargo.toml --- cargo-0.58.0/vendor/termcolor/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/termcolor/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -3,24 +3,35 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "termcolor" -version = "1.1.2" +version = "1.1.3" authors = ["Andrew Gallant "] -exclude = ["/.travis.yml", "/appveyor.yml", "/ci/**"] -description = "A simple cross platform library for writing colored text to a terminal.\n" +exclude = [ + "/.travis.yml", + "/appveyor.yml", + "/ci/**", +] +description = """ +A simple cross platform library for writing colored text to a terminal. +""" homepage = "https://github.com/BurntSushi/termcolor" documentation = "https://docs.rs/termcolor" readme = "README.md" -keywords = ["windows", "win", "color", "ansi", "console"] +keywords = [ + "windows", + "win", + "color", + "ansi", + "console", +] license = "Unlicense OR MIT" repository = "https://github.com/BurntSushi/termcolor" @@ -28,6 +39,5 @@ name = "termcolor" bench = false -[dev-dependencies] [target."cfg(windows)".dependencies.winapi-util] version = "0.1.3" diff -Nru cargo-0.58.0/vendor/termcolor/README.md cargo-0.60.0ubuntu1/vendor/termcolor/README.md --- cargo-0.58.0/vendor/termcolor/README.md 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/termcolor/README.md 2022-04-20 13:48:09.000000000 +0000 @@ -9,7 +9,7 @@ [![Build status](https://github.com/BurntSushi/termcolor/workflows/ci/badge.svg)](https://github.com/BurntSushi/termcolor/actions) [![](https://img.shields.io/crates/v/termcolor.svg)](https://crates.io/crates/termcolor) -Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org). +Dual-licensed under MIT or the [UNLICENSE](https://unlicense.org/). ### Documentation @@ -85,7 +85,7 @@ ### Automatic color selection When building a writer with termcolor, the caller must provide a -[`ColorChoice`](https://docs.rs/termcolor/1.0.5/termcolor/enum.ColorChoice.html) +[`ColorChoice`](https://docs.rs/termcolor/1.*/termcolor/enum.ColorChoice.html) selection. When the color choice is `Auto`, termcolor will attempt to determine whether colors should be enabled by inspecting the environment. Currently, termcolor will inspect the `TERM` and `NO_COLOR` environment variables: diff -Nru cargo-0.58.0/vendor/termcolor/src/lib.rs cargo-0.60.0ubuntu1/vendor/termcolor/src/lib.rs --- cargo-0.58.0/vendor/termcolor/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/termcolor/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -82,7 +82,7 @@ automatically when writing to a terminal and disable colors automatically when writing to anything else. The typical way to achieve this in Unix environments is via libc's -[`isatty`](http://man7.org/linux/man-pages/man3/isatty.3.html) +[`isatty`](https://man7.org/linux/man-pages/man3/isatty.3.html) function. Unfortunately, this notoriously does not work well in Windows environments. To work around that, the currently recommended solution is to use the @@ -1450,6 +1450,20 @@ } } +impl WriteColor for io::Sink { + fn supports_color(&self) -> bool { + false + } + + fn set_color(&mut self, _: &ColorSpec) -> io::Result<()> { + Ok(()) + } + + fn reset(&mut self) -> io::Result<()> { + Ok(()) + } +} + /// An in-memory buffer that provides Windows console coloring. /// /// This doesn't actually communicate with the Windows console. Instead, it diff -Nru cargo-0.58.0/vendor/textwrap/debian/patches/disable-hyphenation.diff cargo-0.60.0ubuntu1/vendor/textwrap/debian/patches/disable-hyphenation.diff --- cargo-0.58.0/vendor/textwrap/debian/patches/disable-hyphenation.diff 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/textwrap/debian/patches/disable-hyphenation.diff 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,27 @@ +Index: textwrap/Cargo.toml +=================================================================== +--- textwrap.orig/Cargo.toml ++++ textwrap/Cargo.toml +@@ -26,11 +26,6 @@ repository = "https://github.com/mgeisle + all-features = true + + [[example]] +-name = "hyphenation" +-path = "examples/hyphenation.rs" +-required-features = ["hyphenation"] +- +-[[example]] + name = "termwidth" + path = "examples/termwidth.rs" + required-features = ["terminal_size"] +@@ -44,10 +39,6 @@ harness = false + name = "indent" + path = "benches/indent.rs" + harness = false +-[dependencies.hyphenation] +-version = "0.8.4" +-features = ["embed_en-us"] +-optional = true + + [dependencies.smawk] + version = "0.3.1" diff -Nru cargo-0.58.0/vendor/textwrap/debian/patches/remove-leftovers.patch cargo-0.60.0ubuntu1/vendor/textwrap/debian/patches/remove-leftovers.patch --- cargo-0.58.0/vendor/textwrap/debian/patches/remove-leftovers.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/textwrap/debian/patches/remove-leftovers.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,42 @@ +The crates.io release does not include the benches or examples, but there is +still metadata related to them in Cargo.toml, clean it up so the autopkgtest +can run succesfully. + +Index: textwrap/Cargo.toml +=================================================================== +--- textwrap.orig/Cargo.toml ++++ textwrap/Cargo.toml +@@ -25,21 +25,6 @@ repository = "https://github.com/mgeisle + [package.metadata.docs.rs] + all-features = true + +-[[example]] +-name = "termwidth" +-path = "examples/termwidth.rs" +-required-features = ["terminal_size"] +- +-[[bench]] +-name = "linear" +-path = "benches/linear.rs" +-harness = false +- +-[[bench]] +-name = "indent" +-path = "benches/indent.rs" +-harness = false +- + [dependencies.smawk] + version = "0.3.1" + optional = true +@@ -55,11 +40,6 @@ optional = true + [dependencies.unicode-width] + version = "0.1.9" + optional = true +-[dev-dependencies.criterion] +-version = "0.3.5" +- +-[dev-dependencies.lipsum] +-version = "0.8.0" + + [dev-dependencies.unic-emoji-char] + version = "0.9.0" diff -Nru cargo-0.58.0/vendor/textwrap/debian/patches/remove-unic-emoji-char.patch cargo-0.60.0ubuntu1/vendor/textwrap/debian/patches/remove-unic-emoji-char.patch --- cargo-0.58.0/vendor/textwrap/debian/patches/remove-unic-emoji-char.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/textwrap/debian/patches/remove-unic-emoji-char.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,36 @@ +Index: textwrap/Cargo.toml +=================================================================== +--- textwrap.orig/Cargo.toml ++++ textwrap/Cargo.toml +@@ -56,9 +56,6 @@ optional = true + version = "0.1.9" + optional = true + +-[dev-dependencies.unic-emoji-char] +-version = "0.9.0" +- + [dev-dependencies.version-sync] + version = "0.9.4" + +Index: textwrap/src/core.rs +=================================================================== +--- textwrap.orig/src/core.rs ++++ textwrap/src/core.rs +@@ -358,7 +358,7 @@ mod tests { + assert_eq!(chars.next(), Some('H')); + } + +- #[test] ++ /*#[test] + fn emojis_have_correct_width() { + use unic_emoji_char::is_emoji; + +@@ -397,7 +397,7 @@ mod tests { + + // The remaining planes contain almost no assigned code points + // and thus also no emojis. +- } ++ }*/ + + #[test] + fn display_width_works() { diff -Nru cargo-0.58.0/vendor/textwrap/debian/patches/remove-version-sync.patch cargo-0.60.0ubuntu1/vendor/textwrap/debian/patches/remove-version-sync.patch --- cargo-0.58.0/vendor/textwrap/debian/patches/remove-version-sync.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/textwrap/debian/patches/remove-version-sync.patch 2022-04-20 13:48:09.000000000 +0000 @@ -0,0 +1,30 @@ +Index: textwrap/Cargo.toml +=================================================================== +--- textwrap.orig/Cargo.toml ++++ textwrap/Cargo.toml +@@ -56,9 +56,6 @@ optional = true + version = "0.1.9" + optional = true + +-[dev-dependencies.version-sync] +-version = "0.9.4" +- + [features] + default = ["unicode-linebreak", "unicode-width", "smawk"] + [target."cfg(unix)".dev-dependencies.termion] +Index: textwrap/tests/version-numbers.rs +=================================================================== +--- textwrap.orig/tests/version-numbers.rs ++++ textwrap/tests/version-numbers.rs +@@ -1,4 +1,4 @@ +-#[test] ++/*#[test] + fn test_readme_deps() { + version_sync::assert_markdown_deps_updated!("README.md"); + } +@@ -19,4 +19,4 @@ fn test_html_root_url() { + #[test] + fn test_dependency_graph() { + version_sync::assert_contains_regex!("src/lib.rs", "master/images/textwrap-{version}.svg"); +-} ++}*/ diff -Nru cargo-0.58.0/vendor/thread_local/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/thread_local/.cargo-checksum.json --- cargo-0.58.0/vendor/thread_local/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/thread_local/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd"} \ No newline at end of file +{"files":{},"package":"5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/thread_local/Cargo.toml cargo-0.60.0ubuntu1/vendor/thread_local/Cargo.toml --- cargo-0.58.0/vendor/thread_local/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/thread_local/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -3,17 +3,16 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "thread_local" -version = "1.1.3" +version = "1.1.4" authors = ["Amanieu d'Antras "] description = "Per-object thread-local storage" documentation = "https://docs.rs/thread_local/" diff -Nru cargo-0.58.0/vendor/thread_local/src/lib.rs cargo-0.60.0ubuntu1/vendor/thread_local/src/lib.rs --- cargo-0.58.0/vendor/thread_local/src/lib.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/thread_local/src/lib.rs 2022-04-20 13:48:09.000000000 +0000 @@ -378,7 +378,7 @@ fn next<'a, T: Send + Sync>(&mut self, thread_local: &'a ThreadLocal) -> Option<&'a T> { while self.bucket < BUCKETS { let bucket = unsafe { thread_local.buckets.get_unchecked(self.bucket) }; - let bucket = bucket.load(Ordering::Relaxed); + let bucket = bucket.load(Ordering::Acquire); if !bucket.is_null() { while self.index < self.bucket_size { diff -Nru cargo-0.58.0/vendor/toml/.cargo-checksum.json cargo-0.60.0ubuntu1/vendor/toml/.cargo-checksum.json --- cargo-0.58.0/vendor/toml/.cargo-checksum.json 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/toml/.cargo-checksum.json 2022-04-20 13:48:09.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"} \ No newline at end of file +{"files":{},"package":"8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"} \ No newline at end of file diff -Nru cargo-0.58.0/vendor/toml/Cargo.lock cargo-0.60.0ubuntu1/vendor/toml/Cargo.lock --- cargo-0.58.0/vendor/toml/Cargo.lock 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/toml/Cargo.lock 2022-04-20 13:48:09.000000000 +0000 @@ -86,7 +86,7 @@ [[package]] name = "toml" -version = "0.5.8" +version = "0.5.9" dependencies = [ "indexmap", "serde", diff -Nru cargo-0.58.0/vendor/toml/Cargo.toml cargo-0.60.0ubuntu1/vendor/toml/Cargo.toml --- cargo-0.58.0/vendor/toml/Cargo.toml 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/toml/Cargo.toml 2022-04-20 13:48:09.000000000 +0000 @@ -3,32 +3,41 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "toml" -version = "0.5.8" +version = "0.5.9" authors = ["Alex Crichton "] -description = "A native Rust encoder and decoder of TOML-formatted files and streams. Provides\nimplementations of the standard Serialize/Deserialize traits for TOML data to\nfacilitate deserializing and serializing Rust structures.\n" +description = """ +A native Rust encoder and decoder of TOML-formatted files and streams. Provides +implementations of the standard Serialize/Deserialize traits for TOML data to +facilitate deserializing and serializing Rust structures. +""" homepage = "https://github.com/alexcrichton/toml-rs" documentation = "https://docs.rs/toml" readme = "README.md" keywords = ["encoding"] -categories = ["config", "encoding", "parser-implementations"] +categories = [ + "config", + "encoding", + "parser-implementations", +] license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/toml-rs" + [dependencies.indexmap] version = "1.0" optional = true [dependencies.serde] version = "1.0.97" + [dev-dependencies.serde_derive] version = "1.0" diff -Nru cargo-0.58.0/vendor/toml/examples/decode.rs cargo-0.60.0ubuntu1/vendor/toml/examples/decode.rs --- cargo-0.58.0/vendor/toml/examples/decode.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/toml/examples/decode.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,6 +2,7 @@ //! TOML into a Rust `struct` #![deny(warnings)] +#![allow(dead_code)] use serde_derive::Deserialize; diff -Nru cargo-0.58.0/vendor/toml/examples/enum_external.rs cargo-0.60.0ubuntu1/vendor/toml/examples/enum_external.rs --- cargo-0.58.0/vendor/toml/examples/enum_external.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/toml/examples/enum_external.rs 2022-04-20 13:48:09.000000000 +0000 @@ -2,6 +2,7 @@ //! TOML into a Rust `struct`, with enums. #![deny(warnings)] +#![allow(dead_code)] use serde_derive::Deserialize; diff -Nru cargo-0.58.0/vendor/toml/src/datetime.rs cargo-0.60.0ubuntu1/vendor/toml/src/datetime.rs --- cargo-0.58.0/vendor/toml/src/datetime.rs 2021-12-20 10:27:19.000000000 +0000 +++ cargo-0.60.0ubuntu1/vendor/toml/src/datetime.rs 2022-04-20 13:48:09.000000000 +0000 @@ -21,11 +21,74 @@ /// Also note though that while this type implements `Serialize` and /// `Deserialize` it's only recommended to use this type with the TOML format, /// otherwise encoded in other formats it may look a little odd. +/// +/// Depending on how the option values are used, this struct will correspond +/// with one of the following four datetimes from the [TOML v1.0.0 spec]: +/// +/// | `date` | `time` | `offset` | TOML type | +/// | --------- | --------- | --------- | ------------------ | +/// | `Some(_)` | `Some(_)` | `Some(_)` | [Offset Date-Time] | +/// | `Some(_)` | `Some(_)` | `None` | [Local Date-Time] | +/// | `Some(_)` | `None` | `None` | [Local Date] | +/// | `None` | `Some(_)` | `None` | [Local Time] | +/// +/// **1. Offset Date-Time**: If all the optional values are used, `Datetime` +/// corresponds to an [Offset Date-Time]. From the TOML v1.0.0 spec: +/// +/// > To unambiguously represent a specific instant in time, you may use an +/// > RFC 3339 formatted date-time with offset. +/// > +/// > ```toml +/// > odt1 = 1979-05-27T07:32:00Z +/// > odt2 = 1979-05-27T00:32:00-07:00 +/// > odt3 = 1979-05-27T00:32:00.999999-07:00 +/// > ``` +/// > +/// > For the sake of readability, you may replace the T delimiter between date +/// > and time with a space character (as permitted by RFC 3339 section 5.6). +/// > +/// > ```toml +/// > odt4 = 1979-05-27 07:32:00Z +/// > ``` +/// +/// **2. Local Date-Time**: If `date` and `time` are given but `offset` is +/// `None`, `Datetime` corresponds to a [Local Date-Time]. From the spec: +/// +/// > If you omit the offset from an RFC 3339 formatted date-time, it will +/// > represent the given date-time without any relation to an offset or +/// > timezone. It cannot be converted to an instant in time without additional +/// > information. Conversion to an instant, if required, is implementation- +/// > specific. +/// > +/// > ```toml +/// > ldt1 = 1979-05-27T07:32:00 +/// > ldt2 = 1979-05-27T00:32:00.999999 +/// > ``` +/// +/// **3. Local Date**: If only `date` is given, `Datetime` corresponds to a +/// [Local Date]; see the docs for [`Date`]. +/// +/// **4. Local Time**: If only `time` is given, `Datetime` corresponds to a +/// [Local Time]; see the docs for [`Time`]. +/// +/// [TOML v1.0.0 spec]: https://toml.io/en/v1.0.0 +/// [Offset Date-Time]: https://toml.io/en/v1.0.0#offset-date-time +/// [Local Date-Time]: https://toml.io/en/v1.0.0#local-date-time +/// [Local Date]: https://toml.io/en/v1.0.0#local-date +/// [Local Time]: https://toml.io/en/v1.0.0#local-time #[derive(PartialEq, Clone)] pub struct Datetime { - date: Option, - time: Option