diff -Nru cargo-0.64.0ubuntu0.libgit2/Cargo.toml cargo-0.66.0+ds0ubuntu0.libgit2/Cargo.toml --- cargo-0.64.0ubuntu0.libgit2/Cargo.toml 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/Cargo.toml 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "cargo" -version = "0.64.0" +version = "0.66.0" edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://crates.io" @@ -21,7 +21,6 @@ cargo-platform = { path = "crates/cargo-platform", version = "0.1.2" } cargo-util = { path = "crates/cargo-util", version = "0.2.1" } crates-io = { path = "crates/crates-io", version = "0.34.0" } -crossbeam-utils = "0.8" curl = { version = "0.4.43", features = ["http2"] } curl-sys = "0.4.55" env_logger = "0.9.0" @@ -29,8 +28,8 @@ anyhow = "1.0" filetime = "0.2.9" flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] } -git2 = "0.14.2" -git2-curl = "0.15.0" +git2 = "0.15.0" +git2-curl = "0.16.0" glob = "0.3.0" hex = "0.4" home = "0.5" @@ -42,11 +41,10 @@ lazycell = "1.2.0" libc = "0.2" log = "0.4.6" -libgit2-sys = "0.13.2" +libgit2-sys = "0.14.0" memchr = "2.1.3" -num_cpus = "1.0" opener = "0.5" -os_info = "3.0.7" +os_info = "3.5.0" pathdiff = "0.2" percent-encoding = "2.0" rustfix = "0.6.0" @@ -63,7 +61,7 @@ unicode-xid = "0.2.0" url = "2.2.2" walkdir = "2.2" -clap = "3.2.1" +clap = "3.2.18" unicode-width = "0.1.5" openssl = { version = '0.10.11', optional = true } im-rc = "15.0.0" @@ -101,7 +99,7 @@ [dev-dependencies] cargo-test-macro = { path = "crates/cargo-test-macro" } cargo-test-support = { path = "crates/cargo-test-support" } -snapbox = { version = "0.2.8", features = ["diff", "path"] } +snapbox = { version = "0.3.0", features = ["diff", "path"] } [build-dependencies] flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] } diff -Nru cargo-0.64.0ubuntu0.libgit2/CHANGELOG.md cargo-0.66.0+ds0ubuntu0.libgit2/CHANGELOG.md --- cargo-0.64.0ubuntu0.libgit2/CHANGELOG.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/CHANGELOG.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,19 +1,142 @@ # Changelog +## Cargo 1.65 (2022-11-03) +[4fd148c4...HEAD](https://github.com/rust-lang/cargo/compare/4fd148c4...HEAD) + +### Added + +### Changed + +- Cargo now uses the standard library's `available_parallelism` instead of the + `num_cpus` crate for determining the default parallelism. + [#10969](https://github.com/rust-lang/cargo/pull/10969) + +### Fixed + +### Nightly only + + +## Cargo 1.64 (2022-09-22) +[a5e08c47...rust-1.64.0](https://github.com/rust-lang/cargo/compare/a5e08c47...rust-1.64.0) + +### Added + +- 🎉 Packages can now inherit settings from the workspace so that the settings + can be centralized in one place. See + [`workspace.package`](https://doc.rust-lang.org/nightly/cargo/reference/workspaces.html#the-workspacepackage-table) + and + [`workspace.dependencies`](https://doc.rust-lang.org/nightly/cargo/reference/workspaces.html#the-workspacedependencies-table) + for more details on how to define these common settings. + [#10859](https://github.com/rust-lang/cargo/pull/10859) +- Added the + [`--crate-type`](https://doc.rust-lang.org/nightly/cargo/commands/cargo-rustc.html#option-cargo-rustc---crate-type) + flag to `cargo rustc` to override the crate type. + [#10838](https://github.com/rust-lang/cargo/pull/10838) +- Cargo commands can now accept multiple `--target` flags to build for + multiple targets at once, and the + [`build.target`](https://doc.rust-lang.org/nightly/cargo/reference/config.html#buildtarget) + config option may now take an array of multiple targets. + [#10766](https://github.com/rust-lang/cargo/pull/10766) +- The `--jobs` argument can now take a negative number to count backwards from + the max CPUs. + [#10844](https://github.com/rust-lang/cargo/pull/10844) + +### Changed +- Bash completion of `cargo install --path` now supports path completion. + [#10798](https://github.com/rust-lang/cargo/pull/10798) +- Significantly improved the performance fetching git dependencies from GitHub + when using a hash in the `rev` field. + [#10079](https://github.com/rust-lang/cargo/pull/10079) +- Published packages will now include the resolver setting from the workspace + to ensure that they use the same resolver when used in isolation. + [#10911](https://github.com/rust-lang/cargo/pull/10911) + [#10961](https://github.com/rust-lang/cargo/pull/10961) + [#10970](https://github.com/rust-lang/cargo/pull/10970) +- `cargo add` will now update `Cargo.lock`. + [#10902](https://github.com/rust-lang/cargo/pull/10902) +- The path in the config output of `cargo vendor` now translates backslashes + to forward slashes so that the settings should work across platforms. + [#10668](https://github.com/rust-lang/cargo/pull/10668) +- The + [`workspace.default-members`](https://doc.rust-lang.org/nightly/cargo/reference/workspaces.html#package-selection) + setting now allows a value of `"."` in a non-virtual workspace to refer to + the root package. + [#10784](https://github.com/rust-lang/cargo/pull/10784) + +### Fixed +- The `os` output in `cargo --version --verbose` now supports more platforms. + [#10802](https://github.com/rust-lang/cargo/pull/10802) +- Cached git checkouts will now be rebuilt if they are corrupted. This may + happen when using `net.git-fetch-with-cli` and interrupting the clone + process. + [#10829](https://github.com/rust-lang/cargo/pull/10829) +- Fixed panic in `cargo add --offline`. + [#10817](https://github.com/rust-lang/cargo/pull/10817) + + +### Nightly only +- Fixed deserialization of unstable `check-cfg` in `config.toml`. + [#10799](https://github.com/rust-lang/cargo/pull/10799) + + ## Cargo 1.63 (2022-08-11) -[3f052d8e...HEAD](https://github.com/rust-lang/cargo/compare/3f052d8e...HEAD) +[3f052d8e...rust-1.63.0](https://github.com/rust-lang/cargo/compare/3f052d8e...rust-1.63.0) ### Added +- 🎉 Added the `--config` CLI option to pass config options directly on the CLI. + [#10755](https://github.com/rust-lang/cargo/pull/10755) +- The `CARGO_PKG_RUST_VERSION` environment variable is now set when compiling + a crate if the manifest has the `rust-version` field set. + [#10713](https://github.com/rust-lang/cargo/pull/10713) + + ### Changed +- A warning is emitted when encountering multiple packages with the same name + in a git dependency. This will ignore packages with `publish=false`. + [#10701](https://github.com/rust-lang/cargo/pull/10701) + [#10767](https://github.com/rust-lang/cargo/pull/10767) +- Change tracking now uses the contents of a `.json` target spec file instead + of its path. This should help avoid rebuilds if the path changes. + [#10746](https://github.com/rust-lang/cargo/pull/10746) +- Git dependencies with a submodule configured with the `update=none` strategy + in `.gitmodules` is now honored, and the submodule will not be fetched. + [#10717](https://github.com/rust-lang/cargo/pull/10717) +- Crate files now use a more recent date (Jul 23, 2006 instead of Nov 29, 1973) + for deterministic behavior. + [#10720](https://github.com/rust-lang/cargo/pull/10720) +- The initial template used for `cargo new` now includes a slightly more + realistic test structure that has `use super::*;` in the test module. + [#10706](https://github.com/rust-lang/cargo/pull/10706) +- Updated the internal HTTP library libcurl with various small fixes and updates. + [#10696](https://github.com/rust-lang/cargo/pull/10696) ### Fixed +- Fix zsh completions for `cargo add` and `cargo locate-project` + [#10810](https://github.com/rust-lang/cargo/pull/10810) + [#10811](https://github.com/rust-lang/cargo/pull/10811) +- Fixed `-p` being ignored with `cargo publish` in the root of a virtual + workspace. Some additional checks were also added to generate an error if + multiple packages were selected (previously it would pick the first one). + [#10677](https://github.com/rust-lang/cargo/pull/10677) +- The human-readable executable name is no longer displayed for `cargo test` + when using JSON output. + [#10691](https://github.com/rust-lang/cargo/pull/10691) ### Nightly only - Added `-Zcheck-cfg=output` to support build-scripts declaring their supported set of `cfg` values with `cargo:rustc-check-cfg`. [#10539](https://github.com/rust-lang/cargo/pull/10539) +- `-Z http-registry` now uses https://index.crates.io/ when accessing crates-io. + [#10725](https://github.com/rust-lang/cargo/pull/10725) +- Fixed formatting of `.workspace` key in `cargo add` for workspace inheritance. + [#10705](https://github.com/rust-lang/cargo/pull/10705) +- Sparse HTTP registry URLs must now end with a `/`. + [#10698](https://github.com/rust-lang/cargo/pull/10698) +- Fixed issue with `cargo add` and workspace inheritance of the `default-features` key. + [#10685](https://github.com/rust-lang/cargo/pull/10685) + ## Cargo 1.62 (2022-06-30) @@ -78,6 +201,10 @@ - The `build.dep-info-basedir` configuration setting now properly supports the use of `..` in the path to refer to a parent directory. [#10281](https://github.com/rust-lang/cargo/pull/10281) +- Fixed regression in automatic detection of the default number of CPUs to use + on systems using cgroups v1. + [#10737](https://github.com/rust-lang/cargo/pull/10737) + [#10739](https://github.com/rust-lang/cargo/pull/10739) ### Nightly only diff -Nru cargo-0.64.0ubuntu0.libgit2/crates/cargo-test-macro/src/lib.rs cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-test-macro/src/lib.rs --- cargo-0.64.0ubuntu0.libgit2/crates/cargo-test-macro/src/lib.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-test-macro/src/lib.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,20 +1,119 @@ extern crate proc_macro; use proc_macro::*; +use std::process::Command; +use std::sync::Once; #[proc_macro_attribute] pub fn cargo_test(attr: TokenStream, item: TokenStream) -> TokenStream { + // Ideally these options would be embedded in the test itself. However, I + // find it very helpful to have the test clearly state whether or not it + // is ignored. It would be nice to have some kind of runtime ignore + // support (such as + // https://internals.rust-lang.org/t/pre-rfc-skippable-tests/14611). + // + // Unfortunately a big drawback here is that if the environment changes + // (such as the existence of the `git` CLI), this will not trigger a + // rebuild and the test will still be ignored. In theory, something like + // `tracked_env` or `tracked_path` + // (https://github.com/rust-lang/rust/issues/99515) could help with this, + // but they don't really handle the absence of files well. + let mut ignore = false; + let mut requires_reason = false; + let mut explicit_reason = None; + let mut implicit_reasons = Vec::new(); + macro_rules! set_ignore { + ($predicate:expr, $($arg:tt)*) => { + let p = $predicate; + ignore |= p; + if p { + implicit_reasons.push(std::fmt::format(format_args!($($arg)*))); + } + }; + } + let is_not_nightly = !version().1; + for rule in split_rules(attr) { + match rule.as_str() { + "build_std_real" => { + // Only run the "real" build-std tests on nightly and with an + // explicit opt-in (these generally only work on linux, and + // have some extra requirements, and are slow, and can pollute + // the environment since it downloads dependencies). + set_ignore!(is_not_nightly, "requires nightly"); + set_ignore!( + option_env!("CARGO_RUN_BUILD_STD_TESTS").is_none(), + "CARGO_RUN_BUILD_STD_TESTS must be set" + ); + } + "build_std_mock" => { + // Only run the "mock" build-std tests on nightly and disable + // for windows-gnu which is missing object files (see + // https://github.com/rust-lang/wg-cargo-std-aware/issues/46). + set_ignore!(is_not_nightly, "requires nightly"); + set_ignore!( + cfg!(all(target_os = "windows", target_env = "gnu")), + "does not work on windows-gnu" + ); + } + "nightly" => { + requires_reason = true; + set_ignore!(is_not_nightly, "requires nightly"); + } + s if s.starts_with("requires_") => { + let command = &s[9..]; + set_ignore!(!has_command(command), "{command} not installed"); + } + s if s.starts_with(">=1.") => { + requires_reason = true; + let min_minor = s[4..].parse().unwrap(); + let minor = version().0; + set_ignore!(minor < min_minor, "requires rustc 1.{minor} or newer"); + } + s if s.starts_with("reason=") => { + explicit_reason = Some(s[7..].parse().unwrap()); + } + _ => panic!("unknown rule {:?}", rule), + } + } + if requires_reason && explicit_reason.is_none() { + panic!( + "#[cargo_test] with a rule also requires a reason, \ + such as #[cargo_test(nightly, reason = \"needs -Z unstable-thing\")]" + ); + } + + // Construct the appropriate attributes. let span = Span::call_site(); let mut ret = TokenStream::new(); - ret.extend(Some(TokenTree::from(Punct::new('#', Spacing::Alone)))); - let test = TokenTree::from(Ident::new("test", span)); - ret.extend(Some(TokenTree::from(Group::new( - Delimiter::Bracket, - test.into(), - )))); - - let build_std = contains_ident(&attr, "build_std"); + let add_attr = |ret: &mut TokenStream, attr_name, attr_input| { + ret.extend(Some(TokenTree::from(Punct::new('#', Spacing::Alone)))); + let attr = TokenTree::from(Ident::new(attr_name, span)); + let mut attr_stream: TokenStream = attr.into(); + if let Some(input) = attr_input { + attr_stream.extend(input); + } + ret.extend(Some(TokenTree::from(Group::new( + Delimiter::Bracket, + attr_stream, + )))); + }; + add_attr(&mut ret, "test", None); + if ignore { + let reason = explicit_reason + .or_else(|| { + (!implicit_reasons.is_empty()) + .then(|| TokenTree::from(Literal::string(&implicit_reasons.join(", "))).into()) + }) + .map(|reason: TokenStream| { + let mut stream = TokenStream::new(); + stream.extend(Some(TokenTree::from(Punct::new('=', Spacing::Alone)))); + stream.extend(Some(reason)); + stream + }); + add_attr(&mut ret, "ignore", reason); + } + // Find where the function body starts, and add the boilerplate at the start. for token in item { let group = match token { TokenTree::Group(g) => { @@ -38,17 +137,6 @@ };"#, ); - // If this is a `build_std` test (aka `tests/build-std/*.rs`) then they - // only run on nightly and they only run when specifically instructed to - // on CI. - if build_std { - let ts = to_token_stream("if !cargo_test_support::is_nightly() { return }"); - new_body.extend(ts); - let ts = to_token_stream( - "if std::env::var(\"CARGO_RUN_BUILD_STD_TESTS\").is_err() { return }", - ); - new_body.extend(ts); - } new_body.extend(group.stream()); ret.extend(Some(TokenTree::from(Group::new( group.delimiter(), @@ -59,13 +147,79 @@ ret } -fn contains_ident(t: &TokenStream, ident: &str) -> bool { - t.clone().into_iter().any(|t| match t { - TokenTree::Ident(i) => i.to_string() == ident, +fn split_rules(t: TokenStream) -> Vec { + let tts: Vec<_> = t.into_iter().collect(); + tts.split(|tt| match tt { + TokenTree::Punct(p) => p.as_char() == ',', _ => false, }) + .filter(|parts| !parts.is_empty()) + .map(|parts| { + parts + .into_iter() + .map(|part| part.to_string()) + .collect::() + }) + .collect() } fn to_token_stream(code: &str) -> TokenStream { code.parse().unwrap() } + +static mut VERSION: (u32, bool) = (0, false); + +fn version() -> &'static (u32, bool) { + static INIT: Once = Once::new(); + INIT.call_once(|| { + let output = Command::new("rustc") + .arg("-V") + .output() + .expect("rustc should run"); + let stdout = std::str::from_utf8(&output.stdout).expect("utf8"); + let vers = stdout.split_whitespace().skip(1).next().unwrap(); + let is_nightly = option_env!("CARGO_TEST_DISABLE_NIGHTLY").is_none() + && (vers.contains("-nightly") || vers.contains("-dev")); + let minor = vers.split('.').skip(1).next().unwrap().parse().unwrap(); + unsafe { VERSION = (minor, is_nightly) } + }); + unsafe { &VERSION } +} + +fn has_command(command: &str) -> bool { + let output = match Command::new(command).arg("--version").output() { + Ok(output) => output, + Err(e) => { + // hg is not installed on GitHub macOS or certain constrained + // environments like Docker. Consider installing it if Cargo gains + // more hg support, but otherwise it isn't critical. + if is_ci() && command != "hg" { + panic!( + "expected command `{}` to be somewhere in PATH: {}", + command, e + ); + } + return false; + } + }; + if !output.status.success() { + panic!( + "expected command `{}` to be runnable, got error {}:\n\ + stderr:{}\n\ + stdout:{}\n", + command, + output.status, + String::from_utf8_lossy(&output.stderr), + String::from_utf8_lossy(&output.stdout) + ); + } + true +} + +/// Whether or not this running in a Continuous Integration environment. +fn is_ci() -> bool { + // Consider using `tracked_env` instead of option_env! when it is stabilized. + // `tracked_env` will handle changes, but not require rebuilding the macro + // itself like option_env does. + option_env!("CI").is_some() || option_env!("TF_BUILD").is_some() +} diff -Nru cargo-0.64.0ubuntu0.libgit2/crates/cargo-test-support/Cargo.toml cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-test-support/Cargo.toml --- cargo-0.64.0ubuntu0.libgit2/crates/cargo-test-support/Cargo.toml 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-test-support/Cargo.toml 2022-10-20 06:00:42.000000000 +0000 @@ -11,10 +11,10 @@ anyhow = "1.0.34" cargo-test-macro = { path = "../cargo-test-macro" } cargo-util = { path = "../cargo-util" } -snapbox = { version = "0.2.8", features = ["diff", "path"] } +snapbox = { version = "0.3.0", features = ["diff", "path"] } filetime = "0.2" flate2 = { version = "1.0", default-features = false, features = ["zlib"] } -git2 = "0.14.2" +git2 = "0.15.0" glob = "0.3" itertools = "0.10.0" lazy_static = "1.0" @@ -25,5 +25,8 @@ toml_edit = { version = "0.14.3", features = ["serde", "easy", "perf"] } url = "2.2.2" +[target.'cfg(windows)'.dependencies] +winapi = "0.3" + [features] deny-warnings = [] diff -Nru cargo-0.64.0ubuntu0.libgit2/crates/cargo-test-support/src/compare.rs cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-test-support/src/compare.rs --- cargo-0.64.0ubuntu0.libgit2/crates/cargo-test-support/src/compare.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-test-support/src/compare.rs 2022-10-20 06:00:42.000000000 +0000 @@ -70,7 +70,7 @@ /// Other heuristics are applied to try to ensure Windows-style paths aren't /// a problem. /// - Carriage returns are removed, which can help when running on Windows. -pub fn assert() -> snapbox::Assert { +pub fn assert_ui() -> snapbox::Assert { let root = paths::root(); // Use `from_file_path` instead of `from_dir_path` so the trailing slash is // put in the users output, rather than hidden in the variable diff -Nru cargo-0.64.0ubuntu0.libgit2/crates/cargo-test-support/src/lib.rs cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-test-support/src/lib.rs --- cargo-0.64.0ubuntu0.libgit2/crates/cargo-test-support/src/lib.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-test-support/src/lib.rs 2022-10-20 06:00:42.000000000 +0000 @@ -806,9 +806,14 @@ p.build_command() } - pub fn masquerade_as_nightly_cargo(&mut self) -> &mut Self { + /// Enables nightly features for testing + /// + /// The list of reasons should be why nightly cargo is needed. If it is + /// becuase of an unstable feature put the name of the feature as the reason, + /// e.g. `&["print-im-a-teapot"]` + pub fn masquerade_as_nightly_cargo(&mut self, reasons: &[&str]) -> &mut Self { if let Some(ref mut p) = self.process_builder { - p.masquerade_as_nightly_cargo(); + p.masquerade_as_nightly_cargo(reasons); } self } @@ -1123,6 +1128,10 @@ pub fn is_nightly() -> bool { let vv = &RUSTC_INFO.verbose_version; + // CARGO_TEST_DISABLE_NIGHTLY is set in rust-lang/rust's CI so that all + // nightly-only tests are disabled there. Otherwise, it could make it + // difficult to land changes which would need to be made simultaneously in + // rust-lang/cargo and rust-lan/rust, which isn't possible. env::var("CARGO_TEST_DISABLE_NIGHTLY").is_err() && (vv.contains("-nightly") || vv.contains("-dev")) } @@ -1139,17 +1148,20 @@ /// Enable nightly features for testing pub trait ChannelChanger { - fn masquerade_as_nightly_cargo(self) -> Self; + /// The list of reasons should be why nightly cargo is needed. If it is + /// becuase of an unstable feature put the name of the feature as the reason, + /// e.g. `&["print-im-a-teapot"]`. + fn masquerade_as_nightly_cargo(self, _reasons: &[&str]) -> Self; } impl ChannelChanger for &mut ProcessBuilder { - fn masquerade_as_nightly_cargo(self) -> Self { + fn masquerade_as_nightly_cargo(self, _reasons: &[&str]) -> Self { self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly") } } impl ChannelChanger for snapbox::cmd::Command { - fn masquerade_as_nightly_cargo(self) -> Self { + fn masquerade_as_nightly_cargo(self, _reasons: &[&str]) -> Self { self.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly") } } @@ -1197,7 +1209,7 @@ .current_dir(&paths::root()) .env("HOME", paths::home()) .env("CARGO_HOME", paths::home().join(".cargo")) - .env("__CARGO_TEST_ROOT", paths::root()) + .env("__CARGO_TEST_ROOT", paths::global_root()) // Force Cargo to think it's on the stable channel for all tests, this // should hopefully not surprise us as we add cargo features over time and // cargo rides the trains. @@ -1262,13 +1274,13 @@ /// Test the cargo command pub trait CargoCommand { - fn cargo() -> Self; + fn cargo_ui() -> Self; } impl CargoCommand for snapbox::cmd::Command { - fn cargo() -> Self { + fn cargo_ui() -> Self { Self::new(cargo_exe()) - .with_assert(compare::assert()) + .with_assert(compare::assert_ui()) .test_env() } } @@ -1342,16 +1354,6 @@ Duration::from_secs(*SLOW_CPU_MULTIPLIER * main) } -pub fn command_is_available(cmd: &str) -> bool { - if let Err(e) = process(cmd).arg("-V").exec_with_output() { - eprintln!("{} not available, skipping tests", cmd); - eprintln!("{:?}", e); - false - } else { - true - } -} - #[cfg(windows)] pub fn symlink_supported() -> bool { if is_ci() { diff -Nru cargo-0.64.0ubuntu0.libgit2/crates/cargo-test-support/src/paths.rs cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-test-support/src/paths.rs --- cargo-0.64.0ubuntu0.libgit2/crates/cargo-test-support/src/paths.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-test-support/src/paths.rs 2022-10-20 06:00:42.000000000 +0000 @@ -287,3 +287,61 @@ let sysroot = String::from_utf8(output.stdout).unwrap(); sysroot.trim().to_string() } + +/// Returns true if names such as aux.* are allowed. +/// +/// Traditionally, Windows did not allow a set of file names (see `is_windows_reserved` +/// for a list). More recent versions of Windows have relaxed this restriction. This test +/// determines whether we are running in a mode that allows Windows reserved names. +#[cfg(windows)] +pub fn windows_reserved_names_are_allowed() -> bool { + use cargo_util::is_ci; + + // Ensure tests still run in CI until we need to migrate. + if is_ci() { + return false; + } + + use std::ffi::OsStr; + use std::os::windows::ffi::OsStrExt; + use std::ptr; + use winapi::um::fileapi::GetFullPathNameW; + + let test_file_name: Vec<_> = OsStr::new("aux.rs").encode_wide().collect(); + + let buffer_length = + unsafe { GetFullPathNameW(test_file_name.as_ptr(), 0, ptr::null_mut(), ptr::null_mut()) }; + + if buffer_length == 0 { + // This means the call failed, so we'll conservatively assume reserved names are not allowed. + return false; + } + + let mut buffer = vec![0u16; buffer_length as usize]; + + let result = unsafe { + GetFullPathNameW( + test_file_name.as_ptr(), + buffer_length, + buffer.as_mut_ptr(), + ptr::null_mut(), + ) + }; + + if result == 0 { + // Once again, conservatively assume reserved names are not allowed if the + // GetFullPathNameW call failed. + return false; + } + + // Under the old rules, a file name like aux.rs would get converted into \\.\aux, so + // we detect this case by checking if the string starts with \\.\ + // + // Otherwise, the filename will be something like C:\Users\Foo\Documents\aux.rs + let prefix: Vec<_> = OsStr::new("\\\\.\\").encode_wide().collect(); + if buffer.starts_with(&prefix) { + false + } else { + true + } +} diff -Nru cargo-0.64.0ubuntu0.libgit2/crates/cargo-util/Cargo.toml cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-util/Cargo.toml --- cargo-0.64.0ubuntu0.libgit2/crates/cargo-util/Cargo.toml 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-util/Cargo.toml 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "cargo-util" -version = "0.2.1" +version = "0.2.2" edition = "2021" license = "MIT OR Apache-2.0" homepage = "https://github.com/rust-lang/cargo" diff -Nru cargo-0.64.0ubuntu0.libgit2/crates/cargo-util/src/process_builder.rs cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-util/src/process_builder.rs --- cargo-0.64.0ubuntu0.libgit2/crates/cargo-util/src/process_builder.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/crates/cargo-util/src/process_builder.rs 2022-10-20 06:00:42.000000000 +0000 @@ -40,7 +40,7 @@ /// See [`ProcessBuilder::retry_with_argfile`] for more information. retry_with_argfile: bool, /// Data to write to stdin. - stdin: Vec, + stdin: Option>, } impl fmt::Display for ProcessBuilder { @@ -82,7 +82,7 @@ jobserver: None, display_env_vars: false, retry_with_argfile: false, - stdin: Vec::new(), + stdin: None, } } @@ -212,7 +212,7 @@ /// Sets a value that will be written to stdin of the process on launch. pub fn stdin>>(&mut self, stdin: T) -> &mut Self { - self.stdin = stdin.into(); + self.stdin = Some(stdin.into()); self } @@ -284,18 +284,22 @@ fn _output(&self) -> io::Result { if !debug_force_argfile(self.retry_with_argfile) { let mut cmd = self.build_command(); - match piped(&mut cmd).spawn() { + match piped(&mut cmd, self.stdin.is_some()).spawn() { Err(ref e) if self.should_retry_with_argfile(e) => {} Err(e) => return Err(e), Ok(mut child) => { - child.stdin.take().unwrap().write_all(&self.stdin)?; + if let Some(stdin) = &self.stdin { + child.stdin.take().unwrap().write_all(stdin)?; + } return child.wait_with_output(); } } } let (mut cmd, argfile) = self.build_command_with_argfile()?; - let mut child = piped(&mut cmd).spawn()?; - child.stdin.take().unwrap().write_all(&self.stdin)?; + let mut child = piped(&mut cmd, self.stdin.is_some()).spawn()?; + if let Some(stdin) = &self.stdin { + child.stdin.take().unwrap().write_all(stdin)?; + } let output = child.wait_with_output(); close_tempfile_and_log_error(argfile); output @@ -340,14 +344,14 @@ let spawn = |mut cmd| { if !debug_force_argfile(self.retry_with_argfile) { - match piped(&mut cmd).spawn() { + match piped(&mut cmd, false).spawn() { Err(ref e) if self.should_retry_with_argfile(e) => {} Err(e) => return Err(e), Ok(child) => return Ok((child, None)), } } let (mut cmd, argfile) = self.build_command_with_argfile()?; - Ok((piped(&mut cmd).spawn()?, Some(argfile))) + Ok((piped(&mut cmd, false).spawn()?, Some(argfile))) }; let status = (|| { @@ -541,11 +545,15 @@ cfg!(debug_assertions) && env::var("__CARGO_TEST_FORCE_ARGFILE").is_ok() && retry_enabled } -/// Creates new pipes for stderr, stdout and stdin. -fn piped(cmd: &mut Command) -> &mut Command { +/// Creates new pipes for stderr, stdout, and optionally stdin. +fn piped(cmd: &mut Command, pipe_stdin: bool) -> &mut Command { cmd.stdout(Stdio::piped()) .stderr(Stdio::piped()) - .stdin(Stdio::piped()) + .stdin(if pipe_stdin { + Stdio::piped() + } else { + Stdio::null() + }) } fn close_tempfile_and_log_error(file: NamedTempFile) { diff -Nru cargo-0.64.0ubuntu0.libgit2/crates/resolver-tests/src/lib.rs cargo-0.66.0+ds0ubuntu0.libgit2/crates/resolver-tests/src/lib.rs --- cargo-0.64.0ubuntu0.libgit2/crates/resolver-tests/src/lib.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/crates/resolver-tests/src/lib.rs 2022-10-20 06:00:42.000000000 +0000 @@ -12,7 +12,7 @@ use cargo::core::dependency::DepKind; use cargo::core::resolver::{self, ResolveOpts, VersionPreferences}; -use cargo::core::source::{GitReference, SourceId}; +use cargo::core::source::{GitReference, QueryKind, SourceId}; use cargo::core::Resolve; use cargo::core::{Dependency, PackageId, Registry, Summary}; use cargo::util::{CargoResult, Config, Graph, IntoUrl}; @@ -128,11 +128,15 @@ fn query( &mut self, dep: &Dependency, + kind: QueryKind, f: &mut dyn FnMut(Summary), - fuzzy: bool, ) -> Poll> { for summary in self.list.iter() { - if fuzzy || dep.matches(summary) { + let matched = match kind { + QueryKind::Exact => dep.matches(summary), + QueryKind::Fuzzy => true, + }; + if matched { self.used.insert(summary.package_id()); f(summary.clone()); } diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/changelog cargo-0.66.0+ds0ubuntu0.libgit2/debian/changelog --- cargo-0.64.0ubuntu0.libgit2/debian/changelog 2022-12-01 13:37:34.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/changelog 2023-01-18 20:42:34.000000000 +0000 @@ -1,11 +1,63 @@ -cargo (0.64.0ubuntu0.libgit2-0ubuntu0.22.04) jammy; urgency=medium +cargo (0.66.0+ds0ubuntu0.libgit2-0ubuntu0.22.04) jammy; urgency=medium - * Backport to jammy (LP: #1995096) - * Re-vendor libgit2 C lib and revert associated patch - * d/rules: Remove the vendored sources tracking code since deps - aren't available + * Backport to Jammy (LP: #2000839) + * Re-enable libgit2 vendoring: + - d/control: remove libgit2-dev and libhttp-parser-dev from B-D + - include Rust provided patches to fix CVE-2022-46176 + * Remove the need of dh-cargo - -- Simon Chopin Thu, 01 Dec 2022 14:37:34 +0100 + -- Zixing Liu Wed, 18 Jan 2023 13:42:34 -0700 + +cargo (0.66.0+ds1-1ubuntu1) lunar; urgency=medium + + * Merge from Debian unstable (LP: #2000839): + Remaining changes: + - Add an explicit mechanism to customize the vendoring process + - d/p/proxy-skip-tests.patch: skip a test when there's a proxy configured + to accommodate Ubuntu autopkgtest setup + - d/p/i386-crossbuild-tests.patch: disable some failing tests for + cross-building from i386 + - d/p/remove-badges.patch: remove badges from documentation for privacy + reasons (refreshed) + - autopkgtests: test on all arches on Ubuntu + - d/control: update the Vcs fields to point to Launchpad + - make_orig_multi.sh: fix orig tarball compression to xz on Ubuntu + - Track vendored dependencies + - Bump the libgit2-related crates to get libgit2 1.5.0 bindings + - make_orig_multi.sh: only use xz for vendor orig tarball on Ubuntu + * Update vendored sources information + + -- Simon Chopin Tue, 17 Jan 2023 14:48:37 +0100 + +cargo (0.66.0+ds1-1) unstable; urgency=medium + + [ Fabian Grünbichler ] + * fix CVE-2022-46176 (Thanks Peter Green!) + * repack vendored sources with required libgit2-sys/git2/git2-curl versions + * update unsuspicious files + + -- Fabian Gruenbichler Wed, 11 Jan 2023 18:55:09 +0100 + +cargo (0.66.0-1) unstable; urgency=medium + + * new upstream version 0.66 + + [ Blair Noctis ] + * Update debcargo-conf.patch, unapply tempfile patch to match vendored + * Refresh patches and remove upstream applied CVE patches + * Patch test macro to work around qemu vfork bug when command not found + + [ Fabian Grünbichler ] + * no longer pin git2/libgit2-sys + * update debcargo-conf.patch (concolor, clap) + * update unsuspicious files + * d/control: depend on rustc 1.63 + * drop armel workaround + + [ Rob Shearman ] + * d/control: update minimum cargo, rustc and libstd-rust-dev versions + + -- Fabian Gruenbichler Sun, 08 Jan 2023 16:38:30 +0100 cargo (0.64.0ubuntu1-0ubuntu1) lunar; urgency=medium @@ -16,13 +68,19 @@ -- Simon Chopin Tue, 29 Nov 2022 15:05:19 +0100 +cargo (0.63.1-3) unstable; urgency=medium + + * workaround armel breakage + + -- Fabian Gruenbichler Wed, 07 Dec 2022 14:58:58 +0100 + cargo (0.63.1-2ubuntu1) lunar; urgency=medium * Merge from Debian unstable. Remaining changes: - Add an explicit mechanism to customize the vendoring process - d/p/proxy-skip-tests.patch: skip a test when there's a proxy configured - to accomodate Ubuntu autopkgtest setup + to accommodate Ubuntu autopkgtest setup - d/p/i386-crossbuild-tests.patch: disable some failing tests for cross-building from i386 - d/p/remove-badges.patch: remove badges from documentation for privacy @@ -80,7 +138,7 @@ * d/p/remove-badges.patch: remove badges from documentation for privacy reasons * d/p/proxy-skip-tests.patch: skip a test when there's a proxy configured - to accomodate Ubuntu autopkgtest setup + to accommodate Ubuntu autopkgtest setup -- Simon Chopin Fri, 24 Jun 2022 11:17:27 +0200 @@ -167,6 +225,7 @@ [ Simon Chopin ] * Add an autopkgtest for cargo to build itself + * Disable cross-build tests in autopkgtests [ Ximin Luo ] * Fix FTBFS on x32. diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/control cargo-0.66.0+ds0ubuntu0.libgit2/debian/control --- cargo-0.64.0ubuntu0.libgit2/debian/control 2022-12-01 13:37:34.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/control 2023-01-18 20:42:34.000000000 +0000 @@ -11,9 +11,9 @@ Build-Depends: debhelper (>= 12~), dpkg-dev (>= 1.17.14), - cargo:native (>= 0.17.0), - rustc:native (>= 1.16), - libstd-rust-dev (>= 1.16), + cargo:native (>= 0.56.0), + rustc:native (>= 1.63), + libstd-rust-dev (>= 1.63), pkg-config, bash-completion, python3:native, @@ -29,7 +29,7 @@ XSBC-Original-Vcs-Browser: https://salsa.debian.org/rust-team/cargo Vcs-Git: https://git.launchpad.net/~canonical-foundations/ubuntu/+source/cargo Vcs-Browser: https://git.launchpad.net/~canonical-foundations/ubuntu/+source/cargo -XS-Vendored-Sources-Rust: adler@1.0.2, aho-corasick@0.7.20, anyhow@1.0.66, arrayvec@0.5.2, atty@0.2.14, autocfg@1.1.0, bitflags@1.3.2, bitmaps@2.1.0, bstr@0.2.17, bytes@1.3.0, bytesize@1.1.0, cc@1.0.77, cfg-if@1.0.0, clap@3.2.23, clap_lex@0.2.4, combine@4.6.6, commoncrypto-sys@0.2.0, commoncrypto@0.2.0, concolor-query@0.0.5, concolor@0.0.8, content_inspector@0.2.4, core-foundation-sys@0.8.3, core-foundation@0.9.3, crc32fast@1.3.2, crossbeam-utils@0.8.14, crypto-hash@0.3.4, curl-sys@0.4.59+curl-7.86.0, curl@0.4.44, dunce@1.0.3, either@1.8.0, env_logger@0.7.1, env_logger@0.9.3, fastrand@1.8.0, filetime@0.2.18, flate2@1.0.25, fnv@1.0.7, foreign-types-shared@0.1.1, foreign-types@0.3.2, form_urlencoded@1.1.0, fwdansi@1.1.0, git2-curl@0.15.0, git2@0.14.4, glob@0.3.0, globset@0.4.9, hashbrown@0.12.3, hex@0.4.3, home@0.5.4, humantime@1.3.0, humantime@2.1.0, idna@0.3.0, ignore@0.4.18, im-rc@15.1.0, indexmap@1.9.2, itertools@0.10.5, itoa@1.0.4, jobserver@0.1.25, kstring@2.0.0, lazy_static@1.4.0, lazycell@1.3.0, libc@0.2.137, libgit2-sys@0.13.4+1.4.2, libnghttp2-sys@0.1.7+1.45.0, libssh2-sys@0.2.23, libz-sys@1.1.8, log@0.4.17, memchr@2.5.0, miniz_oxide@0.6.2, miow@0.3.7, normalize-line-endings@0.3.0, num_cpus@1.14.0, once_cell@1.16.0, opener@0.5.0, openssl-macros@0.1.0, openssl-probe@0.1.5, openssl-sys@0.9.78, openssl@0.10.43, os_info@3.5.1, os_str_bytes@6.4.1, pathdiff@0.2.1, percent-encoding@2.2.0, pkg-config@0.3.26, pretty_env_logger@0.4.0, proc-macro2@1.0.47, quick-error@1.2.3, quote@1.0.21, rand_core@0.6.4, rand_xoshiro@0.6.0, redox_syscall@0.2.16, regex-automata@0.1.10, regex-syntax@0.6.28, regex@1.7.0, remove_dir_all@0.5.3, rustc-workspace-hack@1.0.0, rustfix@0.6.1, ryu@1.0.11, same-file@1.0.6, semver@1.0.14, serde@1.0.148, serde_derive@1.0.148, serde_ignored@0.1.5, serde_json@1.0.89, shell-escape@0.1.5, similar@2.2.1, sized-chunks@0.6.5, snapbox-macros@0.2.1, snapbox@0.2.10, socket2@0.4.7, static_assertions@1.1.0, strip-ansi-escapes@0.1.1, strsim@0.10.0, syn@1.0.104, tar@0.4.38, tempfile@3.3.0, termcolor@1.1.3, textwrap@0.16.0, thread_local@1.1.4, tinyvec@1.6.0, tinyvec_macros@0.1.0, toml_edit@0.14.4, typenum@1.15.0, unicode-bidi@0.3.8, unicode-ident@1.0.5, unicode-normalization@0.1.22, unicode-width@0.1.10, unicode-xid@0.2.4, url@2.3.1, utf8parse@0.2.0, vcpkg@0.2.15, version_check@0.9.4, vte@0.10.1, vte_generate_state_changes@0.1.1, walkdir@2.3.2, winapi-i686-pc-windows-gnu@0.4.0, winapi-util@0.1.5, winapi-x86_64-pc-windows-gnu@0.4.0, winapi@0.3.9, yansi@0.5.1 +XS-Vendored-Sources-Rust: adler@1.0.2, aho-corasick@0.7.20, anyhow@1.0.68, arrayvec@0.5.2, atty@0.2.14, autocfg@1.1.0, base64@0.13.1, bitflags@1.3.2, bitmaps@2.1.0, block-buffer@0.10.3, bstr@0.2.17, bstr@1.1.0, bytes@1.3.0, bytesize@1.1.0, cc@1.0.78, cfg-if@1.0.0, clap@3.2.23, clap_lex@0.2.4, combine@4.6.6, commoncrypto-sys@0.2.0, commoncrypto@0.2.0, concolor-query@0.0.5, concolor@0.0.8, content_inspector@0.2.4, core-foundation-sys@0.8.3, core-foundation@0.9.3, cpufeatures@0.2.5, crc32fast@1.3.2, crypto-common@0.1.6, crypto-hash@0.3.4, curl-sys@0.4.59+curl-7.86.0, curl@0.4.44, digest@0.10.6, dunce@1.0.3, either@1.8.0, env_logger@0.7.1, env_logger@0.9.3, fastrand@1.8.0, filetime@0.2.19, flate2@1.0.25, fnv@1.0.7, foreign-types-shared@0.1.1, foreign-types@0.3.2, form_urlencoded@1.1.0, fwdansi@1.1.0, generic-array@0.14.6, git2-curl@0.17.0, git2@0.16.0, glob@0.3.1, globset@0.4.10, hashbrown@0.12.3, hex@0.4.3, hmac@0.12.1, home@0.5.4, humantime@1.3.0, humantime@2.1.0, idna@0.3.0, ignore@0.4.19, im-rc@15.1.0, indexmap@1.9.2, itertools@0.10.5, itoa@1.0.5, jobserver@0.1.25, kstring@2.0.0, lazy_static@1.4.0, lazycell@1.3.0, libc@0.2.139, libgit2-sys@0.14.1+1.5.0, libnghttp2-sys@0.1.7+1.45.0, libssh2-sys@0.2.23, libz-sys@1.1.8, log@0.4.17, memchr@2.5.0, miniz_oxide@0.6.2, miow@0.3.7, normalize-line-endings@0.3.0, once_cell@1.17.0, opener@0.5.0, openssl-macros@0.1.0, openssl-probe@0.1.5, openssl-sys@0.9.80, openssl@0.10.45, os_info@3.5.1, os_str_bytes@6.4.1, pathdiff@0.2.1, percent-encoding@2.2.0, pkg-config@0.3.26, pretty_env_logger@0.4.0, proc-macro2@1.0.49, quick-error@1.2.3, quote@1.0.23, rand_core@0.6.4, rand_xoshiro@0.6.0, redox_syscall@0.2.16, regex-automata@0.1.10, regex-syntax@0.6.28, regex@1.7.0, remove_dir_all@0.5.3, rustc-workspace-hack@1.0.0, rustfix@0.6.1, ryu@1.0.12, same-file@1.0.6, schannel@0.1.19, semver@1.0.16, serde@1.0.152, serde_derive@1.0.152, serde_ignored@0.1.7, serde_json@1.0.91, sha1@0.10.5, shell-escape@0.1.5, similar@2.2.1, sized-chunks@0.6.5, snapbox-macros@0.3.1, snapbox@0.3.3, socket2@0.4.7, static_assertions@1.1.0, strip-ansi-escapes@0.1.1, strsim@0.10.0, subtle@2.4.1, syn@1.0.107, tar@0.4.38, tempfile@3.3.0, termcolor@1.1.3, textwrap@0.16.0, thread_local@1.1.4, tinyvec@1.6.0, tinyvec_macros@0.1.0, toml_edit@0.14.4, typenum@1.16.0, unicode-bidi@0.3.8, unicode-ident@1.0.6, unicode-normalization@0.1.22, unicode-width@0.1.10, unicode-xid@0.2.4, url@2.3.1, utf8parse@0.2.0, vcpkg@0.2.15, version_check@0.9.4, vte@0.10.1, vte_generate_state_changes@0.1.1, walkdir@2.3.2, winapi-i686-pc-windows-gnu@0.4.0, winapi-util@0.1.5, winapi-x86_64-pc-windows-gnu@0.4.0, winapi@0.3.9, yansi@0.5.1 Package: cargo Architecture: any diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/copyright cargo-0.66.0+ds0ubuntu0.libgit2/debian/copyright --- cargo-0.64.0ubuntu0.libgit2/debian/copyright 2022-12-01 12:18:16.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/copyright 2023-01-17 14:05:25.000000000 +0000 @@ -120,12 +120,25 @@ see https://github.com/bluss/either see https://github.com/rust-itertools/itertools +Files: vendor/base64/* +Copyright: 2015-2023 Alice Maz + 2015-2023 Marshall Pierce +License: MIT or Apache-2.0 +Comment: see https://github.com/marshallpierce/rust-base64 + Files: vendor/bitmaps/* Copyright: 2019-2020 Bodil Stokke License: MPL-2.0+ Comment: see https://github.com/bodil/bitmaps -Files: vendor/bstr/* +Files: vendor/block-buffer/* +Copyright: 2016-2023 RustCrypto Developers +License: MIT OR Apache-2.0 +Comment: see https://github.com/RustCrypto/utils + +Files: + vendor/bstr/* + vendor/bstr-*/* Copyright: 2015-2019 Andrew Gallant License: MIT or Apache-2.0 Comment: @@ -177,6 +190,11 @@ License: MIT or Apache-2.0 Comment: see https://github.com/servo/core-foundation-rs +Files: vendor/cpufeatures/* +Copyright: 2016-2023 RustCrypto Developers +License: MIT OR Apache-2.0 +Comment: see https://github.com/RustCrypto/utils + Files: vendor/crc32fast/* Copyright: 2018, Sam Rijs 2018, Alex Crichton @@ -187,6 +205,11 @@ License: MIT or Apache-2.0 Comment: see https://github.com/crossbeam-rs +Files: vendor/crypto-common/* +Copyright: 2017-2023 RustCrypto Developers +License: MIT OR Apache-2.0 +Comment: see https://github.com/RustCrypto/traits + Files: vendor/commoncrypto/* vendor/commoncrypto-sys/* vendor/crypto-hash/* @@ -203,6 +226,11 @@ License: MIT Comment: see https://github.com/alexcrichton/curl-rust +Files: vendor/digest/* +Copyright: 2017-2023 RustCrypto Developers +License: MIT OR Apache-2.0 +Comment: see https://github.com/RustCrypto/traits + Files: vendor/dunce/* Copyright: 2017-2021 Kornel License: CC0-1.0 @@ -213,6 +241,12 @@ License: Apache-2.0 OR MIT Comment: see https://github.com/smol-rs/fastrand +Files: vendor/generic-array/* +Copyright: 2015-2022 Bartłomiej Kamiński + 2015-2022 Aaron Trent +License: MIT +Comment: see https://github.com/fizyk20/generic-array.git + Files: vendor/hashbrown/* Copyright: 2018-2022 Amanieu d'Antras License: MIT OR Apache-2.0 @@ -225,6 +259,11 @@ License: MIT or Apache-2.0 Comment: see https://github.com/KokaKiwi/rust-hex +Files: vendor/hmac/* +Copyright: 2017-2023 RustCrypto Developers +License: MIT OR Apache-2.0 +Comment: see https://github.com/RustCrypto/MACs + Files: vendor/home/* Copyright: Brian Anderson License: MIT or Apache-2.0 @@ -400,6 +439,11 @@ Comment: see https://github.com/serde-rs see https://github.com/dtolnay/serde-ignored +Files: vendor/sha1/* +Copyright: 2016-2022 RustCrypto Developers +License: MIT OR Apache-2.0 +Comment: see https://github.com/RustCrypto/hashes + Files: vendor/similar/* Copyright: 2021-2022 Armin Ronacher 2021-2022 Pierre-Étienne Meunier @@ -428,6 +472,12 @@ License: MIT Comment: see https://github.com/dguo/strsim-rs +Files: vendor/subtle/* +Copyright: 2017-2021 Isis Lovecruft + 2017-2021 Henry de Valence +License: BSD-3-Clause +Comment: see https://github.com/dalek-cryptography/subtle + Files: vendor/syn/* Copyright: 2016-2017 David Tolnay License: MIT or Apache-2.0 diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/debcargo-conf.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/debcargo-conf.patch --- cargo-0.64.0ubuntu0.libgit2/debian/debcargo-conf.patch 2022-12-01 12:18:16.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/debcargo-conf.patch 2023-01-17 13:25:36.000000000 +0000 @@ -7,9 +7,296 @@ even un-re-written ones that were published to crates.io. The patch below rewrites our existing patches so they work against the un-re-written ones. -- unicode-normalization, vte: have dependency relaxation that applies, but - doesn't match the vendored copy +- unicode-normalization, vte, tempfile: have dependency relaxation that applies, + but doesn't match the vendored copy +- concolor: more recent version in debcargo-conf, can be dropped once cargo + upstream updates + +- clap: clap is v4 in debcargo-conf, patches from clap-3 temporarily patched in + until we update to a cargo version using clap 4.x + +diff --git a/src/clap/debian/patches/disable-derive-deprecated.patch b/src/clap/debian/patches/disable-derive-deprecated.patch +new file mode 100644 +index 000000000..6ed82171f +--- /dev/null ++++ b/src/clap/debian/patches/disable-derive-deprecated.patch +@@ -0,0 +1,11 @@ ++--- a/Cargo.toml +++++ b/Cargo.toml ++@@ -418,7 +418,7 @@ ++ "color", ++ "suggestions", ++ ] ++-deprecated = ["clap_derive/deprecated"] +++deprecated = [] ++ derive = [ ++ "clap_derive", ++ "once_cell", +diff --git a/src/clap/debian/patches/disable-snapbox.patch b/src/clap/debian/patches/disable-snapbox.patch +index a6fbd083a..9335518c4 100644 +--- a/src/clap/debian/patches/disable-snapbox.patch ++++ b/src/clap/debian/patches/disable-snapbox.patch +@@ -1,6 +1,12 @@ + --- a/Cargo.toml + +++ b/Cargo.toml +-@@ -400,3 +399,0 @@ ++@@ -397,9 +397,6 @@ ++ [dev-dependencies.shlex] ++ version = "1.1.0" ++ + -[dev-dependencies.snapbox] +--version = "0.4" ++-version = "0.2.9" + - ++ [dev-dependencies.static_assertions] ++ version = "1.1.0" ++ +diff --git a/src/clap/debian/patches/disable-trycmd.diff b/src/clap/debian/patches/disable-trycmd.diff +index aeb0bbad4..053bf14f9 100644 +--- a/src/clap/debian/patches/disable-trycmd.diff ++++ b/src/clap/debian/patches/disable-trycmd.diff +@@ -1,8 +1,11 @@ + --- a/Cargo.toml + +++ b/Cargo.toml +-@@ -413,9 +412,0 @@ ++@@ -410,15 +410,6 @@ ++ [dev-dependencies.trybuild] ++ version = "1.0.18" ++ + -[dev-dependencies.trycmd] +--version = "0.14.3" ++-version = "0.13" + -features = [ + - "color-auto", + - "diff", +@@ -10,3 +13,6 @@ + -] + -default-features = false + - ++ [features] ++ cargo = ["once_cell"] ++ color = [ +diff --git a/src/clap/debian/patches/disable-unic-emoji-char.patch b/src/clap/debian/patches/disable-unic-emoji-char.patch +deleted file mode 100644 +index 97aa25af0..000000000 +--- a/src/clap/debian/patches/disable-unic-emoji-char.patch ++++ /dev/null +@@ -1,36 +0,0 @@ +-Index: clap/Cargo.toml +-=================================================================== +---- clap.orig/Cargo.toml +-+++ clap/Cargo.toml +-@@ -408,9 +408,6 @@ version = "1.1.0" +- [dev-dependencies.trybuild] +- version = "1.0.71" +- +--[dev-dependencies.unic-emoji-char] +--version = "0.9.0" +-- +- [features] +- cargo = ["dep:once_cell"] +- color = [ +-Index: clap/src/output/textwrap/core.rs +-=================================================================== +---- clap.orig/src/output/textwrap/core.rs +-+++ clap/src/output/textwrap/core.rs +-@@ -90,7 +90,7 @@ mod tests { +- #[cfg(feature = "unicode")] +- use unicode_width::UnicodeWidthChar; +- +-- #[test] +-+ /*#[test] +- fn emojis_have_correct_width() { +- use unic_emoji_char::is_emoji; +- +-@@ -129,7 +129,7 @@ mod tests { +- +- // The remaining planes contain almost no assigned code points +- // and thus also no emojis. +-- } +-+ }*/ +- +- #[test] +- #[cfg(feature = "unicode")] +diff --git a/src/clap/debian/patches/disable-unstable-doc.patch b/src/clap/debian/patches/disable-unstable-doc.patch +index 00de9ce79..404f1d9cf 100644 +--- a/src/clap/debian/patches/disable-unstable-doc.patch ++++ b/src/clap/debian/patches/disable-unstable-doc.patch +@@ -1,25 +1,38 @@ + --- a/Cargo.toml + +++ b/Cargo.toml +-@@ -39,3 +39,2 @@ ++@@ -37,7 +37,6 @@ ++ repository = "https://github.com/clap-rs/clap" ++ + [package.metadata.docs.rs] + -features = ["unstable-doc"] + rustdoc-args = [ +-@@ -49,5 +48,2 @@ ++ "--cfg", ++ "docsrs", ++@@ -47,9 +46,6 @@ ++ "-Zrustdoc-scrape-examples=examples", ++ ] + + -[package.metadata.playground] + -features = ["unstable-doc"] + - + [package.metadata.release] +-@@ -439,12 +435,2 @@ ++ shared-version = true ++ tag-name = "v{{version}}" ++@@ -437,17 +433,6 @@ ++ "textwrap/unicode-width", ++ "unicase", + ] + -unstable-doc = [ + - "derive", + - "cargo", + - "wrap_help", ++- "yaml", + - "env", + - "unicode", +-- "string", ++- "regex", + - "unstable-replace", + - "unstable-grouped", + -] + unstable-grouped = [] ++ unstable-replace = [] ++ unstable-v4 = [ +diff --git a/src/clap/debian/patches/disable-unstable-v4.patch b/src/clap/debian/patches/disable-unstable-v4.patch +new file mode 100644 +index 000000000..2993a959a +--- /dev/null ++++ b/src/clap/debian/patches/disable-unstable-v4.patch +@@ -0,0 +1,13 @@ ++--- a/Cargo.toml +++++ b/Cargo.toml ++@@ -435,10 +435,6 @@ ++ ] ++ unstable-grouped = [] ++ unstable-replace = [] ++-unstable-v4 = [ ++- "clap_derive/unstable-v4", ++- "deprecated", ++-] ++ wrap_help = [ ++ "terminal_size", ++ "textwrap/terminal_size", +diff --git a/src/clap/debian/patches/disable-unstable-v5.patch b/src/clap/debian/patches/disable-unstable-v5.patch +deleted file mode 100644 +index 5c2a59a30..000000000 +--- a/src/clap/debian/patches/disable-unstable-v5.patch ++++ /dev/null +@@ -1,7 +0,0 @@ +---- a/Cargo.toml +-+++ b/Cargo.toml +-@@ -438,4 +437,0 @@ +--unstable-v5 = [ +-- "clap_derive?/unstable-v5", +-- "deprecated", +--] +diff --git a/src/clap/debian/patches/once-cell-non-optional.patch b/src/clap/debian/patches/once-cell-non-optional.patch +new file mode 100644 +index 000000000..0e6692e81 +--- /dev/null ++++ b/src/clap/debian/patches/once-cell-non-optional.patch +@@ -0,0 +1,29 @@ ++--- a/Cargo.toml +++++ b/Cargo.toml ++@@ -354,7 +354,6 @@ ++ ++ [dependencies.once_cell] ++ version = "1.12.0" ++-optional = true ++ ++ [dependencies.regex] ++ version = "1.0" ++@@ -404,7 +403,7 @@ ++ version = "1.0.18" ++ ++ [features] ++-cargo = ["once_cell"] +++cargo = [] ++ color = [ ++ "atty", ++ "termcolor", ++@@ -420,8 +419,7 @@ ++ ] ++ deprecated = [] ++ derive = [ ++- "clap_derive", ++- "once_cell", +++ "clap_derive" ++ ] ++ env = [] ++ std = ["indexmap/std"] +diff --git a/src/clap/debian/patches/revert-switch-to-is-terminal.patch b/src/clap/debian/patches/revert-switch-to-is-terminal.patch +deleted file mode 100644 +index 425ff3aca..000000000 +--- a/src/clap/debian/patches/revert-switch-to-is-terminal.patch ++++ /dev/null +@@ -1,44 +0,0 @@ +-Index: clap/src/output/fmt.rs +-=================================================================== +---- clap.orig/src/output/fmt.rs +-+++ clap/src/output/fmt.rs +-@@ -82,9 +82,10 @@ impl std::fmt::Display for Colorizer { +- +- #[cfg(feature = "color")] +- fn is_a_tty(stream: Stream) -> bool { +-- use is_terminal::IsTerminal; +-- match stream { +-- Stream::Stdout => std::io::stdout().is_terminal(), +-- Stream::Stderr => std::io::stderr().is_terminal(), +-- } +-+ let stream = match stream { +-+ Stream::Stdout => atty::Stream::Stdout, +-+ Stream::Stderr => atty::Stream::Stderr, +-+ }; +-+ +-+ atty::is(stream) +- } +-Index: clap/Cargo.toml +-=================================================================== +---- clap.orig/Cargo.toml +-+++ clap/Cargo.toml +-@@ -365,8 +365,8 @@ optional = true +- [dependencies.clap_lex] +- version = "0.3.0" +- +--[dependencies.is-terminal] +--version = "0.4.1" +-+[dependencies.atty] +-+version = "0.2" +- optional = true +- +- [dependencies.once_cell] +-@@ -414,7 +414,7 @@ version = "0.9.0" +- [features] +- cargo = ["dep:once_cell"] +- color = [ +-- "dep:is-terminal", +-+ "dep:atty", +- "dep:termcolor", +- ] +- debug = [ +diff --git a/src/clap/debian/patches/series b/src/clap/debian/patches/series +index 137658685..47bdb2c6b 100644 +--- a/src/clap/debian/patches/series ++++ b/src/clap/debian/patches/series +@@ -1,6 +1,6 @@ + disable-trycmd.diff + disable-unstable-doc.patch +-disable-unstable-v5.patch ++disable-unstable-v4.patch + disable-snapbox.patch +-revert-switch-to-is-terminal.patch +-disable-unic-emoji-char.patch ++disable-derive-deprecated.patch ++once-cell-non-optional.patch diff --git a/src/commoncrypto-sys/debian/patches/no-clippy.patch b/src/commoncrypto-sys/debian/patches/no-clippy.patch index 3e4c8850e..93789f3b8 100644 --- a/src/commoncrypto-sys/debian/patches/no-clippy.patch @@ -76,6 +363,21 @@ +- + [dev-dependencies] + hex = "0.2" +diff --git a/src/concolor/debian/patches/series b/src/concolor/debian/patches/series +index cdf075927..942673b44 100644 +--- a/src/concolor/debian/patches/series ++++ b/src/concolor/debian/patches/series +@@ -1,2 +1,2 @@ + avoid-doctest-breakage.patch +-switch-back-to-atty.patch ++#switch-back-to-atty.patch +diff --git a/src/tempfile/debian/patches/series b/src/tempfile/debian/patches/series +index 75abb7f14..2378a84ba 100644 +--- a/src/tempfile/debian/patches/series ++++ b/src/tempfile/debian/patches/series +@@ -1 +1 @@ +-relax-dep.diff ++#relax-dep.diff diff --git a/src/unicode-normalization/debian/patches/series b/src/unicode-normalization/debian/patches/series index 2c1db10bd..39fe7a4da 100644 --- a/src/unicode-normalization/debian/patches/series diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/debcargo-ubuntu/0001-libgit2-re-enable-the-C-library-vendoring.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/debcargo-ubuntu/0001-libgit2-re-enable-the-C-library-vendoring.patch --- cargo-0.64.0ubuntu0.libgit2/debian/debcargo-ubuntu/0001-libgit2-re-enable-the-C-library-vendoring.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/debcargo-ubuntu/0001-libgit2-re-enable-the-C-library-vendoring.patch 2023-01-18 20:42:34.000000000 +0000 @@ -0,0 +1,36 @@ +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 0d1188a48..b8de81ac0 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 90136830c..4ffa526de 100644 +--- a/src/libgit2-sys/debian/patches/series ++++ b/src/libgit2-sys/debian/patches/series +@@ -1,2 +1,2 @@ + remove-zlib-ng-compat.patch +-disable-vendor.patch ++# disable-vendor.patch +-- +2.34.1 + diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/debcargo-ubuntu/README cargo-0.66.0+ds0ubuntu0.libgit2/debian/debcargo-ubuntu/README --- cargo-0.64.0ubuntu0.libgit2/debian/debcargo-ubuntu/README 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/debcargo-ubuntu/README 2023-01-18 20:42:34.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.64.0ubuntu0.libgit2/debian/debcargo-ubuntu/series cargo-0.66.0+ds0ubuntu0.libgit2/debian/debcargo-ubuntu/series --- cargo-0.64.0ubuntu0.libgit2/debian/debcargo-ubuntu/series 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/debcargo-ubuntu/series 2023-01-18 20:42:34.000000000 +0000 @@ -0,0 +1 @@ +0001-libgit2-re-enable-the-C-library-vendoring.patch diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/make_orig_multi-pre-vendor.sh cargo-0.66.0+ds0ubuntu0.libgit2/debian/make_orig_multi-pre-vendor.sh --- cargo-0.64.0ubuntu0.libgit2/debian/make_orig_multi-pre-vendor.sh 2022-12-01 12:18:16.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/make_orig_multi-pre-vendor.sh 2023-01-18 20:42:34.000000000 +0000 @@ -15,12 +15,14 @@ # Drop the "vendored" feature since we patch it out of debcargo sed -i /vendored/d Cargo.toml -# cargo 0.57 can't download the newest libgit2-sys version -cargo update -p git2@0.15.0 -p libgit2-sys@0.14.0+1.5.0 -p git2-curl@0.16.0 -sed -i 's/git2 = "0.14.2"/git2 = "0.15.0"/' Cargo.toml -sed -i 's/git2 = "0.14.2"/git2 = "0.15.0"/' crates/cargo-test-support/Cargo.toml -sed -i 's/libgit2-sys = "0.13.2"/libgit2-sys = "0.14.0+1.5.0"/' Cargo.toml -sed -i 's/git2-curl = "0.15.0"/git2-curl = "0.16.0"/' Cargo.toml - # avoid pulling in windows-sys for now -# cargo update -p schannel --precise 0.1.19 +cargo update -p schannel --precise 0.1.19 + +# pin the dependencies as Debian intended +cargo update -p ignore --precise 0.4.19 +cargo update -p regex --precise 1.7.0 +cargo update -p proc-macro2 --precise 1.0.49 +cargo update -p termcolor --precise 1.1.3 +cargo update -p git2 --precise 0.16.0 +cargo update -p libgit2-sys --precise 0.14.1+1.5.0 +cargo update -p unicode-bidi --precise 0.3.8 diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/make_orig_multi.sh cargo-0.66.0+ds0ubuntu0.libgit2/debian/make_orig_multi.sh --- cargo-0.64.0ubuntu0.libgit2/debian/make_orig_multi.sh 2022-12-01 12:18:16.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/make_orig_multi.sh 2023-01-17 14:08:25.000000000 +0000 @@ -34,6 +34,14 @@ tar -xaf "${TMPDIR}/cargo_${CARGO_VER}.orig.tar.gz" -C cargo --strip-components=1 cd cargo +# special patch for CVE fix - we want to vendor the updated/fixed dependencies! +echo "Applying CVE-2022-46176 patches"; +for p in "${SRCDIR}/debian/patches/cve/"*.patch; do + echo "$(basename "$p")" + patch -p1 < "$p" + echo "$p" >> .cve-patches +done + # Download build-deps via cargo-vendor export GIT_AUTHOR_NAME="deb-build" export GIT_AUTHOR_EMAIL="<>" @@ -55,6 +63,14 @@ rm -rf vendor-scan +# special patch for CVE fix - unapply to keep orig.tar.gz pristine +echo "Unapplying CVE-2022-46176 patches"; +tac .cve-patches | while read p; do + echo "$(basename "$p")" + patch -Rp1 < "$p" +done +rm .cve-patches + # Pack it up, reproducibly tar --sort=name \ --auto-compress \ diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/0001-CVE-2022-36113-avoid-unpacking-.cargo-ok-from-the-cr.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/0001-CVE-2022-36113-avoid-unpacking-.cargo-ok-from-the-cr.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/0001-CVE-2022-36113-avoid-unpacking-.cargo-ok-from-the-cr.patch 2022-12-01 12:18:16.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/0001-CVE-2022-36113-avoid-unpacking-.cargo-ok-from-the-cr.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -From c4de262f1f6e813e06981c3d635c009d4f5d7082 Mon Sep 17 00:00:00 2001 -From: Josh Triplett -Date: Thu, 18 Aug 2022 17:17:19 +0200 -Subject: [PATCH 1/2] CVE-2022-36113: avoid unpacking .cargo-ok from the crate - ---- - src/cargo/sources/registry/mod.rs | 15 ++++++++++----- - 1 file changed, 10 insertions(+), 5 deletions(-) - -diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs -index 413734e10..b28bc4942 100644 ---- a/src/cargo/sources/registry/mod.rs -+++ b/src/cargo/sources/registry/mod.rs -@@ -639,6 +639,13 @@ impl<'cfg> RegistrySource<'cfg> { - prefix - ) - } -+ // Prevent unpacking the lockfile from the crate itself. -+ if entry_path -+ .file_name() -+ .map_or(false, |p| p == PACKAGE_SOURCE_LOCK) -+ { -+ continue; -+ } - // Unpacking failed - let mut result = entry.unpack_in(parent).map_err(anyhow::Error::from); - if cfg!(windows) && restricted_names::is_windows_reserved_path(&entry_path) { -@@ -654,16 +661,14 @@ impl<'cfg> RegistrySource<'cfg> { - .with_context(|| format!("failed to unpack entry at `{}`", entry_path.display()))?; - } - -- // The lock file is created after unpacking so we overwrite a lock file -- // which may have been extracted from the package. -+ // Now that we've finished unpacking, create and write to the lock file to indicate that -+ // unpacking was successful. - let mut ok = OpenOptions::new() -- .create(true) -+ .create_new(true) - .read(true) - .write(true) - .open(&path) - .with_context(|| format!("failed to open `{}`", path.display()))?; -- -- // Write to the lock file to indicate that unpacking was successful. - write!(ok, "ok")?; - - Ok(unpack_dir.to_path_buf()) --- -2.34.1 - diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/0001-CVE-2022-36114-limit-the-maximum-unpacked-size-of-a-.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/0001-CVE-2022-36114-limit-the-maximum-unpacked-size-of-a-.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/0001-CVE-2022-36114-limit-the-maximum-unpacked-size-of-a-.patch 2022-12-01 12:18:16.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/0001-CVE-2022-36114-limit-the-maximum-unpacked-size-of-a-.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -From 886efa25746cc4bf397442adebd43d2159bd09d2 Mon Sep 17 00:00:00 2001 -From: Josh Triplett -Date: Thu, 18 Aug 2022 17:45:45 +0200 -Subject: [PATCH 1/2] CVE-2022-36114: limit the maximum unpacked size of a - crate to 512MB - -This gives users of custom registries the same protections, using the -same size limit that crates.io uses. - -`LimitErrorReader` code copied from crates.io. ---- - src/cargo/sources/registry/mod.rs | 6 +++++- - src/cargo/util/io.rs | 26 ++++++++++++++++++++++++++ - src/cargo/util/mod.rs | 2 ++ - 3 files changed, 33 insertions(+), 1 deletion(-) - create mode 100644 src/cargo/util/io.rs - -diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs -index b28bc4942..b1e246968 100644 ---- a/src/cargo/sources/registry/mod.rs -+++ b/src/cargo/sources/registry/mod.rs -@@ -182,7 +182,9 @@ use crate::util::hex; - use crate::util::interning::InternedString; - use crate::util::into_url::IntoUrl; - use crate::util::network::PollExt; --use crate::util::{restricted_names, CargoResult, Config, Filesystem, OptVersionReq}; -+use crate::util::{ -+ restricted_names, CargoResult, Config, Filesystem, LimitErrorReader, OptVersionReq, -+}; - - const PACKAGE_SOURCE_LOCK: &str = ".cargo-ok"; - pub const CRATES_IO_INDEX: &str = "https://github.com/rust-lang/crates.io-index"; -@@ -194,6 +196,7 @@ const VERSION_TEMPLATE: &str = "{version}"; - const PREFIX_TEMPLATE: &str = "{prefix}"; - const LOWER_PREFIX_TEMPLATE: &str = "{lowerprefix}"; - const CHECKSUM_TEMPLATE: &str = "{sha256-checksum}"; -+const MAX_UNPACK_SIZE: u64 = 512 * 1024 * 1024; - - /// A "source" for a local (see `local::LocalRegistry`) or remote (see - /// `remote::RemoteRegistry`) registry. -@@ -615,6 +618,7 @@ impl<'cfg> RegistrySource<'cfg> { - } - } - let gz = GzDecoder::new(tarball); -+ let gz = LimitErrorReader::new(gz, MAX_UNPACK_SIZE); - let mut tar = Archive::new(gz); - let prefix = unpack_dir.file_name().unwrap(); - let parent = unpack_dir.parent().unwrap(); -diff --git a/src/cargo/util/io.rs b/src/cargo/util/io.rs -new file mode 100644 -index 000000000..cc617954e ---- /dev/null -+++ b/src/cargo/util/io.rs -@@ -0,0 +1,26 @@ -+use std::io::{self, Read, Take}; -+ -+#[derive(Debug)] -+pub struct LimitErrorReader { -+ inner: Take, -+} -+ -+impl LimitErrorReader { -+ pub fn new(r: R, limit: u64) -> LimitErrorReader { -+ LimitErrorReader { -+ inner: r.take(limit), -+ } -+ } -+} -+ -+impl Read for LimitErrorReader { -+ fn read(&mut self, buf: &mut [u8]) -> io::Result { -+ match self.inner.read(buf) { -+ Ok(0) if self.inner.limit() == 0 => Err(io::Error::new( -+ io::ErrorKind::Other, -+ "maximum limit reached when reading", -+ )), -+ e => e, -+ } -+ } -+} -diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs -index 4b8604f92..dd695fbff 100644 ---- a/src/cargo/util/mod.rs -+++ b/src/cargo/util/mod.rs -@@ -14,6 +14,7 @@ pub use self::hasher::StableHasher; - pub use self::hex::{hash_u64, short_hash, to_hex}; - pub use self::into_url::IntoUrl; - pub use self::into_url_with_base::IntoUrlWithBase; -+pub(crate) use self::io::LimitErrorReader; - pub use self::lev_distance::{closest, closest_msg, lev_distance}; - pub use self::lockserver::{LockServer, LockServerClient, LockServerStarted}; - pub use self::progress::{Progress, ProgressStyle}; -@@ -44,6 +45,7 @@ pub mod important_paths; - pub mod interning; - pub mod into_url; - mod into_url_with_base; -+mod io; - pub mod job; - pub mod lev_distance; - mod lockserver; --- -2.34.1 - diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/2002_disable-net-tests.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/2002_disable-net-tests.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/2002_disable-net-tests.patch 2022-12-01 12:18:16.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/2002_disable-net-tests.patch 2023-01-17 13:46:33.000000000 +0000 @@ -45,7 +45,7 @@ .file( --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs -@@ -1642,7 +1642,7 @@ +@@ -1584,7 +1584,7 @@ .run(); } diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/2003-workaround-qemu-vfork-command-not-found.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/2003-workaround-qemu-vfork-command-not-found.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/2003-workaround-qemu-vfork-command-not-found.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/2003-workaround-qemu-vfork-command-not-found.patch 2023-01-17 13:25:36.000000000 +0000 @@ -0,0 +1,17 @@ +--- a/crates/cargo-test-macro/src/lib.rs ++++ b/crates/cargo-test-macro/src/lib.rs +@@ -203,6 +203,14 @@ + } + }; + if !output.status.success() { ++ // Debian specific patch, upstream wontfix: ++ // qemu has a faulty vfork where it fails to fail if a command is not ++ // found, with a unix_wait_status of 32512, or 0x7f00, 7f meaning ++ // exit code 127. See https://github.com/rust-lang/rust/issues/90825 ++ use std::os::unix::process::ExitStatusExt; ++ if output.status.into_raw() == 0x7f00 { ++ return false; ++ } + panic!( + "expected command `{}` to be runnable, got error {}:\n\ + stderr:{}\n\ diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/bump-libgit2.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/bump-libgit2.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/bump-libgit2.patch 2022-12-01 12:18:16.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/bump-libgit2.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -29,8 +29,8 @@ pretty_env_logger = { version = "0.4", o - anyhow = "1.0" - filetime = "0.2.9" - flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] } --git2 = "0.14.2" --git2-curl = "0.15.0" -+git2 = "0.15.0" -+git2-curl = "0.16.0" - glob = "0.3.0" - hex = "0.4" - home = "0.5" -@@ -42,7 +42,7 @@ jobserver = "0.1.24" - lazycell = "1.2.0" - libc = "0.2" - log = "0.4.6" --libgit2-sys = "0.13.2" -+libgit2-sys = "0.14.0+1.5.0" - memchr = "2.1.3" - num_cpus = "1.0" - opener = "0.5" ---- a/crates/cargo-test-support/Cargo.toml -+++ b/crates/cargo-test-support/Cargo.toml -@@ -14,7 +14,7 @@ - snapbox = { version = "0.2.8", features = ["diff", "path"] } - filetime = "0.2" - flate2 = { version = "1.0", default-features = false, features = ["zlib"] } --git2 = "0.14.2" -+git2 = "0.15.0" - glob = "0.3" - itertools = "0.10.0" - lazy_static = "1.0" diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-01-validate-ssh-host.keys.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-01-validate-ssh-host.keys.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-01-validate-ssh-host.keys.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-01-validate-ssh-host.keys.patch 2023-01-17 14:05:25.000000000 +0000 @@ -0,0 +1,586 @@ +This patch is based on the upstream commit described below, adapted for use +in the Debian package by Peter Michael Green. + +commit 1387fd4105b242fa2d24ad99d10a5b1af23f293e +Author: Eric Huss +Date: Wed Dec 7 18:52:00 2022 -0800 + + Validate SSH host keys + +Index: cargo/src/cargo/sources/git/known_hosts.rs +=================================================================== +--- /dev/null ++++ cargo/src/cargo/sources/git/known_hosts.rs +@@ -0,0 +1,439 @@ ++//! SSH host key validation support. ++//! ++//! A primary goal with this implementation is to provide user-friendly error ++//! messages, guiding them to understand the issue and how to resolve it. ++//! ++//! Note that there are a lot of limitations here. This reads OpenSSH ++//! known_hosts files from well-known locations, but it does not read OpenSSH ++//! config files. The config file can change the behavior of how OpenSSH ++//! handles known_hosts files. For example, some things we don't handle: ++//! ++//! - `GlobalKnownHostsFile` — Changes the location of the global host file. ++//! - `UserKnownHostsFile` — Changes the location of the user's host file. ++//! - `KnownHostsCommand` — A command to fetch known hosts. ++//! - `CheckHostIP` — DNS spoofing checks. ++//! - `VisualHostKey` — Shows a visual ascii-art key. ++//! - `VerifyHostKeyDNS` — Uses SSHFP DNS records to fetch a host key. ++//! ++//! There's also a number of things that aren't supported but could be easily ++//! added (it just adds a little complexity). For example, hashed hostnames, ++//! hostname patterns, and revoked markers. See "FIXME" comments littered in ++//! this file. ++ ++use git2::cert::Cert; ++use git2::CertificateCheckStatus; ++use std::collections::HashSet; ++use std::fmt::Write; ++use std::path::{Path, PathBuf}; ++ ++/// These are host keys that are hard-coded in cargo to provide convenience. ++/// ++/// If GitHub ever publishes new keys, the user can add them to their own ++/// configuration file to use those instead. ++/// ++/// The GitHub keys are sourced from or ++/// . ++/// ++/// These will be ignored if the user adds their own entries for `github.com`, ++/// which can be useful if GitHub ever revokes their old keys. ++static BUNDLED_KEYS: &[(&str, &str, &str)] = &[ ++ ("github.com", "ssh-ed25519", "AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl"), ++ ("github.com", "ecdsa-sha2-nistp256", "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg="), ++ ("github.com", "ssh-rsa", "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ=="), ++]; ++ ++enum KnownHostError { ++ /// Some general error happened while validating the known hosts. ++ CheckError(anyhow::Error), ++ /// The host key was not found. ++ HostKeyNotFound { ++ hostname: String, ++ key_type: git2::cert::SshHostKeyType, ++ remote_host_key: String, ++ remote_fingerprint: String, ++ other_hosts: Vec, ++ }, ++ /// The host key was found, but does not match the remote's key. ++ HostKeyHasChanged { ++ hostname: String, ++ key_type: git2::cert::SshHostKeyType, ++ old_known_host: KnownHost, ++ remote_host_key: String, ++ remote_fingerprint: String, ++ }, ++} ++ ++impl From for KnownHostError { ++ fn from(err: anyhow::Error) -> KnownHostError { ++ KnownHostError::CheckError(err.into()) ++ } ++} ++ ++/// The location where a host key was located. ++#[derive(Clone)] ++enum KnownHostLocation { ++ /// Loaded from a file from disk. ++ File { path: PathBuf, lineno: u32 }, ++ /// Part of the hard-coded bundled keys in Cargo. ++ Bundled, ++} ++ ++/// The git2 callback used to validate a certificate (only ssh known hosts are validated). ++pub fn certificate_check( ++ cert: &Cert<'_>, ++ host: &str, ++ port: Option, ++) -> Result { ++ let Some(host_key) = cert.as_hostkey() else { ++ // Return passthrough for TLS X509 certificates to use whatever validation ++ // was done in git2. ++ return Ok(CertificateCheckStatus::CertificatePassthrough) ++ }; ++ // If a nonstandard port is in use, check for that first. ++ // The fallback to check without a port is handled in the HostKeyNotFound handler. ++ let host_maybe_port = match port { ++ Some(port) if port != 22 => format!("[{host}]:{port}"), ++ _ => host.to_string(), ++ }; ++ // The error message must be constructed as a string to pass through the libgit2 C API. ++ let err_msg = match check_ssh_known_hosts(host_key, &host_maybe_port) { ++ Ok(()) => { ++ return Ok(CertificateCheckStatus::CertificateOk); ++ } ++ Err(KnownHostError::CheckError(e)) => { ++ format!("error: failed to validate host key:\n{:#}", e) ++ } ++ Err(KnownHostError::HostKeyNotFound { ++ hostname, ++ key_type, ++ remote_host_key, ++ remote_fingerprint, ++ other_hosts, ++ }) => { ++ // Try checking without the port. ++ if port.is_some() ++ && !matches!(port, Some(22)) ++ && check_ssh_known_hosts(host_key, host).is_ok() ++ { ++ return Ok(CertificateCheckStatus::CertificateOk); ++ } ++ let key_type_short_name = key_type.short_name(); ++ let key_type_name = key_type.name(); ++ let known_hosts_location = user_known_host_location_to_add(); ++ let other_hosts_message = if other_hosts.is_empty() { ++ String::new() ++ } else { ++ let mut msg = String::from( ++ "Note: This host key was found, \ ++ but is associated with a different host:\n", ++ ); ++ for known_host in other_hosts { ++ let loc = match known_host.location { ++ KnownHostLocation::File { path, lineno } => { ++ format!("{} line {lineno}", path.display()) ++ } ++ KnownHostLocation::Bundled => format!("bundled with cargo"), ++ }; ++ write!(msg, " {loc}: {}\n", known_host.patterns).unwrap(); ++ } ++ msg ++ }; ++ format!("error: unknown SSH host key\n\ ++ The SSH host key for `{hostname}` is not known and cannot be validated.\n\ ++ \n\ ++ To resolve this issue, add the host key to {known_hosts_location}\n\ ++ \n\ ++ The key to add is:\n\ ++ \n\ ++ {hostname} {key_type_name} {remote_host_key}\n\ ++ \n\ ++ The {key_type_short_name} key fingerprint is: SHA256:{remote_fingerprint}\n\ ++ This fingerprint should be validated with the server administrator that it is correct.\n\ ++ {other_hosts_message}\n\ ++ See https://doc.rust-lang.org/nightly/cargo/appendix/git-authentication.html#ssh-known-hosts \ ++ for more information.\n\ ++ ") ++ } ++ Err(KnownHostError::HostKeyHasChanged { ++ hostname, ++ key_type, ++ old_known_host, ++ remote_host_key, ++ remote_fingerprint, ++ }) => { ++ let key_type_short_name = key_type.short_name(); ++ let key_type_name = key_type.name(); ++ let known_hosts_location = user_known_host_location_to_add(); ++ let old_key_resolution = match old_known_host.location { ++ KnownHostLocation::File { path, lineno } => { ++ let old_key_location = path.display(); ++ format!( ++ "removing the old {key_type_name} key for `{hostname}` \ ++ located at {old_key_location} line {lineno}, \ ++ and adding the new key to {known_hosts_location}", ++ ) ++ } ++ KnownHostLocation::Bundled => { ++ format!( ++ "adding the new key to {known_hosts_location}\n\ ++ The current host key is bundled as part of Cargo." ++ ) ++ } ++ }; ++ format!("error: SSH host key has changed for `{hostname}`\n\ ++ *********************************\n\ ++ * WARNING: HOST KEY HAS CHANGED *\n\ ++ *********************************\n\ ++ This may be caused by a man-in-the-middle attack, or the \ ++ server may have changed its host key.\n\ ++ \n\ ++ The {key_type_short_name} fingerprint for the key from the remote host is:\n\ ++ SHA256:{remote_fingerprint}\n\ ++ \n\ ++ You are strongly encouraged to contact the server \ ++ administrator for `{hostname}` to verify that this new key is \ ++ correct.\n\ ++ \n\ ++ If you can verify that the server has a new key, you can \ ++ resolve this error by {old_key_resolution}\n\ ++ \n\ ++ The key provided by the remote host is:\n\ ++ \n\ ++ {hostname} {key_type_name} {remote_host_key}\n\ ++ \n\ ++ See https://doc.rust-lang.org/nightly/cargo/appendix/git-authentication.html#ssh-known-hosts \ ++ for more information.\n\ ++ ") ++ } ++ }; ++ Err(git2::Error::new( ++ git2::ErrorCode::GenericError, ++ git2::ErrorClass::Callback, ++ err_msg, ++ )) ++} ++ ++/// Checks if the given host/host key pair is known. ++fn check_ssh_known_hosts( ++ cert_host_key: &git2::cert::CertHostkey<'_>, ++ host: &str, ++) -> Result<(), KnownHostError> { ++ let Some(remote_host_key) = cert_host_key.hostkey() else { ++ return Err(anyhow::format_err!("remote host key is not available").into()); ++ }; ++ let remote_key_type = cert_host_key.hostkey_type().unwrap(); ++ // `changed_key` keeps track of any entries where the key has changed. ++ let mut changed_key = None; ++ // `other_hosts` keeps track of any entries that have an identical key, ++ // but a different hostname. ++ let mut other_hosts = Vec::new(); ++ ++ // Collect all the known host entries from disk. ++ let mut known_hosts = Vec::new(); ++ for path in known_host_files() { ++ if !path.exists() { ++ continue; ++ } ++ let hosts = load_hostfile(&path)?; ++ known_hosts.extend(hosts); ++ } ++ // Load the bundled keys. Don't add keys for hosts that the user has ++ // configured, which gives them the option to override them. This could be ++ // useful if the keys are ever revoked. ++ let configured_hosts: HashSet<_> = known_hosts ++ .iter() ++ .flat_map(|known_host| { ++ known_host ++ .patterns ++ .split(',') ++ .map(|pattern| pattern.to_lowercase()) ++ }) ++ .collect(); ++ for (patterns, key_type, key) in BUNDLED_KEYS { ++ if !configured_hosts.contains(*patterns) { ++ let key = base64::decode(key).unwrap(); ++ known_hosts.push(KnownHost { ++ location: KnownHostLocation::Bundled, ++ patterns: patterns.to_string(), ++ key_type: key_type.to_string(), ++ key, ++ }); ++ } ++ } ++ ++ for known_host in known_hosts { ++ // The key type from libgit2 needs to match the key type from the host file. ++ if known_host.key_type != remote_key_type.name() { ++ continue; ++ } ++ let key_matches = known_host.key == remote_host_key; ++ if !known_host.host_matches(host) { ++ // `name` can be None for hashed hostnames (which libgit2 does not expose). ++ if key_matches { ++ other_hosts.push(known_host.clone()); ++ } ++ continue; ++ } ++ if key_matches { ++ return Ok(()); ++ } ++ // The host and key type matched, but the key itself did not. ++ // This indicates the key has changed. ++ // This is only reported as an error if no subsequent lines have a ++ // correct key. ++ changed_key = Some(known_host.clone()); ++ } ++ // Older versions of OpenSSH (before 6.8, March 2015) showed MD5 ++ // fingerprints (see FingerprintHash ssh config option). Here we only ++ // support SHA256. ++ let mut remote_fingerprint = cargo_util::Sha256::new(); ++ remote_fingerprint.update(remote_host_key); ++ let remote_fingerprint = ++ base64::encode_config(remote_fingerprint.finish(), base64::STANDARD_NO_PAD); ++ let remote_host_key = base64::encode(remote_host_key); ++ // FIXME: Ideally the error message should include the IP address of the ++ // remote host (to help the user validate that they are connecting to the ++ // host they were expecting to). However, I don't see a way to obtain that ++ // information from libgit2. ++ match changed_key { ++ Some(old_known_host) => Err(KnownHostError::HostKeyHasChanged { ++ hostname: host.to_string(), ++ key_type: remote_key_type, ++ old_known_host, ++ remote_host_key, ++ remote_fingerprint, ++ }), ++ None => Err(KnownHostError::HostKeyNotFound { ++ hostname: host.to_string(), ++ key_type: remote_key_type, ++ remote_host_key, ++ remote_fingerprint, ++ other_hosts, ++ }), ++ } ++} ++ ++/// Returns a list of files to try loading OpenSSH-formatted known hosts. ++fn known_host_files() -> Vec { ++ let mut result = Vec::new(); ++ if cfg!(unix) { ++ result.push(PathBuf::from("/etc/ssh/ssh_known_hosts")); ++ } else if cfg!(windows) { ++ // The msys/cygwin version of OpenSSH uses `/etc` from the posix root ++ // filesystem there (such as `C:\msys64\etc\ssh\ssh_known_hosts`). ++ // However, I do not know of a way to obtain that location from ++ // Windows-land. The ProgramData version here is what the PowerShell ++ // port of OpenSSH does. ++ if let Some(progdata) = std::env::var_os("ProgramData") { ++ let mut progdata = PathBuf::from(progdata); ++ progdata.push("ssh"); ++ progdata.push("ssh_known_hosts"); ++ result.push(progdata) ++ } ++ } ++ result.extend(user_known_host_location()); ++ result ++} ++ ++/// The location of the user's known_hosts file. ++fn user_known_host_location() -> Option { ++ // NOTE: This is a potentially inaccurate prediction of what the user ++ // actually wants. The actual location depends on several factors: ++ // ++ // - Windows OpenSSH Powershell version: I believe this looks up the home ++ // directory via ProfileImagePath in the registry, falling back to ++ // `GetWindowsDirectoryW` if that fails. ++ // - OpenSSH Portable (under msys): This is very complicated. I got lost ++ // after following it through some ldap/active directory stuff. ++ // - OpenSSH (most unix platforms): Uses `pw->pw_dir` from `getpwuid()`. ++ // ++ // This doesn't do anything close to that. home_dir's behavior is: ++ // - Windows: $USERPROFILE, or SHGetFolderPathW() ++ // - Unix: $HOME, or getpwuid_r() ++ // ++ // Since there is a mismatch here, the location returned here might be ++ // different than what the user's `ssh` CLI command uses. We may want to ++ // consider trying to align it better. ++ home::home_dir().map(|mut home| { ++ home.push(".ssh"); ++ home.push("known_hosts"); ++ home ++ }) ++} ++ ++/// The location to display in an error message instructing the user where to ++/// add the new key. ++fn user_known_host_location_to_add() -> String { ++ // Note that we don't bother with the legacy known_hosts2 files. ++ match user_known_host_location() { ++ Some(path) => path.to_str().expect("utf-8 home").to_string(), ++ None => "~/.ssh/known_hosts".to_string(), ++ } ++} ++ ++/// A single known host entry. ++#[derive(Clone)] ++struct KnownHost { ++ location: KnownHostLocation, ++ /// The hostname. May be comma separated to match multiple hosts. ++ patterns: String, ++ key_type: String, ++ key: Vec, ++} ++ ++impl KnownHost { ++ /// Returns whether or not the given host matches this known host entry. ++ fn host_matches(&self, host: &str) -> bool { ++ let mut match_found = false; ++ let host = host.to_lowercase(); ++ // FIXME: support hashed hostnames ++ for pattern in self.patterns.split(',') { ++ let pattern = pattern.to_lowercase(); ++ // FIXME: support * and ? wildcards ++ if let Some(pattern) = pattern.strip_prefix('!') { ++ if pattern == host { ++ return false; ++ } ++ } else { ++ match_found = pattern == host; ++ } ++ } ++ match_found ++ } ++} ++ ++/// Loads an OpenSSH known_hosts file. ++fn load_hostfile(path: &Path) -> Result, anyhow::Error> { ++ let contents = cargo_util::paths::read(path)?; ++ let entries = contents ++ .lines() ++ .enumerate() ++ .filter_map(|(lineno, line)| { ++ let location = KnownHostLocation::File { ++ path: path.to_path_buf(), ++ lineno: lineno as u32 + 1, ++ }; ++ parse_known_hosts_line(line, location) ++ }) ++ .collect(); ++ Ok(entries) ++} ++ ++fn parse_known_hosts_line(line: &str, location: KnownHostLocation) -> Option { ++ let line = line.trim(); ++ // FIXME: @revoked and @cert-authority is currently not supported. ++ if line.is_empty() || line.starts_with('#') || line.starts_with('@') { ++ return None; ++ } ++ let mut parts = line.split([' ', '\t']).filter(|s| !s.is_empty()); ++ let Some(patterns) = parts.next() else { return None }; ++ let Some(key_type) = parts.next() else { return None }; ++ let Some(key) = parts.next() else { return None }; ++ let Ok(key) = base64::decode(key) else { return None }; ++ Some(KnownHost { ++ location, ++ patterns: patterns.to_string(), ++ key_type: key_type.to_string(), ++ key, ++ }) ++} +Index: cargo/src/cargo/sources/git/mod.rs +=================================================================== +--- cargo.orig/src/cargo/sources/git/mod.rs ++++ cargo/src/cargo/sources/git/mod.rs +@@ -1,4 +1,5 @@ + pub use self::source::GitSource; + pub use self::utils::{fetch, GitCheckout, GitDatabase, GitRemote}; ++mod known_hosts; + mod source; + mod utils; +Index: cargo/src/cargo/sources/git/utils.rs +=================================================================== +--- cargo.orig/src/cargo/sources/git/utils.rs ++++ cargo/src/cargo/sources/git/utils.rs +@@ -647,7 +647,6 @@ where + | ErrorClass::Submodule + | ErrorClass::FetchHead + | ErrorClass::Ssh +- | ErrorClass::Callback + | ErrorClass::Http => { + let mut msg = "network failure seems to have happened\n".to_string(); + msg.push_str( +@@ -658,6 +657,13 @@ where + ); + err = err.context(msg); + } ++ ErrorClass::Callback => { ++ // This unwraps the git2 error. We're using the callback error ++ // specifically to convey errors from Rust land through the C ++ // callback interface. We don't need the `; class=Callback ++ // (26)` that gets tacked on to the git2 error message. ++ err = anyhow::format_err!("{}", e.message()); ++ } + _ => {} + } + } +@@ -686,12 +692,16 @@ pub fn with_fetch_options( + let mut progress = Progress::new("Fetch", config); + network::with_retry(config, || { + with_authentication(url, git_config, |f| { ++ let port = Url::parse(url).ok().and_then(|url| url.port()); + let mut last_update = Instant::now(); + let mut rcb = git2::RemoteCallbacks::new(); + // We choose `N=10` here to make a `300ms * 10slots ~= 3000ms` + // sliding window for tracking the data transfer rate (in bytes/s). + let mut counter = MetricsCounter::<10>::new(0, last_update); + rcb.credentials(f); ++ rcb.certificate_check(|cert, host| { ++ super::known_hosts::certificate_check(cert, host, port) ++ }); + rcb.transfer_progress(|stats| { + let indexed_deltas = stats.indexed_deltas(); + let msg = if indexed_deltas > 0 { +Index: cargo/src/doc/src/appendix/git-authentication.md +=================================================================== +--- cargo.orig/src/doc/src/appendix/git-authentication.md ++++ cargo/src/doc/src/appendix/git-authentication.md +@@ -58,9 +58,32 @@ on how to start `ssh-agent` and to add k + > used by Cargo's built-in SSH library. More advanced requirements should use + > [`net.git-fetch-with-cli`]. + ++### SSH Known Hosts ++ ++When connecting to an SSH host, Cargo must verify the identity of the host ++using "known hosts", which are a list of host keys. Cargo can look for these ++known hosts in OpenSSH-style `known_hosts` files located in their standard ++locations (`.ssh/known_hosts` in your home directory, or ++`/etc/ssh/ssh_known_hosts` on Unix-like platforms or ++`%PROGRAMDATA%\ssh\ssh_known_hosts` on Windows). More information about these ++files can be found in the [sshd man page]. ++ ++When connecting to an SSH host before the known hosts has been configured, ++Cargo will display an error message instructing you how to add the host key. ++This also includes a "fingerprint", which is a smaller hash of the host key, ++which should be easier to visually verify. The server administrator can get ++the fingerprint by running `ssh-keygen` against the public key (for example, ++`ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub`). Well-known sites may ++publish their fingerprints on the web; for example GitHub posts theirs at ++. ++ ++Cargo comes with the host keys for [github.com](https://github.com) built-in. ++If those ever change, you can add the new keys to your known_hosts file. ++ + [`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 ++[sshd man page]: https://man.openbsd.org/sshd#SSH_KNOWN_HOSTS_FILE_FORMAT +--- rust-cargo-0.66.0.orig/Cargo.toml ++++ rust-cargo-0.66.0/Cargo.toml +@@ -17,6 +17,7 @@ path = "src/cargo/lib.rs" + + [dependencies] + atty = "0.2" ++base64 = "0.13" + bytesize = "1.0" + cargo-platform = { path = "crates/cargo-platform", version = "0.1.2" } + cargo-util = { path = "crates/cargo-util", version = "0.2.1" } +@@ -28,8 +29,8 @@ pretty_env_logger = { version = "0.4", o + anyhow = "1.0" + filetime = "0.2.9" + flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] } +-git2 = "0.15.0" +-git2-curl = "0.16.0" ++git2 = "0.16.0" ++git2-curl = "0.17.0" + glob = "0.3.0" + hex = "0.4" + home = "0.5" +@@ -41,7 +42,7 @@ jobserver = "0.1.24" + lazycell = "1.2.0" + libc = "0.2" + log = "0.4.6" +-libgit2-sys = "0.14.0" ++libgit2-sys = "0.14.1" + memchr = "2.1.3" + opener = "0.5" + os_info = "3.5.0" + +--- cargo-0.66/crates/cargo-test-support/Cargo.toml.orig 2023-01-11 11:33:00.584077593 +0100 ++++ cargo-0.66/crates/cargo-test-support/Cargo.toml 2023-01-11 11:33:12.564917363 +0100 +@@ -14,7 +14,7 @@ cargo-util = { path = "../cargo-util" } + snapbox = { version = "0.3.0", features = ["diff", "path"] } + filetime = "0.2" + flate2 = { version = "1.0", default-features = false, features = ["zlib"] } +-git2 = "0.15.0" ++git2 = "0.16.0" + glob = "0.3" + itertools = "0.10.0" + lazy_static = "1.0" + diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-02-add-support-for-deserializing-vec-value-string.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-02-add-support-for-deserializing-vec-value-string.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-02-add-support-for-deserializing-vec-value-string.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-02-add-support-for-deserializing-vec-value-string.patch 2023-01-17 14:05:25.000000000 +0000 @@ -0,0 +1,157 @@ +commit 9f62f8440e9e542f27d60c75be38ac51186c6c32 +Author: Eric Huss +Date: Fri Dec 9 20:03:27 2022 -0800 + + Add support for deserializing Vec> in config. + + This adds the ability to track the definition location of a string + in a TOML array. + +diff --git a/src/cargo/util/config/de.rs b/src/cargo/util/config/de.rs +index 6fddc7e71f..1408f15b57 100644 +--- a/src/cargo/util/config/de.rs ++++ b/src/cargo/util/config/de.rs +@@ -384,7 +384,12 @@ impl<'de> de::SeqAccess<'de> for ConfigSeqAccess { + { + match self.list_iter.next() { + // TODO: add `def` to error? +- Some((value, _def)) => seed.deserialize(value.into_deserializer()).map(Some), ++ Some((value, def)) => { ++ // This might be a String or a Value. ++ // ValueDeserializer will handle figuring out which one it is. ++ let maybe_value_de = ValueDeserializer::new_with_string(value, def); ++ seed.deserialize(maybe_value_de).map(Some) ++ } + None => Ok(None), + } + } +@@ -400,7 +405,17 @@ impl<'de> de::SeqAccess<'de> for ConfigSeqAccess { + struct ValueDeserializer<'config> { + hits: u32, + definition: Definition, +- de: Deserializer<'config>, ++ /// The deserializer, used to actually deserialize a Value struct. ++ /// This is `None` if deserializing a string. ++ de: Option>, ++ /// A string value to deserialize. ++ /// ++ /// This is used for situations where you can't address a string via a ++ /// TOML key, such as a string inside an array. The `ConfigSeqAccess` ++ /// doesn't know if the type it should deserialize to is a `String` or ++ /// `Value`, so `ValueDeserializer` needs to be able to handle ++ /// both. ++ str_value: Option, + } + + impl<'config> ValueDeserializer<'config> { +@@ -428,9 +443,19 @@ impl<'config> ValueDeserializer<'config> { + Ok(ValueDeserializer { + hits: 0, + definition, +- de, ++ de: Some(de), ++ str_value: None, + }) + } ++ ++ fn new_with_string(s: String, definition: Definition) -> ValueDeserializer<'config> { ++ ValueDeserializer { ++ hits: 0, ++ definition, ++ de: None, ++ str_value: Some(s), ++ } ++ } + } + + impl<'de, 'config> de::MapAccess<'de> for ValueDeserializer<'config> { +@@ -459,9 +484,14 @@ impl<'de, 'config> de::MapAccess<'de> for ValueDeserializer<'config> { + // If this is the first time around we deserialize the `value` field + // which is the actual deserializer + if self.hits == 1 { +- return seed +- .deserialize(self.de.clone()) +- .map_err(|e| e.with_key_context(&self.de.key, self.definition.clone())); ++ if let Some(de) = &self.de { ++ return seed ++ .deserialize(de.clone()) ++ .map_err(|e| e.with_key_context(&de.key, self.definition.clone())); ++ } else { ++ return seed ++ .deserialize(self.str_value.as_ref().unwrap().clone().into_deserializer()); ++ } + } + + // ... otherwise we're deserializing the `definition` field, so we need +@@ -484,6 +514,71 @@ impl<'de, 'config> de::MapAccess<'de> for ValueDeserializer<'config> { + } + } + ++// Deserializer is only implemented to handle deserializing a String inside a ++// sequence (like `Vec` or `Vec>`). `Value` is ++// handled by deserialize_struct, and the plain `String` is handled by all the ++// other functions here. ++impl<'de, 'config> de::Deserializer<'de> for ValueDeserializer<'config> { ++ type Error = ConfigError; ++ ++ fn deserialize_str(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_str(&self.str_value.expect("string expected")) ++ } ++ ++ fn deserialize_string(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_string(self.str_value.expect("string expected")) ++ } ++ ++ fn deserialize_struct( ++ self, ++ name: &'static str, ++ fields: &'static [&'static str], ++ visitor: V, ++ ) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ // Match on the magical struct name/field names that are passed in to ++ // detect when we're deserializing `Value`. ++ // ++ // See more comments in `value.rs` for the protocol used here. ++ if name == value::NAME && fields == value::FIELDS { ++ return visitor.visit_map(self); ++ } ++ unimplemented!("only strings and Value can be deserialized from a sequence"); ++ } ++ ++ fn deserialize_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_string(self.str_value.expect("string expected")) ++ } ++ ++ fn deserialize_ignored_any(self, visitor: V) -> Result ++ where ++ V: de::Visitor<'de>, ++ { ++ visitor.visit_unit() ++ } ++ ++ serde::forward_to_deserialize_any! { ++ i8 i16 i32 i64 ++ u8 u16 u32 u64 ++ option ++ newtype_struct seq tuple tuple_struct map enum bool ++ f32 f64 char bytes ++ byte_buf unit unit_struct ++ identifier ++ } ++} ++ + /// A deserializer which takes two values and deserializes into a tuple of those + /// two values. This is similar to types like `StrDeserializer` in upstream + /// serde itself. diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-03-support-configuring-ssh-known-hosts.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-03-support-configuring-ssh-known-hosts.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-03-support-configuring-ssh-known-hosts.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-03-support-configuring-ssh-known-hosts.patch 2023-01-17 14:05:25.000000000 +0000 @@ -0,0 +1,299 @@ +commit 026bda3fb5eddac0df111ee150706f756558a7b3 +Author: Eric Huss +Date: Fri Dec 9 20:38:12 2022 -0800 + + Support configuring ssh known-hosts via cargo config. + +diff --git a/src/cargo/sources/git/known_hosts.rs b/src/cargo/sources/git/known_hosts.rs +index 875dcf63f3..7efea43c3b 100644 +--- a/src/cargo/sources/git/known_hosts.rs ++++ b/src/cargo/sources/git/known_hosts.rs +@@ -20,6 +20,7 @@ + //! hostname patterns, and revoked markers. See "FIXME" comments littered in + //! this file. + ++use crate::util::config::{Definition, Value}; + use git2::cert::Cert; + use git2::CertificateCheckStatus; + use std::collections::HashSet; +@@ -74,6 +75,8 @@ impl From for KnownHostError { + enum KnownHostLocation { + /// Loaded from a file from disk. + File { path: PathBuf, lineno: u32 }, ++ /// Loaded from cargo's config system. ++ Config { definition: Definition }, + /// Part of the hard-coded bundled keys in Cargo. + Bundled, + } +@@ -83,6 +86,8 @@ pub fn certificate_check( + cert: &Cert<'_>, + host: &str, + port: Option, ++ config_known_hosts: Option<&Vec>>, ++ diagnostic_home_config: &str, + ) -> Result { + let Some(host_key) = cert.as_hostkey() else { + // Return passthrough for TLS X509 certificates to use whatever validation +@@ -96,7 +101,7 @@ pub fn certificate_check( + _ => host.to_string(), + }; + // The error message must be constructed as a string to pass through the libgit2 C API. +- let err_msg = match check_ssh_known_hosts(host_key, &host_maybe_port) { ++ let err_msg = match check_ssh_known_hosts(host_key, &host_maybe_port, config_known_hosts) { + Ok(()) => { + return Ok(CertificateCheckStatus::CertificateOk); + } +@@ -113,13 +118,13 @@ pub fn certificate_check( + // Try checking without the port. + if port.is_some() + && !matches!(port, Some(22)) +- && check_ssh_known_hosts(host_key, host).is_ok() ++ && check_ssh_known_hosts(host_key, host, config_known_hosts).is_ok() + { + return Ok(CertificateCheckStatus::CertificateOk); + } + let key_type_short_name = key_type.short_name(); + let key_type_name = key_type.name(); +- let known_hosts_location = user_known_host_location_to_add(); ++ let known_hosts_location = user_known_host_location_to_add(diagnostic_home_config); + let other_hosts_message = if other_hosts.is_empty() { + String::new() + } else { +@@ -132,6 +137,9 @@ pub fn certificate_check( + KnownHostLocation::File { path, lineno } => { + format!("{} line {lineno}", path.display()) + } ++ KnownHostLocation::Config { definition } => { ++ format!("config value from {definition}") ++ } + KnownHostLocation::Bundled => format!("bundled with cargo"), + }; + write!(msg, " {loc}: {}\n", known_host.patterns).unwrap(); +@@ -163,7 +171,7 @@ pub fn certificate_check( + }) => { + let key_type_short_name = key_type.short_name(); + let key_type_name = key_type.name(); +- let known_hosts_location = user_known_host_location_to_add(); ++ let known_hosts_location = user_known_host_location_to_add(diagnostic_home_config); + let old_key_resolution = match old_known_host.location { + KnownHostLocation::File { path, lineno } => { + let old_key_location = path.display(); +@@ -173,6 +181,13 @@ pub fn certificate_check( + and adding the new key to {known_hosts_location}", + ) + } ++ KnownHostLocation::Config { definition } => { ++ format!( ++ "removing the old {key_type_name} key for `{hostname}` \ ++ loaded from Cargo's config at {definition}, \ ++ and adding the new key to {known_hosts_location}" ++ ) ++ } + KnownHostLocation::Bundled => { + format!( + "adding the new key to {known_hosts_location}\n\ +@@ -217,6 +232,7 @@ pub fn certificate_check( + fn check_ssh_known_hosts( + cert_host_key: &git2::cert::CertHostkey<'_>, + host: &str, ++ config_known_hosts: Option<&Vec>>, + ) -> Result<(), KnownHostError> { + let Some(remote_host_key) = cert_host_key.hostkey() else { + return Err(anyhow::format_err!("remote host key is not available").into()); +@@ -237,6 +253,23 @@ fn check_ssh_known_hosts( + let hosts = load_hostfile(&path)?; + known_hosts.extend(hosts); + } ++ if let Some(config_known_hosts) = config_known_hosts { ++ // Format errors aren't an error in case the format needs to change in ++ // the future, to retain forwards compatibility. ++ for line_value in config_known_hosts { ++ let location = KnownHostLocation::Config { ++ definition: line_value.definition.clone(), ++ }; ++ match parse_known_hosts_line(&line_value.val, location) { ++ Some(known_host) => known_hosts.push(known_host), ++ None => log::warn!( ++ "failed to parse known host {} from {}", ++ line_value.val, ++ line_value.definition ++ ), ++ } ++ } ++ } + // Load the bundled keys. Don't add keys for hosts that the user has + // configured, which gives them the option to override them. This could be + // useful if the keys are ever revoked. +@@ -363,12 +396,18 @@ fn user_known_host_location() -> Option { + + /// The location to display in an error message instructing the user where to + /// add the new key. +-fn user_known_host_location_to_add() -> String { ++fn user_known_host_location_to_add(diagnostic_home_config: &str) -> String { + // Note that we don't bother with the legacy known_hosts2 files. +- match user_known_host_location() { +- Some(path) => path.to_str().expect("utf-8 home").to_string(), +- None => "~/.ssh/known_hosts".to_string(), +- } ++ let user = user_known_host_location(); ++ let openssh_loc = match &user { ++ Some(path) => path.to_str().expect("utf-8 home"), ++ None => "~/.ssh/known_hosts", ++ }; ++ format!( ++ "the `net.ssh.known-hosts` array in your Cargo configuration \ ++ (such as {diagnostic_home_config}) \ ++ or in your OpenSSH known_hosts file at {openssh_loc}" ++ ) + } + + /// A single known host entry. +diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs +index 831c43be6b..457c97c5bb 100644 +--- a/src/cargo/sources/git/utils.rs ++++ b/src/cargo/sources/git/utils.rs +@@ -726,6 +726,9 @@ pub fn with_fetch_options( + cb: &mut dyn FnMut(git2::FetchOptions<'_>) -> CargoResult<()>, + ) -> CargoResult<()> { + let mut progress = Progress::new("Fetch", config); ++ let ssh_config = config.net_config()?.ssh.as_ref(); ++ let config_known_hosts = ssh_config.and_then(|ssh| ssh.known_hosts.as_ref()); ++ let diagnostic_home_config = config.diagnostic_home_config(); + network::with_retry(config, || { + with_authentication(url, git_config, |f| { + let port = Url::parse(url).ok().and_then(|url| url.port()); +@@ -736,7 +739,13 @@ pub fn with_fetch_options( + let mut counter = MetricsCounter::<10>::new(0, last_update); + rcb.credentials(f); + rcb.certificate_check(|cert, host| { +- super::known_hosts::certificate_check(cert, host, port) ++ super::known_hosts::certificate_check( ++ cert, ++ host, ++ port, ++ config_known_hosts, ++ &diagnostic_home_config, ++ ) + }); + rcb.transfer_progress(|stats| { + let indexed_deltas = stats.indexed_deltas(); +diff --git a/src/cargo/util/config/mod.rs b/src/cargo/util/config/mod.rs +index d30e094413..d9ab142c4e 100644 +--- a/src/cargo/util/config/mod.rs ++++ b/src/cargo/util/config/mod.rs +@@ -356,6 +356,18 @@ impl Config { + &self.home_path + } + ++ /// Returns a path to display to the user with the location of their home ++ /// config file (to only be used for displaying a diagnostics suggestion, ++ /// such as recommending where to add a config value). ++ pub fn diagnostic_home_config(&self) -> String { ++ let home = self.home_path.as_path_unlocked(); ++ let path = match self.get_file_path(home, "config", false) { ++ Ok(Some(existing_path)) => existing_path, ++ _ => home.join("config.toml"), ++ }; ++ path.to_string_lossy().to_string() ++ } ++ + /// Gets the Cargo Git directory (`/git`). + pub fn git_path(&self) -> Filesystem { + self.home_path.join("git") +@@ -2356,6 +2368,13 @@ pub struct CargoNetConfig { + pub retry: Option, + pub offline: Option, + pub git_fetch_with_cli: Option, ++ pub ssh: Option, ++} ++ ++#[derive(Debug, Deserialize)] ++#[serde(rename_all = "kebab-case")] ++pub struct CargoSshConfig { ++ pub known_hosts: Option>>, + } + + #[derive(Debug, Deserialize)] +diff --git a/src/doc/src/appendix/git-authentication.md b/src/doc/src/appendix/git-authentication.md +index a7db1ac7f1..f46a6535c6 100644 +--- a/src/doc/src/appendix/git-authentication.md ++++ b/src/doc/src/appendix/git-authentication.md +@@ -66,7 +66,8 @@ known hosts in OpenSSH-style `known_hosts` files located in their standard + locations (`.ssh/known_hosts` in your home directory, or + `/etc/ssh/ssh_known_hosts` on Unix-like platforms or + `%PROGRAMDATA%\ssh\ssh_known_hosts` on Windows). More information about these +-files can be found in the [sshd man page]. ++files can be found in the [sshd man page]. Alternatively, keys may be ++configured in a Cargo configuration file with [`net.ssh.known-hosts`]. + + When connecting to an SSH host before the known hosts has been configured, + Cargo will display an error message instructing you how to add the host key. +@@ -78,10 +79,11 @@ publish their fingerprints on the web; for example GitHub posts theirs at + . + + Cargo comes with the host keys for [github.com](https://github.com) built-in. +-If those ever change, you can add the new keys to your known_hosts file. ++If those ever change, you can add the new keys to the config or known_hosts file. + + [`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 ++[`net.ssh.known-hosts`]: ../reference/config.md#netsshknown-hosts + [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 +diff --git a/src/doc/src/reference/config.md b/src/doc/src/reference/config.md +index 1e50648797..f804ceebea 100644 +--- a/src/doc/src/reference/config.md ++++ b/src/doc/src/reference/config.md +@@ -114,6 +114,9 @@ retry = 2 # network retries + git-fetch-with-cli = true # use the `git` executable for git operations + offline = true # do not access the network + ++[net.ssh] ++known-hosts = ["..."] # known SSH host keys ++ + [patch.] + # Same keys as for [patch] in Cargo.toml + +@@ -750,6 +753,41 @@ needed, and generate an error if it encounters a network error. + + Can be overridden with the `--offline` command-line option. + ++##### `net.ssh` ++ ++The `[net.ssh]` table contains settings for SSH connections. ++ ++##### `net.ssh.known-hosts` ++* Type: array of strings ++* Default: see description ++* Environment: not supported ++ ++The `known-hosts` array contains a list of SSH host keys that should be ++accepted as valid when connecting to an SSH server (such as for SSH git ++dependencies). Each entry should be a string in a format similar to OpenSSH ++`known_hosts` files. Each string should start with one or more hostnames ++separated by commas, a space, the key type name, a space, and the ++base64-encoded key. For example: ++ ++```toml ++[net.ssh] ++known-hosts = [ ++ "example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFO4Q5T0UV0SQevair9PFwoxY9dl4pQl3u5phoqJH3cF" ++] ++``` ++ ++Cargo will attempt to load known hosts keys from common locations supported in ++OpenSSH, and will join those with any listed in a Cargo configuration file. ++If any matching entry has the correct key, the connection will be allowed. ++ ++Cargo comes with the host keys for [github.com][github-keys] built-in. If ++those ever change, you can add the new keys to the config or known_hosts file. ++ ++See [Git Authentication](../appendix/git-authentication.md#ssh-known-hosts) ++for more details. ++ ++[github-keys]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints ++ + #### `[patch]` + + Just as you can override dependencies using [`[patch]` in diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-04-add-some-known-hosts-tests-and-fix-comma-bug.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-04-add-some-known-hosts-tests-and-fix-comma-bug.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-04-add-some-known-hosts-tests-and-fix-comma-bug.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-04-add-some-known-hosts-tests-and-fix-comma-bug.patch 2023-01-17 14:05:25.000000000 +0000 @@ -0,0 +1,244 @@ +commit 302a543ddf3b7621c2f10623862029d35fae7e3c +Author: Eric Huss +Date: Mon Dec 12 20:14:23 2022 -0800 + + Add some known_hosts tests. + + This also fixes a bug with the host matching when there are comma-separated hosts. + +diff --git a/src/cargo/sources/git/known_hosts.rs b/src/cargo/sources/git/known_hosts.rs +index 7efea43c3b..58e64e7913 100644 +--- a/src/cargo/sources/git/known_hosts.rs ++++ b/src/cargo/sources/git/known_hosts.rs +@@ -21,7 +21,7 @@ + //! this file. + + use crate::util::config::{Definition, Value}; +-use git2::cert::Cert; ++use git2::cert::{Cert, SshHostKeyType}; + use git2::CertificateCheckStatus; + use std::collections::HashSet; + use std::fmt::Write; +@@ -49,7 +49,7 @@ enum KnownHostError { + /// The host key was not found. + HostKeyNotFound { + hostname: String, +- key_type: git2::cert::SshHostKeyType, ++ key_type: SshHostKeyType, + remote_host_key: String, + remote_fingerprint: String, + other_hosts: Vec, +@@ -57,7 +57,7 @@ enum KnownHostError { + /// The host key was found, but does not match the remote's key. + HostKeyHasChanged { + hostname: String, +- key_type: git2::cert::SshHostKeyType, ++ key_type: SshHostKeyType, + old_known_host: KnownHost, + remote_host_key: String, + remote_fingerprint: String, +@@ -238,11 +238,6 @@ fn check_ssh_known_hosts( + return Err(anyhow::format_err!("remote host key is not available").into()); + }; + let remote_key_type = cert_host_key.hostkey_type().unwrap(); +- // `changed_key` keeps track of any entries where the key has changed. +- let mut changed_key = None; +- // `other_hosts` keeps track of any entries that have an identical key, +- // but a different hostname. +- let mut other_hosts = Vec::new(); + + // Collect all the known host entries from disk. + let mut known_hosts = Vec::new(); +@@ -293,6 +288,21 @@ fn check_ssh_known_hosts( + }); + } + } ++ check_ssh_known_hosts_loaded(&known_hosts, host, remote_key_type, remote_host_key) ++} ++ ++/// Checks a host key against a loaded set of known hosts. ++fn check_ssh_known_hosts_loaded( ++ known_hosts: &[KnownHost], ++ host: &str, ++ remote_key_type: SshHostKeyType, ++ remote_host_key: &[u8], ++) -> Result<(), KnownHostError> { ++ // `changed_key` keeps track of any entries where the key has changed. ++ let mut changed_key = None; ++ // `other_hosts` keeps track of any entries that have an identical key, ++ // but a different hostname. ++ let mut other_hosts = Vec::new(); + + for known_host in known_hosts { + // The key type from libgit2 needs to match the key type from the host file. +@@ -301,7 +311,6 @@ fn check_ssh_known_hosts( + } + let key_matches = known_host.key == remote_host_key; + if !known_host.host_matches(host) { +- // `name` can be None for hashed hostnames (which libgit2 does not expose). + if key_matches { + other_hosts.push(known_host.clone()); + } +@@ -434,7 +443,7 @@ impl KnownHost { + return false; + } + } else { +- match_found = pattern == host; ++ match_found |= pattern == host; + } + } + match_found +@@ -444,6 +453,10 @@ impl KnownHost { + /// Loads an OpenSSH known_hosts file. + fn load_hostfile(path: &Path) -> Result, anyhow::Error> { + let contents = cargo_util::paths::read(path)?; ++ Ok(load_hostfile_contents(path, &contents)) ++} ++ ++fn load_hostfile_contents(path: &Path, contents: &str) -> Vec { + let entries = contents + .lines() + .enumerate() +@@ -455,13 +468,13 @@ fn load_hostfile(path: &Path) -> Result, anyhow::Error> { + parse_known_hosts_line(line, location) + }) + .collect(); +- Ok(entries) ++ entries + } + + fn parse_known_hosts_line(line: &str, location: KnownHostLocation) -> Option { + let line = line.trim(); + // FIXME: @revoked and @cert-authority is currently not supported. +- if line.is_empty() || line.starts_with('#') || line.starts_with('@') { ++ if line.is_empty() || line.starts_with(['#', '@', '|']) { + return None; + } + let mut parts = line.split([' ', '\t']).filter(|s| !s.is_empty()); +@@ -476,3 +489,126 @@ fn parse_known_hosts_line(line: &str, location: KnownHostLocation) -> Option { ++ assert_eq!(path, kh_path); ++ assert_eq!(*lineno, 4); ++ } ++ _ => panic!("unexpected"), ++ } ++ assert_eq!(khs[0].patterns, "example.com,rust-lang.org"); ++ assert_eq!(khs[0].key_type, "ssh-rsa"); ++ assert_eq!(khs[0].key.len(), 407); ++ assert_eq!(&khs[0].key[..30], b"\x00\x00\x00\x07ssh-rsa\x00\x00\x00\x03\x01\x00\x01\x00\x00\x01\x81\x00\xb935\x88\xa5\x9c)"); ++ match &khs[1].location { ++ KnownHostLocation::File { path, lineno } => { ++ assert_eq!(path, kh_path); ++ assert_eq!(*lineno, 5); ++ } ++ _ => panic!("unexpected"), ++ } ++ assert_eq!(khs[2].patterns, "[example.net]:2222"); ++ assert_eq!(khs[3].patterns, "nistp256.example.org"); ++ assert_eq!(khs[7].patterns, "192.168.42.12"); ++ } ++ ++ #[test] ++ fn host_matches() { ++ let kh_path = Path::new("/home/abc/.known_hosts"); ++ let khs = load_hostfile_contents(kh_path, COMMON_CONTENTS); ++ assert!(khs[0].host_matches("example.com")); ++ assert!(khs[0].host_matches("rust-lang.org")); ++ assert!(khs[0].host_matches("EXAMPLE.COM")); ++ assert!(khs[1].host_matches("example.net")); ++ assert!(!khs[0].host_matches("example.net")); ++ assert!(khs[2].host_matches("[example.net]:2222")); ++ assert!(!khs[2].host_matches("example.net")); ++ assert!(!khs[8].host_matches("neg.example.com")); ++ } ++ ++ #[test] ++ fn check_match() { ++ let kh_path = Path::new("/home/abc/.known_hosts"); ++ let khs = load_hostfile_contents(kh_path, COMMON_CONTENTS); ++ ++ assert!(check_ssh_known_hosts_loaded( ++ &khs, ++ "example.com", ++ SshHostKeyType::Rsa, ++ &khs[0].key ++ ) ++ .is_ok()); ++ ++ match check_ssh_known_hosts_loaded(&khs, "example.com", SshHostKeyType::Dss, &khs[0].key) { ++ Err(KnownHostError::HostKeyNotFound { ++ hostname, ++ remote_fingerprint, ++ other_hosts, ++ .. ++ }) => { ++ assert_eq!( ++ remote_fingerprint, ++ "yn+pONDn0EcgdOCVptgB4RZd/wqmsVKrPnQMLtrvhw8" ++ ); ++ assert_eq!(hostname, "example.com"); ++ assert_eq!(other_hosts.len(), 0); ++ } ++ _ => panic!("unexpected"), ++ } ++ ++ match check_ssh_known_hosts_loaded( ++ &khs, ++ "foo.example.com", ++ SshHostKeyType::Rsa, ++ &khs[0].key, ++ ) { ++ Err(KnownHostError::HostKeyNotFound { other_hosts, .. }) => { ++ assert_eq!(other_hosts.len(), 1); ++ assert_eq!(other_hosts[0].patterns, "example.com,rust-lang.org"); ++ } ++ _ => panic!("unexpected"), ++ } ++ ++ let mut modified_key = khs[0].key.clone(); ++ modified_key[0] = 1; ++ match check_ssh_known_hosts_loaded(&khs, "example.com", SshHostKeyType::Rsa, &modified_key) ++ { ++ Err(KnownHostError::HostKeyHasChanged { old_known_host, .. }) => { ++ assert!(matches!( ++ old_known_host.location, ++ KnownHostLocation::File { lineno: 4, .. } ++ )); ++ } ++ _ => panic!("unexpected"), ++ } ++ } ++} diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-05-remove-let-else.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-05-remove-let-else.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-05-remove-let-else.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-05-remove-let-else.patch 2023-01-17 14:05:25.000000000 +0000 @@ -0,0 +1,26 @@ +commit cf716fc3c2b0785013b321f08d6cf9e277f89c84 +Author: Eric Huss +Date: Tue Dec 13 08:14:59 2022 -0800 + + Remove let-else, just use ? propagation. + + Co-authored-by: Weihang Lo + +diff --git a/src/cargo/sources/git/known_hosts.rs b/src/cargo/sources/git/known_hosts.rs +index 58e64e7913..f272195306 100644 +--- a/src/cargo/sources/git/known_hosts.rs ++++ b/src/cargo/sources/git/known_hosts.rs +@@ -478,10 +478,9 @@ fn parse_known_hosts_line(line: &str, location: KnownHostLocation) -> Option +Date: Wed Dec 14 19:01:40 2022 -0800 + + Add test for config Value in TOML array. + +diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs +index b1d07bb405..d1487833f7 100644 +--- a/tests/testsuite/config.rs ++++ b/tests/testsuite/config.rs +@@ -1,7 +1,7 @@ + //! Tests for config settings. + + use cargo::core::{PackageIdSpec, Shell}; +-use cargo::util::config::{self, Config, SslVersionConfig, StringList}; ++use cargo::util::config::{self, Config, Definition, SslVersionConfig, StringList}; + use cargo::util::interning::InternedString; + use cargo::util::toml::{self, VecStringOrBool as VSOB}; + use cargo::CargoResult; +@@ -1508,3 +1508,59 @@ fn all_profile_options() { + let roundtrip_toml = toml_edit::easy::to_string(&roundtrip).unwrap(); + compare::assert_match_exact(&profile_toml, &roundtrip_toml); + } ++ ++#[cargo_test] ++fn value_in_array() { ++ // Value in an array should work ++ let root_path = paths::root().join(".cargo/config.toml"); ++ write_config_at( ++ &root_path, ++ "\ ++[net.ssh] ++known-hosts = [ ++ \"example.com ...\", ++ \"example.net ...\", ++] ++", ++ ); ++ ++ let foo_path = paths::root().join("foo/.cargo/config.toml"); ++ write_config_at( ++ &foo_path, ++ "\ ++[net.ssh] ++known-hosts = [ ++ \"example.org ...\", ++] ++", ++ ); ++ ++ let config = ConfigBuilder::new() ++ .cwd("foo") ++ // environment variables don't actually work for known-hosts due to ++ // space splitting, but this is included here just to validate that ++ // they work (particularly if other Vec config vars are added ++ // in the future). ++ .env("CARGO_NET_SSH_KNOWN_HOSTS", "env-example") ++ .build(); ++ let net_config = config.net_config().unwrap(); ++ let kh = net_config ++ .ssh ++ .as_ref() ++ .unwrap() ++ .known_hosts ++ .as_ref() ++ .unwrap(); ++ assert_eq!(kh.len(), 4); ++ assert_eq!(kh[0].val, "example.org ..."); ++ assert_eq!(kh[0].definition, Definition::Path(foo_path.clone())); ++ assert_eq!(kh[1].val, "example.com ..."); ++ assert_eq!(kh[1].definition, Definition::Path(root_path.clone())); ++ assert_eq!(kh[2].val, "example.net ..."); ++ assert_eq!(kh[2].definition, Definition::Path(root_path.clone())); ++ assert_eq!(kh[3].val, "env-example"); ++ assert_eq!( ++ kh[3].definition, ++ Definition::Environment("CARGO_NET_SSH_KNOWN_HOSTS".to_string()) ++ ); ++} diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-07-support-hashed-hostnames.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-07-support-hashed-hostnames.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-07-support-hashed-hostnames.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-07-support-hashed-hostnames.patch 2023-01-17 14:05:25.000000000 +0000 @@ -0,0 +1,125 @@ +This patch is based on the upstream commit described below, adapted for use +in the Debian package by Peter Michael Green. + +commit 67ae2dcafea5955824b1f390568a5fa109424987 +Author: Eric Huss +Date: Wed Dec 28 15:52:10 2022 -0800 + + ssh known_hosts: support hashed hostnames + +Index: cargo/src/cargo/sources/git/known_hosts.rs +=================================================================== +--- cargo.orig/src/cargo/sources/git/known_hosts.rs ++++ cargo/src/cargo/sources/git/known_hosts.rs +@@ -16,13 +16,13 @@ + //! - `VerifyHostKeyDNS` — Uses SSHFP DNS records to fetch a host key. + //! + //! There's also a number of things that aren't supported but could be easily +-//! added (it just adds a little complexity). For example, hashed hostnames, +-//! hostname patterns, and revoked markers. See "FIXME" comments littered in +-//! this file. ++//! added (it just adds a little complexity). For example, hostname patterns, ++//! and revoked markers. See "FIXME" comments littered in this file. + + use crate::util::config::{Definition, Value}; + use git2::cert::{Cert, SshHostKeyType}; + use git2::CertificateCheckStatus; ++use hmac::Mac; + use std::collections::HashSet; + use std::fmt::Write; + use std::path::{Path, PathBuf}; +@@ -419,6 +419,8 @@ fn user_known_host_location_to_add(diagn + ) + } + ++const HASH_HOSTNAME_PREFIX: &str = "|1|"; ++ + /// A single known host entry. + #[derive(Clone)] + struct KnownHost { +@@ -434,7 +436,9 @@ impl KnownHost { + fn host_matches(&self, host: &str) -> bool { + let mut match_found = false; + let host = host.to_lowercase(); +- // FIXME: support hashed hostnames ++ if let Some(hashed) = self.patterns.strip_prefix(HASH_HOSTNAME_PREFIX) { ++ return hashed_hostname_matches(&host, hashed); ++ } + for pattern in self.patterns.split(',') { + let pattern = pattern.to_lowercase(); + // FIXME: support * and ? wildcards +@@ -450,6 +454,16 @@ impl KnownHost { + } + } + ++fn hashed_hostname_matches(host: &str, hashed: &str) -> bool { ++ let Some((b64_salt, b64_host)) = hashed.split_once('|') else { return false; }; ++ let Ok(salt) = base64::decode(b64_salt) else { return false; }; ++ let Ok(hashed_host) = base64::decode(b64_host) else { return false; }; ++ let Ok(mut mac) = hmac::Hmac::::new_from_slice(&salt) else { return false; }; ++ mac.update(host.as_bytes()); ++ let result = mac.finalize().into_bytes(); ++ hashed_host == &result[..] ++} ++ + /// Loads an OpenSSH known_hosts file. + fn load_hostfile(path: &Path) -> Result, anyhow::Error> { + let contents = cargo_util::paths::read(path)?; +@@ -474,7 +488,7 @@ fn load_hostfile_contents(path: &Path, c + fn parse_known_hosts_line(line: &str, location: KnownHostLocation) -> Option { + let line = line.trim(); + // FIXME: @revoked and @cert-authority is currently not supported. +- if line.is_empty() || line.starts_with(['#', '@', '|']) { ++ if line.is_empty() || line.starts_with(['#', '@']) { + return None; + } + let mut parts = line.split([' ', '\t']).filter(|s| !s.is_empty()); +@@ -506,8 +520,7 @@ mod tests { + @revoked * ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKtQsi+KPYispwm2rkMidQf30fG1Niy8XNkvASfePoca eric@host + example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAWkjI6XT2SZh3xNk5NhisA3o3sGzWR+VAKMSqHtI0aY eric@host + 192.168.42.12 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKVYJpa0yUGaNk0NXQTPWa0tHjqRpx+7hl2diReH6DtR eric@host +- # Hash not yet supported. +- |1|7CMSYgzdwruFLRhwowMtKx0maIE=|Tlff1GFqc3Ao+fUWxMEVG8mJiyk= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIHgN3O21U4LWtP5OzjTzPnUnSDmCNDvyvlaj6Hi65JC eric@host ++ |1|QxzZoTXIWLhUsuHAXjuDMIV3FjQ=|M6NCOIkjiWdCWqkh5+Q+/uFLGjs= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIHgN3O21U4LWtP5OzjTzPnUnSDmCNDvyvlaj6Hi65JC eric@host + # Negation isn't terribly useful without globs. + neg.example.com,!neg.example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOXfUnaAHTlo1Qi//rNk26OcmHikmkns1Z6WW/UuuS3K eric@host + "#; +@@ -516,7 +529,7 @@ mod tests { + fn known_hosts_parse() { + let kh_path = Path::new("/home/abc/.known_hosts"); + let khs = load_hostfile_contents(kh_path, COMMON_CONTENTS); +- assert_eq!(khs.len(), 9); ++ assert_eq!(khs.len(), 10); + match &khs[0].location { + KnownHostLocation::File { path, lineno } => { + assert_eq!(path, kh_path); +@@ -551,7 +564,9 @@ mod tests { + assert!(!khs[0].host_matches("example.net")); + assert!(khs[2].host_matches("[example.net]:2222")); + assert!(!khs[2].host_matches("example.net")); +- assert!(!khs[8].host_matches("neg.example.com")); ++ assert!(khs[8].host_matches("hashed.example.com")); ++ assert!(!khs[8].host_matches("example.com")); ++ assert!(!khs[9].host_matches("neg.example.com")); + } + + #[test] +--- rust-cargo-0.66.0.orig/Cargo.toml ++++ rust-cargo-0.66.0/Cargo.toml +@@ -33,6 +33,7 @@ git2 = "0.16.0" + git2-curl = "0.17.0" + glob = "0.3.0" + hex = "0.4" ++hmac = "0.12.1" + home = "0.5" + humantime = "2.0.0" + indexmap = "1" +@@ -53,6 +54,7 @@ semver = { version = "1.0.3", features = + serde = { version = "1.0.123", features = ["derive"] } + serde_ignored = "0.1.0" + serde_json = { version = "1.0.30", features = ["raw_value"] } ++sha1 = "0.10.1" + shell-escape = "0.1.4" + strip-ansi-escapes = "0.1.0" + tar = { version = "0.4.38", default-features = false } + diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-08-eliminate-let-else.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-08-eliminate-let-else.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-08-eliminate-let-else.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/cve/CVE-2022-46176-08-eliminate-let-else.patch 2023-01-17 14:05:25.000000000 +0000 @@ -0,0 +1,61 @@ +This patch eliminates let-else usage in the code introduced +to fix CVE-2022-46176 as that construct is not stabalised in +the version of rustc currently in Debian. + +It was written specifical for Debian by Peter Michael Green. + +Index: cargo/src/cargo/sources/git/known_hosts.rs +=================================================================== +--- cargo.orig/src/cargo/sources/git/known_hosts.rs ++++ cargo/src/cargo/sources/git/known_hosts.rs +@@ -89,11 +89,13 @@ pub fn certificate_check( + config_known_hosts: Option<&Vec>>, + diagnostic_home_config: &str, + ) -> Result { +- let Some(host_key) = cert.as_hostkey() else { ++ let host_key = cert.as_hostkey(); ++ if host_key.is_none() { + // Return passthrough for TLS X509 certificates to use whatever validation + // was done in git2. + return Ok(CertificateCheckStatus::CertificatePassthrough) + }; ++ let host_key = host_key.unwrap(); + // If a nonstandard port is in use, check for that first. + // The fallback to check without a port is handled in the HostKeyNotFound handler. + let host_maybe_port = match port { +@@ -234,9 +236,11 @@ fn check_ssh_known_hosts( + host: &str, + config_known_hosts: Option<&Vec>>, + ) -> Result<(), KnownHostError> { +- let Some(remote_host_key) = cert_host_key.hostkey() else { ++ let remote_host_key = cert_host_key.hostkey(); ++ if remote_host_key.is_none() { + return Err(anyhow::format_err!("remote host key is not available").into()); + }; ++ let remote_host_key = remote_host_key.unwrap(); + let remote_key_type = cert_host_key.hostkey_type().unwrap(); + + // Collect all the known host entries from disk. +@@ -455,10 +459,18 @@ impl KnownHost { + } + + fn hashed_hostname_matches(host: &str, hashed: &str) -> bool { +- let Some((b64_salt, b64_host)) = hashed.split_once('|') else { return false; }; +- let Ok(salt) = base64::decode(b64_salt) else { return false; }; +- let Ok(hashed_host) = base64::decode(b64_host) else { return false; }; +- let Ok(mut mac) = hmac::Hmac::::new_from_slice(&salt) else { return false; }; ++ let hostandsalt = hashed.split_once('|'); ++ if hostandsalt.is_none() { return false; }; ++ let (b64_salt, b64_host) = hostandsalt.unwrap(); ++ let salt = base64::decode(b64_salt); ++ if salt.is_err() { return false; }; ++ let salt = salt.unwrap(); ++ let hashed_host = base64::decode(b64_host); ++ if hashed_host.is_err() { return false; }; ++ let hashed_host = hashed_host.unwrap(); ++ let mac = hmac::Hmac::::new_from_slice(&salt); ++ if mac.is_err() { return false; }; ++ let mut mac = mac.unwrap(); + mac.update(host.as_bytes()); + let result = mac.finalize().into_bytes(); + hashed_host == &result[..] diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/remove-badges.patch cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/remove-badges.patch --- cargo-0.64.0ubuntu0.libgit2/debian/patches/remove-badges.patch 2022-09-16 13:57:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/remove-badges.patch 2023-01-17 14:08:25.000000000 +0000 @@ -6,7 +6,7 @@ -[github](https://github.com/dtolnay/proc-macro2) -[crates.io](https://crates.io/crates/proc-macro2) -[docs.rs](https://docs.rs/proc-macro2) --[build status](https://github.com/dtolnay/proc-macro2/actions?query=branch%3Amaster) +-[build status](https://github.com/dtolnay/proc-macro2/actions?query=branch%3Amaster) - A wrapper around the procedural macro API of the compiler's `proc_macro` crate. This library serves two purposes: @@ -20,7 +20,7 @@ -[github](https://github.com/dtolnay/quote) -[crates.io](https://crates.io/crates/quote) -[docs.rs](https://docs.rs/quote) --[build status](https://github.com/dtolnay/quote/actions?query=branch%3Amaster) +-[build status](https://github.com/dtolnay/quote/actions?query=branch%3Amaster) - This crate provides the [`quote!`] macro for turning Rust syntax tree data structures into tokens of source code. @@ -34,7 +34,7 @@ -[github](https://github.com/dtolnay/syn) -[crates.io](https://crates.io/crates/syn) -[docs.rs](https://docs.rs/syn) --[build status](https://github.com/dtolnay/syn/actions?query=branch%3Amaster) +-[build status](https://github.com/dtolnay/syn/actions?query=branch%3Amaster) - Syn is a parsing library for parsing a stream of Rust tokens into a syntax tree of Rust source code. @@ -84,7 +84,7 @@ -[github](https://github.com/dtolnay/unicode-ident) -[crates.io](https://crates.io/crates/unicode-ident) -[docs.rs](https://docs.rs/unicode-ident) --[build status](https://github.com/dtolnay/unicode-ident/actions?query=branch%3Amaster) +-[build status](https://github.com/dtolnay/unicode-ident/actions?query=branch%3Amaster) - Implementation of [Unicode Standard Annex #31][tr31] for determining which `char` values are valid in programming language identifiers. diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/patches/series cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/series --- cargo-0.64.0ubuntu0.libgit2/debian/patches/series 2022-12-01 13:00:36.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/patches/series 2023-01-18 20:42:34.000000000 +0000 @@ -1,11 +1,19 @@ 2002_disable-net-tests.patch +2003-workaround-qemu-vfork-command-not-found.patch 2200-workaround-x32-test.patch -0001-CVE-2022-36113-avoid-unpacking-.cargo-ok-from-the-cr.patch -0001-CVE-2022-36114-limit-the-maximum-unpacked-size-of-a-.patch disable-fs-specific-test.patch 0003-tests-add-missing-cross-disabled-checks.patch + +cve/CVE-2022-46176-01-validate-ssh-host.keys.patch +cve/CVE-2022-46176-02-add-support-for-deserializing-vec-value-string.patch +cve/CVE-2022-46176-03-support-configuring-ssh-known-hosts.patch +cve/CVE-2022-46176-04-add-some-known-hosts-tests-and-fix-comma-bug.patch +cve/CVE-2022-46176-05-remove-let-else.patch +cve/CVE-2022-46176-06-add-test-for-config-value-in-toml-array.patch +cve/CVE-2022-46176-07-support-hashed-hostnames.patch +cve/CVE-2022-46176-08-eliminate-let-else.patch + remove-badges.patch proxy-skip-tests.patch i386-crossbuild-tests.patch -# bump-libgit2.patch diff -Nru cargo-0.64.0ubuntu0.libgit2/debian/vendor-tarball-unsuspicious.txt cargo-0.66.0+ds0ubuntu0.libgit2/debian/vendor-tarball-unsuspicious.txt --- cargo-0.64.0ubuntu0.libgit2/debian/vendor-tarball-unsuspicious.txt 2022-12-01 12:18:16.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/debian/vendor-tarball-unsuspicious.txt 2023-01-17 14:05:25.000000000 +0000 @@ -7,6 +7,10 @@ */LICENSE.md */README.md */Cargo.toml +base64/RELEASE-NOTES.md + +# ignore +base64/icon_CLion.svg # test data bstr/src/unicode/data/*Test.txt @@ -14,6 +18,7 @@ combine/benches/http-requests.txt content_inspector/testdata/* flate2/tests/ +hmac/tests/data/*.blb idna/tests/IdnaTestV2.txt idna/tests/punycode_tests.json im-rc/proptest-regressions/ @@ -30,6 +35,7 @@ schannel/test/cert.der schannel/test/cert.pem schannel/test/key_wrong_header.pem +sha1/tests/data/*.blb toml_edit/tests/fixtures/* unicode-ident/tests/fst/*.fst url/tests/*.json @@ -38,6 +44,7 @@ # ideally should be autogenerated, but too difficult today bstr/src/unicode/fsm/*.dfa +bstr-0.2.17/src/unicode/fsm/*.dfa regex-syntax/src/unicode_tables/*.rs # "verylongtext" but OK source code, manually audited: @@ -65,6 +72,9 @@ # false positive (Algol68) aho-corasick/src/nfa.rs +base64/src/encode.rs +base64/src/decode.rs +block-buffer/tests/mod.rs clap/src/derive.rs combine/src/parser/choice.rs combine/src/parser/mod.rs @@ -72,6 +82,9 @@ combine/src/parser/token.rs combine/src/stream/mod.rs combine/src/stream/position.rs +digest/src/dev.rs +digest/src/core_api/wrapper.rs +digest/src/core_api/rt_variable.rs env_logger-0.7.1/src/fmt/writer/mod.rs env_logger/src/fmt/writer/mod.rs flate2/src/mem.rs diff -Nru cargo-0.64.0ubuntu0.libgit2/.github/workflows/contrib.yml cargo-0.66.0+ds0ubuntu0.libgit2/.github/workflows/contrib.yml --- cargo-0.64.0ubuntu0.libgit2/.github/workflows/contrib.yml 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/.github/workflows/contrib.yml 2022-10-20 06:00:42.000000000 +0000 @@ -4,8 +4,13 @@ branches: - master +permissions: + contents: read + jobs: deploy: + permissions: + contents: write # for Git to git push runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -16,6 +21,9 @@ mkdir mdbook curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.9/mdbook-v0.4.9-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook echo `pwd`/mdbook >> $GITHUB_PATH + - name: Build API doc + run: | + cargo doc --document-private-items --no-deps - name: Deploy docs run: | cd src/doc/contrib @@ -28,6 +36,8 @@ git update-ref -d refs/heads/gh-pages rm -rf contrib mv ../book contrib + # Move rustdoc under contrib/ + mv ../../../../target/doc contrib/apidoc git add contrib git commit -m "Deploy $GITHUB_SHA to gh-pages" git push --force diff -Nru cargo-0.64.0ubuntu0.libgit2/.github/workflows/main.yml cargo-0.66.0+ds0ubuntu0.libgit2/.github/workflows/main.yml --- cargo-0.64.0ubuntu0.libgit2/.github/workflows/main.yml 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/.github/workflows/main.yml 2022-10-20 06:00:42.000000000 +0000 @@ -9,6 +9,9 @@ run: shell: bash +permissions: + contents: read + jobs: # Check Code style quickly by running `rustfmt` over all code rustfmt: @@ -34,24 +37,31 @@ strategy: matrix: include: - - os: ubuntu-latest + - name: Linux x86_64 stable + os: ubuntu-latest rust: stable other: i686-unknown-linux-gnu - - os: ubuntu-latest + - name: Linux x86_64 beta + os: ubuntu-latest rust: beta other: i686-unknown-linux-gnu - - os: ubuntu-latest + - name: Linux x86_64 nightly + os: ubuntu-latest rust: nightly other: i686-unknown-linux-gnu - - os: macos-latest + - name: macOS x86_64 stable + os: macos-latest rust: stable other: x86_64-apple-ios - - os: windows-latest + - name: Windows x86_64 MSVC stable + os: windows-latest rust: stable-msvc other: i686-pc-windows-msvc - - os: windows-latest + - name: Windows x86_64 gnu nightly + os: windows-latest rust: nightly-gnu other: i686-pc-windows-gnu + name: Tests ${{ matrix.name }} steps: - uses: actions/checkout@v3 - name: Dump Environment @@ -140,7 +150,9 @@ mkdir mdbook curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.5/mdbook-v0.4.5-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook echo `pwd`/mdbook >> $GITHUB_PATH - - run: cargo doc --no-deps + - run: cargo doc --document-private-items --no-deps + env: + RUSTDOCFLAGS: -D warnings - run: cd src/doc && mdbook build --dest-dir ../../target/doc - run: | cd src/doc @@ -149,6 +161,8 @@ sh linkcheck.sh --all cargo success: + permissions: + contents: none name: bors build finished needs: [docs, rustfmt, test, resolver, build_std] runs-on: ubuntu-latest @@ -156,6 +170,8 @@ steps: - run: echo ok failure: + permissions: + contents: none name: bors build finished needs: [docs, rustfmt, test, resolver, build_std] runs-on: ubuntu-latest diff -Nru cargo-0.64.0ubuntu0.libgit2/.ignore cargo-0.66.0+ds0ubuntu0.libgit2/.ignore --- cargo-0.64.0ubuntu0.libgit2/.ignore 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/.ignore 2022-10-20 06:00:42.000000000 +0000 @@ -0,0 +1,6 @@ +# Output generated from src/doc/man +# +# The goal is to help people find the right file to edit +src/doc/man/generated_txt +src/doc/src/commands +src/etc/man diff -Nru cargo-0.64.0ubuntu0.libgit2/README.md cargo-0.66.0+ds0ubuntu0.libgit2/README.md --- cargo-0.64.0ubuntu0.libgit2/README.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/README.md 2022-10-20 06:00:42.000000000 +0000 @@ -22,14 +22,44 @@ ## Compiling from Source +### Requirements + Cargo requires the following tools and packages to build: -* `git` -* `curl` (on Unix) -* `pkg-config` (on Unix, used to figure out the `libssl` headers/libraries) -* OpenSSL headers (only for Unix, this is the `libssl-dev` package on ubuntu) -* A C compiler [for your platform](https://github.com/rust-lang/cc-rs#compile-time-requirements) * `cargo` and `rustc` +* A C compiler [for your platform](https://github.com/rust-lang/cc-rs#compile-time-requirements) +* `git` (to clone this repository) + +**Other requirements:** + +The following are optional based on your platform and needs. + +* `pkg-config` — This is used to help locate system packages, such as `libssl` headers/libraries. This may not be required in all cases, such as using vendored OpenSSL, or on Windows. +* OpenSSL — Only needed on Unix-like systems and only if the `vendored-openssl` Cargo feature is not used. + + This requires the development headers, which can be obtained from the `libssl-dev` package on Ubuntu or `openssl-devel` with apk or yum or the `openssl` package from Homebrew on macOS. + + If using the `vendored-openssl` Cargo feature, then a static copy of OpenSSL will be built from source instead of using the system OpenSSL. + This may require additional tools such as `perl` and `make`. + + On macOS, common installation directories from Homebrew, MacPorts, or pkgsrc will be checked. Otherwise it will fall back to `pkg-config`. + + On Windows, the system-provided Schannel will be used instead. + + LibreSSL is also supported. + +**Optional system libraries:** + +The build will automatically use vendored versions of the following libraries. However, if they are provided by the system and can be found with `pkg-config`, then the system libraries will be used instead: + +* [`libcurl`](https://curl.se/libcurl/) — Used for network transfers. +* [`libgit2`](https://libgit2.org/) — Used for fetching git dependencies. +* [`libssh2`](https://www.libssh2.org/) — Used for SSH access to git repositories. +* [`libz`](https://zlib.net/) (aka zlib) — Used for data compression. + +It is recommended to use the vendored versions as they are the versions that are tested to work with Cargo. + +### Compiling First, you'll want to check out this repository diff -Nru cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/cli.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/cli.rs --- cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/cli.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/cli.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,10 +1,8 @@ use anyhow::anyhow; +use cargo::core::shell::Shell; use cargo::core::{features, CliUnstable}; use cargo::{self, drop_print, drop_println, CliResult, Config}; -use clap::{ - error::{ContextKind, ContextValue}, - AppSettings, Arg, ArgMatches, -}; +use clap::{AppSettings, Arg, ArgMatches}; use itertools::Itertools; use std::collections::HashMap; use std::fmt::Write; @@ -24,36 +22,13 @@ ]); } -pub fn main(config: &mut Config) -> CliResult { +pub fn main(config: &mut LazyConfig) -> CliResult { + let args = cli().try_get_matches()?; + // CAUTION: Be careful with using `config` until it is configured below. // In general, try to avoid loading config values unless necessary (like // the [alias] table). - - if commands::help::handle_embedded_help(config) { - return Ok(()); - } - - let args = match cli().try_get_matches() { - Ok(args) => args, - Err(e) => { - if e.kind() == clap::ErrorKind::UnrecognizedSubcommand { - // An unrecognized subcommand might be an external subcommand. - let cmd = e - .context() - .find_map(|c| match c { - (ContextKind::InvalidSubcommand, &ContextValue::String(ref cmd)) => { - Some(cmd) - } - _ => None, - }) - .expect("UnrecognizedSubcommand implies the presence of InvalidSubcommand"); - return super::execute_external_subcommand(config, cmd, &[cmd, "--help"]) - .map_err(|_| e.into()); - } else { - return Err(e.into()); - } - } - }; + let config = config.get_mut(); // Global args need to be extracted before expanding aliases because the // clap code for extracting a subcommand discards global options @@ -412,7 +387,7 @@ } } -fn cli() -> App { +pub fn cli() -> App { let is_rustup = std::env::var_os("RUSTUP_HOME").is_some(); let usage = if is_rustup { "cargo [+toolchain] [OPTIONS] [SUBCOMMAND]" @@ -425,6 +400,8 @@ // Doesn't mix well with our list of common cargo commands. See clap-rs/clap#3108 for // opening clap up to allow us to style our help template .disable_colored_help(true) + // Provide a custom help subcommand for calling into man pages + .disable_help_subcommand(true) .override_usage(usage) .help_template( "\ @@ -488,6 +465,42 @@ .subcommands(commands::builtin()) } +/// Delay loading [`Config`] until access. +/// +/// In the common path, the [`Config`] is dependent on CLI parsing and shouldn't be loaded until +/// after that is done but some other paths (like fix or earlier errors) might need access to it, +/// so this provides a way to share the instance and the implementation across these different +/// accesses. +pub struct LazyConfig { + config: Option, +} + +impl LazyConfig { + pub fn new() -> Self { + Self { config: None } + } + + /// Get the config, loading it if needed + /// + /// On error, the process is terminated + pub fn get(&mut self) -> &Config { + self.get_mut() + } + + /// Get the config, loading it if needed + /// + /// On error, the process is terminated + pub fn get_mut(&mut self) -> &mut Config { + self.config.get_or_insert_with(|| match Config::default() { + Ok(cfg) => cfg, + Err(e) => { + let mut shell = Shell::new(); + cargo::exit_with_error(e.into(), &mut shell) + } + }) + } +} + #[test] fn verify_cli() { cli().debug_assert(); diff -Nru cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/add.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/add.rs --- cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/add.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/add.rs 2022-10-20 06:00:42.000000000 +0000 @@ -7,6 +7,7 @@ use cargo::ops::cargo_add::AddOptions; use cargo::ops::cargo_add::DepOp; use cargo::ops::cargo_add::DepTable; +use cargo::ops::resolve_ws; use cargo::util::command_prelude::*; use cargo::util::interning::InternedString; use cargo::CargoResult; @@ -81,9 +82,6 @@ .takes_value(true) .value_name("SPEC") .help("Package to modify"), - clap::Arg::new("offline") - .long("offline") - .help("Run without accessing the network") ]) .arg_quiet() .arg_dry_run("Don't actually write the manifest") @@ -196,6 +194,12 @@ }; add(&ws, &options)?; + if !dry_run { + // Reload the workspace since we've changed dependencies + let ws = args.workspace(config)?; + resolve_ws(&ws)?; + } + Ok(()) } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/bench.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/bench.rs --- cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/bench.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/bench.rs 2022-10-20 06:00:42.000000000 +0000 @@ -73,12 +73,5 @@ let bench_args = bench_args.chain(args.get_many::("args").unwrap_or_default()); let bench_args = bench_args.map(String::as_str).collect::>(); - let err = ops::run_benches(&ws, &ops, &bench_args)?; - match err { - None => Ok(()), - Some(err) => Err(match err.code { - Some(i) => CliError::new(anyhow::format_err!("bench failed"), i), - None => CliError::new(err.into(), 101), - }), - } + ops::run_benches(&ws, &ops, &bench_args) } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/help.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/help.rs --- cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/help.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/help.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,4 +1,5 @@ use crate::aliased_command; +use crate::command_prelude::*; use cargo::util::errors::CargoResult; use cargo::{drop_println, Config}; use cargo_util::paths::resolve_executable; @@ -10,43 +11,26 @@ const COMPRESSED_MAN: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/man.tgz")); -/// Checks if the `help` command is being issued. -/// -/// This runs before clap processing, because it needs to intercept the `help` -/// command if a man page is available. -/// -/// 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!("help failed: {:?}", e); - false - } - } +pub fn cli() -> App { + subcommand("help") + .about("Displays help for a cargo subcommand") + .arg(Arg::new("SUBCOMMAND")) } -fn try_help(config: &Config) -> CargoResult { - let mut args = std::env::args_os() - .skip(1) - .skip_while(|arg| arg.to_str().map_or(false, |s| s.starts_with('-'))); - if !args - .next() - .map_or(false, |arg| arg.to_str() == Some("help")) - { - return Ok(false); +pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { + let subcommand = args.get_one::("SUBCOMMAND"); + if let Some(subcommand) = subcommand { + if !try_help(config, subcommand)? { + crate::execute_external_subcommand(config, subcommand, &[subcommand, "--help"])?; + } + } else { + let mut cmd = crate::cli::cli(); + let _ = cmd.print_help(); } - let subcommand = match args.next() { - Some(arg) => arg, - None => return Ok(false), - }; - let subcommand = match subcommand.to_str() { - Some(s) => s, - None => return Ok(false), - }; + Ok(()) +} +fn try_help(config: &Config, subcommand: &str) -> CargoResult { 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 => { diff -Nru cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/install.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/install.rs --- cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/install.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/install.rs 2022-10-20 06:00:42.000000000 +0000 @@ -55,7 +55,10 @@ .arg(flag("no-track", "Do not save tracking information")) .arg_features() .arg_profile("Install artifacts with the specified profile") - .arg(flag("debug", "Build in debug mode instead of release mode")) + .arg(flag( + "debug", + "Build in debug mode (with the 'dev' profile) instead of release mode", + )) .arg_targets_bins_examples( "Install only the specified binary", "Install all binaries", diff -Nru cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -13,6 +13,7 @@ fix::cli(), generate_lockfile::cli(), git_checkout::cli(), + help::cli(), init::cli(), install::cli(), locate_project::cli(), @@ -54,6 +55,7 @@ "fix" => fix::exec, "generate-lockfile" => generate_lockfile::exec, "git-checkout" => git_checkout::exec, + "help" => help::exec, "init" => init::exec, "install" => install::exec, "locate-project" => locate_project::exec, diff -Nru cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/rustc.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/rustc.rs --- cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/rustc.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/rustc.rs 2022-10-20 06:00:42.000000000 +0000 @@ -39,7 +39,7 @@ .arg(multi_opt( CRATE_TYPE_ARG_NAME, "CRATE-TYPE", - "Comma separated list of types of crates for the compiler to emit (unstable)", + "Comma separated list of types of crates for the compiler to emit", )) .arg_target_dir() .arg_manifest_path() @@ -88,9 +88,6 @@ 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)?; diff -Nru cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/test.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/test.rs --- cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/commands/test.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/commands/test.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,4 @@ use crate::command_prelude::*; -use anyhow::Error; use cargo::ops; pub fn cli() -> App { @@ -110,18 +109,5 @@ compile_opts, }; - let err = ops::run_tests(&ws, &ops, &test_args)?; - match err { - None => Ok(()), - Some(err) => { - let context = anyhow::format_err!("{}", err.hint(&ws, &ops.compile_opts)); - let e = match err.code { - // Don't show "process didn't exit successfully" for simple errors. - Some(i) if cargo_util::is_simple_exit_code(i) => CliError::new(context, i), - Some(i) => CliError::new(Error::from(err).context(context), i), - None => CliError::new(Error::from(err).context(context), 101), - }; - Err(e) - } - } + ops::run_tests(&ws, &ops, &test_args) } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/main.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/main.rs --- cargo-0.64.0ubuntu0.libgit2/src/bin/cargo/main.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/bin/cargo/main.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,7 +1,6 @@ #![warn(rust_2018_idioms)] // while we're getting used to 2018 #![allow(clippy::all)] -use cargo::core::shell::Shell; use cargo::util::toml::StringOrVec; use cargo::util::CliError; use cargo::util::{self, closest_msg, command_prelude, CargoResult, CliResult, Config}; @@ -22,25 +21,17 @@ #[cfg(not(feature = "pretty-env-logger"))] env_logger::init_from_env("CARGO_LOG"); - let mut config = match Config::default() { - Ok(cfg) => cfg, - Err(e) => { - let mut shell = Shell::new(); - cargo::exit_with_error(e.into(), &mut shell) - } - }; + let mut config = cli::LazyConfig::new(); - let result = match cargo::ops::fix_maybe_exec_rustc(&config) { - Ok(true) => Ok(()), - Ok(false) => { - let _token = cargo::util::job::setup(); - cli::main(&mut config) - } - Err(e) => Err(CliError::from(e)), + let result = if let Some(lock_addr) = cargo::ops::fix_get_proxy_lock_addr() { + cargo::ops::fix_exec_rustc(config.get(), &lock_addr).map_err(|e| CliError::from(e)) + } else { + let _token = cargo::util::job::setup(); + cli::main(&mut config) }; match result { - Err(e) => cargo::exit_with_error(e, &mut *config.shell()), + Err(e) => cargo::exit_with_error(e, &mut config.get_mut().shell()), Ok(()) => {} } } @@ -166,19 +157,36 @@ let command = match path { Some(command) => command, None => { - let suggestions = list_commands(config); - let did_you_mean = closest_msg(cmd, suggestions.keys(), |c| c); - let err = anyhow::format_err!("no such subcommand: `{}`{}", cmd, did_you_mean); + let err = if cmd.starts_with('+') { + anyhow::format_err!( + "no such subcommand: `{}`\n\n\t\ + Cargo does not handle `+toolchain` directives.\n\t\ + Did you mean to invoke `cargo` through `rustup` instead?", + cmd + ) + } else { + let suggestions = list_commands(config); + let did_you_mean = closest_msg(cmd, suggestions.keys(), |c| c); + + anyhow::format_err!( + "no such subcommand: `{}`{}\n\n\t\ + View all installed commands with `cargo --list`", + cmd, + did_you_mean + ) + }; + return Err(CliError::new(err, 101)); } }; let cargo_exe = config.cargo_exe()?; - let err = match ProcessBuilder::new(&command) - .env(cargo::CARGO_ENV, cargo_exe) - .args(args) - .exec_replace() - { + let mut cmd = ProcessBuilder::new(&command); + cmd.env(cargo::CARGO_ENV, cargo_exe).args(args); + if let Some(client) = config.jobserver_from_env() { + cmd.inherit_jobserver(client); + } + let err = match cmd.exec_replace() { Ok(()) => return Ok(()), Err(e) => e, }; @@ -204,11 +212,28 @@ } fn search_directories(config: &Config) -> Vec { - let mut dirs = vec![config.home().clone().into_path_unlocked().join("bin")]; - if let Some(val) = env::var_os("PATH") { - dirs.extend(env::split_paths(&val)); - } - dirs + let mut path_dirs = if let Some(val) = env::var_os("PATH") { + env::split_paths(&val).collect() + } else { + vec![] + }; + + let home_bin = config.home().clone().into_path_unlocked().join("bin"); + + // If any of that PATH elements contains `home_bin`, do not + // add it again. This is so that the users can control priority + // of it using PATH, while preserving the historical + // behavior of preferring it over system global directories even + // when not in PATH at all. + // See https://github.com/rust-lang/cargo/issues/11020 for details. + // + // Note: `p == home_bin` will ignore trailing slash, but we don't + // `canonicalize` the paths. + if !path_dirs.iter().any(|p| p == &home_bin) { + path_dirs.insert(0, home_bin); + }; + + path_dirs } fn init_git_transports(config: &Config) { @@ -239,4 +264,27 @@ unsafe { git2_curl::register(handle); } + + // Disabling the owner validation in git can, in theory, lead to code execution + // vulnerabilities. However, libgit2 does not launch executables, which is the foundation of + // the original security issue. Meanwhile, issues with refusing to load git repos in + // `CARGO_HOME` for example will likely be very frustrating for users. So, we disable the + // validation. + // + // For further discussion of Cargo's current interactions with git, see + // + // https://github.com/rust-lang/rfcs/pull/3279 + // + // and in particular the subsection on "Git support". + // + // Note that we only disable this when Cargo is run as a binary. If Cargo is used as a library, + // this code won't be invoked. Instead, developers will need to explicitly disable the + // validation in their code. This is inconvenient, but won't accidentally open consuming + // applications up to security issues if they use git2 to open repositories elsewhere in their + // code. + unsafe { + if git2::opts::set_verify_owner_validation(false).is_err() { + return; + } + } } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/build_config.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/build_config.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/build_config.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/build_config.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,11 +1,12 @@ use crate::core::compiler::CompileKind; use crate::util::interning::InternedString; use crate::util::{CargoResult, Config, RustfixDiagnosticServer}; -use anyhow::bail; +use anyhow::{bail, Context as _}; use cargo_util::ProcessBuilder; use serde::ser; use std::cell::RefCell; use std::path::PathBuf; +use std::thread::available_parallelism; /// Configuration information for a rustc build. #[derive(Debug)] @@ -45,6 +46,12 @@ pub timing_outputs: Vec, } +fn default_parallelism() -> CargoResult { + Ok(available_parallelism() + .context("failed to determine the amount of parallelism available")? + .get() as u32) +} + impl BuildConfig { /// Parses all config files to learn about build configuration. Currently /// configured options are: @@ -56,16 +63,13 @@ /// * `target.$target.libfoo.metadata` pub fn new( config: &Config, - jobs: Option, + jobs: Option, keep_going: bool, requested_targets: &[String], mode: CompileMode, ) -> CargoResult { let cfg = config.build_config()?; let requested_kinds = CompileKind::from_requested_targets(config, requested_targets)?; - if jobs == Some(0) { - anyhow::bail!("jobs must be at least 1") - } if jobs.is_some() && config.jobserver_from_env().is_some() { config.shell().warn( "a `-j` argument was passed to Cargo but Cargo is \ @@ -73,10 +77,12 @@ its environment, ignoring the `-j` parameter", )?; } - let jobs = jobs.or(cfg.jobs).unwrap_or(::num_cpus::get() as u32); - if jobs == 0 { - anyhow::bail!("jobs may not be 0"); - } + let jobs = match jobs.or(cfg.jobs) { + None => default_parallelism()?, + Some(0) => anyhow::bail!("jobs may not be 0"), + Some(j) if j < 0 => (default_parallelism()? as i32 + j).max(1) as u32, + Some(j) => j as u32, + }; if config.cli_unstable().build_std.is_some() && requested_kinds[0].is_host() { // TODO: This should eventually be fixed. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/build_context/target_info.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/build_context/target_info.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/build_context/target_info.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/build_context/target_info.rs 2022-10-20 06:00:42.000000000 +0000 @@ -597,7 +597,7 @@ /// provided) for artifacts that are always built for the host (plugins, build scripts, ...). /// For those artifacts, _only_ `host.*.rustflags` is respected, and no other configuration /// sources, _regardless of the value of `target-applies-to-host`_. This is counterintuitive, but -/// necessary to retain bacwkards compatibility with older versions of Cargo. +/// necessary to retain backwards compatibility with older versions of Cargo. fn env_args( config: &Config, requested_kinds: &[CompileKind], diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/compilation.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/compilation.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/compilation.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/compilation.rs 2022-10-20 06:00:42.000000000 +0000 @@ -409,7 +409,7 @@ let matching_runner = cfgs.next(); if let Some((key, runner)) = cfgs.next() { anyhow::bail!( - "several matching instances of `target.'cfg(..)'.runner` in `.cargo/config`\n\ + "several matching instances of `target.'cfg(..)'.runner` in configurations\n\ first match `{}` located in {}\n\ second match `{}` located in {}", matching_runner.unwrap().0, diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/compile_kind.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/compile_kind.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/compile_kind.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/compile_kind.rs 2022-10-20 06:00:42.000000000 +0000 @@ -2,7 +2,7 @@ use crate::util::errors::CargoResult; use crate::util::interning::InternedString; use crate::util::{Config, StableHasher}; -use anyhow::{bail, Context as _}; +use anyhow::Context as _; use serde::Serialize; use std::collections::BTreeSet; use std::fs; @@ -65,9 +65,6 @@ }; if !targets.is_empty() { - if targets.len() > 1 && !config.cli_unstable().multitarget { - bail!("specifying multiple `--target` flags requires `-Zmultitarget`") - } return dedup(targets); } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/context/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/context/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/context/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/context/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -92,7 +92,7 @@ let jobserver = match bcx.config.jobserver_from_env() { Some(c) => c.clone(), None => { - let client = Client::new(bcx.build_config.jobs as usize) + let client = Client::new(bcx.jobs() as usize) .with_context(|| "failed to create jobserver")?; client.acquire_raw()?; client @@ -603,7 +603,7 @@ } pub fn new_jobserver(&mut self) -> CargoResult { - let tokens = self.bcx.build_config.jobs as usize; + let tokens = self.bcx.jobs() as usize; let client = Client::new(tokens).with_context(|| "failed to create jobserver")?; // Drain the client fully diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/future_incompat.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/future_incompat.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/future_incompat.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/future_incompat.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,7 +1,7 @@ //! Support for future-incompatible warning reporting. use crate::core::compiler::BuildContext; -use crate::core::{Dependency, PackageId, Workspace}; +use crate::core::{Dependency, PackageId, QueryKind, Workspace}; use crate::sources::SourceConfigMap; use crate::util::{iter_join, CargoResult, Config}; use anyhow::{bail, format_err, Context}; @@ -293,7 +293,7 @@ Ok(dep) => dep, Err(_) => return false, }; - match source.query_vec(&dep) { + match source.query_vec(&dep, QueryKind::Exact) { Poll::Ready(Ok(sum)) => { summaries.push((pkg_id, sum)); false diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/job_queue.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/job_queue.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/job_queue.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/job_queue.rs 2022-10-20 06:00:42.000000000 +0000 @@ -55,11 +55,11 @@ use std::io; use std::marker; use std::sync::Arc; +use std::thread::{self, Scope}; use std::time::Duration; use anyhow::{format_err, Context as _}; use cargo_util::ProcessBuilder; -use crossbeam_utils::thread::Scope; use jobserver::{Acquired, Client, HelperThread}; use log::{debug, trace}; use semver::Version; @@ -162,7 +162,7 @@ /// The list of jobs that we have not yet started executing, but have /// retrieved from the `queue`. We eagerly pull jobs off the main queue to /// allow us to request jobserver tokens pretty early. - pending_queue: Vec<(Unit, Job)>, + pending_queue: Vec<(Unit, Job, usize)>, print: DiagnosticPrinter<'cfg>, /// How many jobs we've finished @@ -556,29 +556,36 @@ .take() .map(move |srv| srv.start(move |msg| messages.push(Message::FixDiagnostic(msg)))); - crossbeam_utils::thread::scope(move |scope| { - match state.drain_the_queue(cx, plan, scope, &helper) { + thread::scope( + move |scope| match state.drain_the_queue(cx, plan, scope, &helper) { Some(err) => Err(err), None => Ok(()), - } - }) - .expect("child threads shouldn't panic") + }, + ) } } impl<'cfg> DrainState<'cfg> { - fn spawn_work_if_possible( + fn spawn_work_if_possible<'s>( &mut self, cx: &mut Context<'_, '_>, jobserver_helper: &HelperThread, - scope: &Scope<'_>, + scope: &'s Scope<'s, '_>, ) -> CargoResult<()> { // Dequeue as much work as we can, learning about everything // possible that can run. Note that this is also the point where we // start requesting job tokens. Each job after the first needs to // request a token. - while let Some((unit, job)) = self.queue.dequeue() { - self.pending_queue.push((unit, job)); + while let Some((unit, job, priority)) = self.queue.dequeue() { + // We want to keep the pieces of work in the `pending_queue` sorted + // by their priorities, and insert the current job at its correctly + // sorted position: following the lower priority jobs, and the ones + // with the same priority (since they were dequeued before the + // current one, we also keep that relation). + let idx = self + .pending_queue + .partition_point(|&(_, _, p)| p <= priority); + self.pending_queue.insert(idx, (unit, job, priority)); if self.active.len() + self.pending_queue.len() > 1 { jobserver_helper.request_token(); } @@ -587,8 +594,11 @@ // Now that we've learned of all possible work that we can execute // try to spawn it so long as we've got a jobserver token which says // we're able to perform some parallel work. + // The `pending_queue` is sorted in ascending priority order, and we + // remove items from its end to schedule the highest priority items + // sooner. while self.has_extra_tokens() && !self.pending_queue.is_empty() { - let (unit, job) = self.pending_queue.remove(0); + let (unit, job, _) = self.pending_queue.pop().unwrap(); *self.counts.get_mut(&unit.pkg.package_id()).unwrap() -= 1; if !cx.bcx.build_config.build_plan { // Print out some nice progress information. @@ -807,11 +817,11 @@ /// /// This returns an Option to prevent the use of `?` on `Result` types /// because it is important for the loop to carefully handle errors. - fn drain_the_queue( + fn drain_the_queue<'s>( mut self, cx: &mut Context<'_, '_>, plan: &mut BuildPlan, - scope: &Scope<'_>, + scope: &'s Scope<'s, '_>, jobserver_helper: &HelperThread, ) -> Option { trace!("queue: {:#?}", self.queue); @@ -997,7 +1007,7 @@ /// /// Fresh jobs block until finished (which should be very fast!), Dirty /// jobs will spawn a thread in the background and return immediately. - fn run(&mut self, unit: &Unit, job: Job, cx: &Context<'_, '_>, scope: &Scope<'_>) { + fn run<'s>(&mut self, unit: &Unit, job: Job, cx: &Context<'_, '_>, scope: &'s Scope<'s, '_>) { let id = JobId(self.next_id); self.next_id = self.next_id.checked_add(1).unwrap(); @@ -1072,7 +1082,7 @@ } Freshness::Dirty => { self.timings.add_dirty(); - scope.spawn(move |_| { + scope.spawn(move || { doit(JobState { id, messages: messages.clone(), diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -793,11 +793,11 @@ ) { // Terminal width explicitly provided - only useful for testing. (Some(Some(width)), _) => { - cmd.arg(format!("-Zterminal-width={}", width)); + cmd.arg(format!("--diagnostic-width={}", width)); } // Terminal width was not explicitly provided but flag was provided - common case. (Some(None), Some(width)) => { - cmd.arg(format!("-Zterminal-width={}", width)); + cmd.arg(format!("--diagnostic-width={}", width)); } // User didn't opt-in. _ => (), diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/timings.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/timings.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/compiler/timings.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/compiler/timings.rs 2022-10-20 06:00:42.000000000 +0000 @@ -13,6 +13,7 @@ use cargo_util::paths; use std::collections::HashMap; use std::io::{BufWriter, Write}; +use std::thread::available_parallelism; use std::time::{Duration, Instant, SystemTime}; pub struct Timings<'cfg> { @@ -380,6 +381,9 @@ }; let total_time = format!("{:.1}s{}", duration, time_human); let max_concurrency = self.concurrency.iter().map(|c| c.active).max().unwrap(); + let num_cpus = available_parallelism() + .map(|x| x.get().to_string()) + .unwrap_or_else(|_| "n/a".into()); let max_rustc_concurrency = self .concurrency .iter() @@ -441,8 +445,8 @@ self.total_dirty, self.total_fresh + self.total_dirty, max_concurrency, - bcx.build_config.jobs, - num_cpus::get(), + bcx.jobs(), + num_cpus, self.start_str, total_time, rustc_info, diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/features.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/features.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/features.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/features.rs 2022-10-20 06:00:42.000000000 +0000 @@ -86,7 +86,9 @@ //! `CliUnstable. Remove the `(unstable)` note in the clap help text if //! necessary. //! 2. Remove `masquerade_as_nightly_cargo` from any tests, and remove -//! `cargo-features` from `Cargo.toml` test files if any. +//! `cargo-features` from `Cargo.toml` test files if any. You can +//! quickly find what needs to be removed by searching for the name +//! of the feature, e.g. `print_im_a_teapot` //! 3. Update the docs in unstable.md to move the section to the bottom //! and summarize it similar to the other entries. Update the rest of the //! documentation to add the new feature. @@ -100,6 +102,7 @@ use cargo_util::ProcessBuilder; use serde::{Deserialize, Serialize}; +use crate::core::resolver::ResolveBehavior; use crate::util::errors::CargoResult; use crate::util::{indented_lines, iter_join}; use crate::Config; @@ -240,6 +243,14 @@ Edition2021 => false, } } + + pub(crate) fn default_resolve_behavior(&self) -> ResolveBehavior { + if *self >= Edition::Edition2021 { + ResolveBehavior::V2 + } else { + ResolveBehavior::V1 + } + } } impl fmt::Display for Edition { @@ -414,7 +425,7 @@ (unstable, profile_rustflags, "", "reference/unstable.html#profile-rustflags-option"), // Allow specifying rustflags directly in a profile - (unstable, workspace_inheritance, "", "reference/unstable.html#workspace-inheritance"), + (stable, workspace_inheritance, "1.64", "reference/unstable.html#workspace-inheritance"), } pub struct Feature { @@ -641,6 +652,7 @@ build_std_features: Option> = ("Configure features enabled for the standard library itself when building the standard library"), config_include: bool = ("Enable the `include` key in config files"), credential_process: bool = ("Add a config setting to fetch registry authentication tokens by calling an external process"), + #[serde(deserialize_with = "deserialize_check_cfg")] check_cfg: Option<(/*features:*/ bool, /*well_known_names:*/ bool, /*well_known_values:*/ bool, /*output:*/ bool)> = ("Specify scope of compile-time checking of `cfg` names/values"), 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"), @@ -719,6 +731,8 @@ const STABILIZED_TIMINGS: &str = "The -Ztimings option has been stabilized as --timings."; +const STABILISED_MULTITARGET: &str = "Multiple `--target` options are now always available."; + fn deserialize_build_std<'de, D>(deserializer: D) -> Result>, D::Error> where D: serde::Deserializer<'de>, @@ -733,6 +747,47 @@ )) } +fn deserialize_check_cfg<'de, D>( + deserializer: D, +) -> Result, D::Error> +where + D: serde::Deserializer<'de>, +{ + use serde::de::Error; + let crates = match >>::deserialize(deserializer)? { + Some(list) => list, + None => return Ok(None), + }; + + parse_check_cfg(crates.into_iter()).map_err(D::Error::custom) +} + +fn parse_check_cfg( + it: impl Iterator>, +) -> CargoResult> { + let mut features = false; + let mut well_known_names = false; + let mut well_known_values = false; + let mut output = false; + + for e in it { + match e.as_ref() { + "features" => features = true, + "names" => well_known_names = true, + "values" => well_known_values = true, + "output" => output = true, + _ => bail!("unstable check-cfg only takes `features`, `names`, `values` or `output` as valid inputs"), + } + } + + Ok(Some(( + features, + well_known_names, + well_known_values, + output, + ))) +} + impl CliUnstable { pub fn parse( &mut self, @@ -783,34 +838,6 @@ } } - fn parse_check_cfg(value: Option<&str>) -> CargoResult> { - if let Some(value) = value { - let mut features = false; - let mut well_known_names = false; - let mut well_known_values = false; - let mut output = false; - - for e in value.split(',') { - match e { - "features" => features = true, - "names" => well_known_names = true, - "values" => well_known_values = true, - "output" => output = true, - _ => bail!("flag -Zcheck-cfg only takes `features`, `names`, `values` or `output` as valid inputs"), - } - } - - Ok(Some(( - features, - well_known_names, - well_known_values, - output, - ))) - } else { - Ok(None) - } - } - // Asserts that there is no argument to the flag. fn parse_empty(key: &str, value: Option<&str>) -> CargoResult { if let Some(v) = value { @@ -868,7 +895,9 @@ "minimal-versions" => self.minimal_versions = parse_empty(k, v)?, "advanced-env" => self.advanced_env = parse_empty(k, v)?, "config-include" => self.config_include = parse_empty(k, v)?, - "check-cfg" => self.check_cfg = parse_check_cfg(v)?, + "check-cfg" => { + self.check_cfg = v.map_or(Ok(None), |v| parse_check_cfg(v.split(',')))? + } "dual-proc-macros" => self.dual_proc_macros = parse_empty(k, v)?, // can also be set in .cargo/config or with and ENV "mtime-on-use" => self.mtime_on_use = parse_empty(k, v)?, @@ -904,7 +933,7 @@ self.features = Some(feats); } "separate-nightlies" => self.separate_nightlies = parse_empty(k, v)?, - "multitarget" => self.multitarget = parse_empty(k, v)?, + "multitarget" => stabilized_warn(k, "1.64", STABILISED_MULTITARGET), "rustdoc-map" => self.rustdoc_map = parse_empty(k, v)?, "terminal-width" => self.terminal_width = Some(parse_usize_opt(v)?), "sparse-registry" => self.sparse_registry = parse_empty(k, v)?, diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -8,7 +8,7 @@ pub use self::registry::Registry; pub use self::resolver::{Resolve, ResolveVersion}; pub use self::shell::{Shell, Verbosity}; -pub use self::source::{GitReference, Source, SourceId, SourceMap}; +pub use self::source::{GitReference, QueryKind, Source, SourceId, SourceMap}; pub use self::summary::{FeatureMap, FeatureValue, Summary}; pub use self::workspace::{ find_workspace_root, resolve_relative_path, MaybePackage, Workspace, WorkspaceConfig, diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/registry.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/registry.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/registry.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/registry.rs 2022-10-20 06:00:42.000000000 +0000 @@ -2,7 +2,7 @@ use std::task::Poll; use crate::core::PackageSet; -use crate::core::{Dependency, PackageId, Source, SourceId, SourceMap, Summary}; +use crate::core::{Dependency, PackageId, QueryKind, Source, SourceId, SourceMap, Summary}; use crate::sources::config::SourceConfigMap; use crate::util::errors::CargoResult; use crate::util::interning::InternedString; @@ -19,14 +19,13 @@ fn query( &mut self, dep: &Dependency, + kind: QueryKind, f: &mut dyn FnMut(Summary), - fuzzy: bool, ) -> Poll>; - fn query_vec(&mut self, dep: &Dependency, fuzzy: bool) -> Poll>> { + fn query_vec(&mut self, dep: &Dependency, kind: QueryKind) -> Poll>> { let mut ret = Vec::new(); - self.query(dep, &mut |s| ret.push(s), fuzzy) - .map_ok(|()| ret) + self.query(dep, kind, &mut |s| ret.push(s)).map_ok(|()| ret) } fn describe_source(&self, source: SourceId) -> String; @@ -327,7 +326,7 @@ .get_mut(dep.source_id()) .expect("loaded source not present"); - let summaries = match source.query_vec(dep)? { + let summaries = match source.query_vec(dep, QueryKind::Exact)? { Poll::Ready(deps) => deps, Poll::Pending => { deps_pending.push(dep_remaining); @@ -483,7 +482,7 @@ for &s in self.overrides.iter() { let src = self.sources.get_mut(s).unwrap(); let dep = Dependency::new_override(dep.package_name(), s); - let mut results = match src.query_vec(&dep) { + let mut results = match src.query_vec(&dep, QueryKind::Exact) { Poll::Ready(results) => results?, Poll::Pending => return Poll::Pending, }; @@ -575,8 +574,8 @@ fn query( &mut self, dep: &Dependency, + kind: QueryKind, f: &mut dyn FnMut(Summary), - fuzzy: bool, ) -> Poll> { assert!(self.patches_locked); let (override_summary, n, to_warn) = { @@ -671,11 +670,7 @@ } f(lock(locked, all_patches, summary)) }; - return if fuzzy { - source.fuzzy_query(dep, callback) - } else { - source.query(dep, callback) - }; + return source.query(dep, kind, callback); } // If we have an override summary then we query the source @@ -694,11 +689,7 @@ n += 1; to_warn = Some(summary); }; - let pend = if fuzzy { - source.fuzzy_query(dep, callback)? - } else { - source.query(dep, callback)? - }; + let pend = source.query(dep, kind, callback); if pend.is_pending() { return Poll::Pending; } @@ -889,7 +880,7 @@ // No summaries found, try to help the user figure out what is wrong. if let Some(locked) = locked { // Since the locked patch did not match anything, try the unlocked one. - let orig_matches = match source.query_vec(orig_patch) { + let orig_matches = match source.query_vec(orig_patch, QueryKind::Exact) { Poll::Pending => return Poll::Pending, Poll::Ready(deps) => deps, } @@ -914,7 +905,7 @@ // Try checking if there are *any* packages that match this by name. let name_only_dep = Dependency::new_override(orig_patch.package_name(), orig_patch.source_id()); - let name_summaries = match source.query_vec(&name_only_dep) { + let name_summaries = match source.query_vec(&name_only_dep, QueryKind::Exact) { Poll::Pending => return Poll::Pending, Poll::Ready(deps) => deps, } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/resolver/dep_cache.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/resolver/dep_cache.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/resolver/dep_cache.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/resolver/dep_cache.rs 2022-10-20 06:00:42.000000000 +0000 @@ -16,7 +16,9 @@ ActivateError, ActivateResult, CliFeatures, RequestedFeatures, ResolveOpts, VersionOrdering, VersionPreferences, }; -use crate::core::{Dependency, FeatureValue, PackageId, PackageIdSpec, Registry, Summary}; +use crate::core::{ + Dependency, FeatureValue, PackageId, PackageIdSpec, QueryKind, Registry, Summary, +}; use crate::util::errors::CargoResult; use crate::util::interning::InternedString; @@ -100,13 +102,9 @@ } let mut ret = Vec::new(); - let ready = self.registry.query( - dep, - &mut |s| { - ret.push(s); - }, - false, - )?; + let ready = self.registry.query(dep, QueryKind::Exact, &mut |s| { + ret.push(s); + })?; if ready.is_pending() { self.registry_cache.insert(dep.clone(), Poll::Pending); return Poll::Pending; @@ -127,7 +125,7 @@ dep.version_req() ); - let mut summaries = match self.registry.query_vec(dep, false)? { + let mut summaries = match self.registry.query_vec(dep, QueryKind::Exact)? { Poll::Ready(s) => s.into_iter(), Poll::Pending => { self.registry_cache.insert(dep.clone(), Poll::Pending); diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/resolver/errors.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/resolver/errors.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/resolver/errors.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/resolver/errors.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,7 +1,7 @@ use std::fmt; use std::task::Poll; -use crate::core::{Dependency, PackageId, Registry, Summary}; +use crate::core::{Dependency, PackageId, QueryKind, Registry, Summary}; use crate::util::lev_distance::lev_distance; use crate::util::{Config, VersionExt}; use anyhow::Error; @@ -228,7 +228,7 @@ new_dep.set_version_req(all_req); let mut candidates = loop { - match registry.query_vec(&new_dep, false) { + match registry.query_vec(&new_dep, QueryKind::Exact) { Poll::Ready(Ok(candidates)) => break candidates, Poll::Ready(Err(e)) => return to_resolve_err(e), Poll::Pending => match registry.block_until_ready() { @@ -294,7 +294,7 @@ // Maybe the user mistyped the name? Like `dep-thing` when `Dep_Thing` // was meant. So we try asking the registry for a `fuzzy` search for suggestions. let mut candidates = loop { - match registry.query_vec(&new_dep, true) { + match registry.query_vec(&new_dep, QueryKind::Fuzzy) { Poll::Ready(Ok(candidates)) => break candidates, Poll::Ready(Err(e)) => return to_resolve_err(e), Poll::Pending => match registry.block_until_ready() { diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/resolver/types.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/resolver/types.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/resolver/types.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/resolver/types.rs 2022-10-20 06:00:42.000000000 +0000 @@ -119,11 +119,12 @@ } } - pub fn to_manifest(&self) -> Option { + pub fn to_manifest(&self) -> String { match self { - ResolveBehavior::V1 => None, - ResolveBehavior::V2 => Some("2".to_string()), + ResolveBehavior::V1 => "1", + ResolveBehavior::V2 => "2", } + .to_owned() } } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/source/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/source/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/source/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/source/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -29,21 +29,16 @@ fn requires_precise(&self) -> bool; /// Attempts to find the packages that match a dependency request. - fn query(&mut self, dep: &Dependency, f: &mut dyn FnMut(Summary)) -> Poll>; - - /// Attempts to find the packages that are close to a dependency request. - /// Each source gets to define what `close` means for it. - /// Path/Git sources may return all dependencies that are at that URI, - /// whereas an `Index` source may return dependencies that have the same canonicalization. - fn fuzzy_query( + fn query( &mut self, dep: &Dependency, + kind: QueryKind, f: &mut dyn FnMut(Summary), ) -> Poll>; - fn query_vec(&mut self, dep: &Dependency) -> Poll>> { + fn query_vec(&mut self, dep: &Dependency, kind: QueryKind) -> Poll>> { let mut ret = Vec::new(); - self.query(dep, &mut |s| ret.push(s)).map_ok(|_| ret) + self.query(dep, kind, &mut |s| ret.push(s)).map_ok(|_| ret) } /// Ensure that the source is fully up-to-date for the current session on the next query. @@ -103,7 +98,7 @@ /// Query if a package is yanked. Only registry sources can mark packages /// as yanked. This ignores the yanked whitelist. - fn is_yanked(&mut self, _pkg: PackageId) -> CargoResult; + fn is_yanked(&mut self, _pkg: PackageId) -> Poll>; /// Block until all outstanding Poll::Pending requests are `Poll::Ready`. /// @@ -115,6 +110,15 @@ fn block_until_ready(&mut self) -> CargoResult<()>; } +#[derive(Copy, Clone, PartialEq, Eq)] +pub enum QueryKind { + Exact, + /// Each source gets to define what `close` means for it. + /// Path/Git sources may return all dependencies that are at that URI, + /// whereas an `Index` source may return dependencies that have the same canonicalization. + Fuzzy, +} + pub enum MaybePackage { Ready(Package), Download { url: String, descriptor: String }, @@ -142,17 +146,13 @@ } /// Forwards to `Source::query`. - fn query(&mut self, dep: &Dependency, f: &mut dyn FnMut(Summary)) -> Poll> { - (**self).query(dep, f) - } - - /// Forwards to `Source::query`. - fn fuzzy_query( + fn query( &mut self, dep: &Dependency, + kind: QueryKind, f: &mut dyn FnMut(Summary), ) -> Poll> { - (**self).fuzzy_query(dep, f) + (**self).query(dep, kind, f) } fn invalidate_cache(&mut self) { @@ -190,7 +190,7 @@ (**self).add_to_yanked_whitelist(pkgs); } - fn is_yanked(&mut self, pkg: PackageId) -> CargoResult { + fn is_yanked(&mut self, pkg: PackageId) -> Poll> { (**self).is_yanked(pkg) } @@ -216,16 +216,13 @@ (**self).requires_precise() } - fn query(&mut self, dep: &Dependency, f: &mut dyn FnMut(Summary)) -> Poll> { - (**self).query(dep, f) - } - - fn fuzzy_query( + fn query( &mut self, dep: &Dependency, + kind: QueryKind, f: &mut dyn FnMut(Summary), ) -> Poll> { - (**self).fuzzy_query(dep, f) + (**self).query(dep, kind, f) } fn invalidate_cache(&mut self) { @@ -260,7 +257,7 @@ (**self).add_to_yanked_whitelist(pkgs); } - fn is_yanked(&mut self, pkg: PackageId) -> CargoResult { + fn is_yanked(&mut self, pkg: PackageId) -> Poll> { (**self).is_yanked(pkg) } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/core/workspace.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/workspace.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/core/workspace.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/core/workspace.rs 2022-10-20 06:00:42.000000000 +0000 @@ -16,7 +16,7 @@ use crate::core::registry::PackageRegistry; use crate::core::resolver::features::CliFeatures; use crate::core::resolver::ResolveBehavior; -use crate::core::{Dependency, Edition, FeatureValue, PackageId, PackageIdSpec}; +use crate::core::{Dependency, FeatureValue, PackageId, PackageIdSpec}; use crate::core::{EitherManifest, Package, SourceId, VirtualManifest}; use crate::ops; use crate::sources::{PathSource, CRATES_IO_INDEX, CRATES_IO_REGISTRY}; @@ -133,6 +133,34 @@ WorkspaceConfig::Member { .. } => None, } } + + /// Returns the path of the workspace root based on this `[workspace]` configuration. + /// + /// Returns `None` if the root is not explicitly known. + /// + /// * `self_path` is the path of the manifest this `WorkspaceConfig` is located. + /// * `look_from` is the path where discovery started (usually the current + /// working directory), used for `workspace.exclude` checking. + fn get_ws_root(&self, self_path: &Path, look_from: &Path) -> Option { + match self { + WorkspaceConfig::Root(ances_root_config) => { + debug!("find_root - found a root checking exclusion"); + if !ances_root_config.is_excluded(look_from) { + debug!("find_root - found!"); + Some(self_path.to_owned()) + } else { + None + } + } + WorkspaceConfig::Member { + root: Some(path_to_root), + } => { + debug!("find_root - found pointer"); + Some(read_root_pointer(self_path, path_to_root)) + } + WorkspaceConfig::Member { .. } => None, + } + } } /// Intermediate configuration of a workspace root in a manifest. @@ -259,16 +287,12 @@ // - If the root package specifies edition 2021, use v2. // - Otherwise, use the default v1. self.resolve_behavior = match self.root_maybe() { - MaybePackage::Package(p) => p.manifest().resolve_behavior().or_else(|| { - if p.manifest().edition() >= Edition::Edition2021 { - Some(ResolveBehavior::V2) - } else { - None - } - }), - MaybePackage::Virtual(vm) => vm.resolve_behavior(), + MaybePackage::Package(p) => p + .manifest() + .resolve_behavior() + .unwrap_or_else(|| p.manifest().edition().default_resolve_behavior()), + MaybePackage::Virtual(vm) => vm.resolve_behavior().unwrap_or(ResolveBehavior::V1), } - .unwrap_or(ResolveBehavior::V1); } /// Returns the current package of this workspace. @@ -592,40 +616,23 @@ /// Returns an error if `manifest_path` isn't actually a valid manifest or /// if some other transient error happens. fn find_root(&mut self, manifest_path: &Path) -> CargoResult> { + let current = self.packages.load(manifest_path)?; + match current + .workspace_config() + .get_ws_root(manifest_path, manifest_path) { - let current = self.packages.load(manifest_path)?; - match *current.workspace_config() { - WorkspaceConfig::Root(_) => { - debug!("find_root - is root {}", manifest_path.display()); - return Ok(Some(manifest_path.to_path_buf())); - } - WorkspaceConfig::Member { - root: Some(ref path_to_root), - } => return Ok(Some(read_root_pointer(manifest_path, path_to_root))), - WorkspaceConfig::Member { root: None } => {} - } - } - - for ances_manifest_path in find_root_iter(manifest_path, self.config) { - debug!("find_root - trying {}", ances_manifest_path.display()); - match *self.packages.load(&ances_manifest_path)?.workspace_config() { - WorkspaceConfig::Root(ref ances_root_config) => { - debug!("find_root - found a root checking exclusion"); - if !ances_root_config.is_excluded(manifest_path) { - debug!("find_root - found!"); - return Ok(Some(ances_manifest_path)); - } - } - WorkspaceConfig::Member { - root: Some(ref path_to_root), - } => { - debug!("find_root - found pointer"); - return Ok(Some(read_root_pointer(&ances_manifest_path, path_to_root))); - } - WorkspaceConfig::Member { .. } => {} - } + Some(root_path) => { + debug!("find_root - is root {}", manifest_path.display()); + Ok(Some(root_path)) + } + None => find_workspace_root_with_loader(manifest_path, self.config, |self_path| { + Ok(self + .packages + .load(self_path)? + .workspace_config() + .get_ws_root(self_path, manifest_path)) + }), } - Ok(None) } /// After the root of a workspace has been located, probes for all members @@ -675,6 +682,8 @@ })?; } + self.find_path_deps(&root_manifest_path, &root_manifest_path, false)?; + if let Some(default) = default_members_paths { for path in default { let normalized_path = paths::normalize_path(&path); @@ -705,7 +714,7 @@ self.default_members.push(self.current_manifest.clone()) } - self.find_path_deps(&root_manifest_path, &root_manifest_path, false) + Ok(()) } fn find_path_deps( @@ -1669,31 +1678,46 @@ } } -fn parse_manifest(manifest_path: &Path, config: &Config) -> CargoResult { - let key = manifest_path.parent().unwrap(); - let source_id = SourceId::for_path(key)?; - let (manifest, _nested_paths) = read_manifest(manifest_path, source_id, config)?; - Ok(manifest) +/// Finds the path of the root of the workspace. +pub fn find_workspace_root(manifest_path: &Path, config: &Config) -> CargoResult> { + find_workspace_root_with_loader(manifest_path, config, |self_path| { + let key = self_path.parent().unwrap(); + let source_id = SourceId::for_path(key)?; + let (manifest, _nested_paths) = read_manifest(self_path, source_id, config)?; + Ok(manifest + .workspace_config() + .get_ws_root(self_path, manifest_path)) + }) } -pub fn find_workspace_root(manifest_path: &Path, config: &Config) -> CargoResult> { - for ances_manifest_path in find_root_iter(manifest_path, config) { - debug!("find_root - trying {}", ances_manifest_path.display()); - match *parse_manifest(&ances_manifest_path, config)?.workspace_config() { - WorkspaceConfig::Root(ref ances_root_config) => { - debug!("find_root - found a root checking exclusion"); - if !ances_root_config.is_excluded(manifest_path) { - debug!("find_root - found!"); - return Ok(Some(ances_manifest_path)); +/// Finds the path of the root of the workspace. +/// +/// This uses a callback to determine if the given path tells us what the +/// workspace root is. +fn find_workspace_root_with_loader( + manifest_path: &Path, + config: &Config, + mut loader: impl FnMut(&Path) -> CargoResult>, +) -> CargoResult> { + // Check if there are any workspace roots that have already been found that would work + { + let roots = config.ws_roots.borrow(); + // Iterate through the manifests parent directories until we find a workspace + // root. Note we skip the first item since that is just the path itself + for current in manifest_path.ancestors().skip(1) { + if let Some(ws_config) = roots.get(current) { + if !ws_config.is_excluded(manifest_path) { + // Add `Cargo.toml` since ws_root is the root and not the file + return Ok(Some(current.join("Cargo.toml"))); } } - WorkspaceConfig::Member { - root: Some(ref path_to_root), - } => { - debug!("find_root - found pointer"); - return Ok(Some(read_root_pointer(&ances_manifest_path, path_to_root))); - } - WorkspaceConfig::Member { .. } => {} + } + } + + for ances_manifest_path in find_root_iter(manifest_path, config) { + debug!("find_root - trying {}", ances_manifest_path.display()); + if let Some(ws_root_path) = loader(&ances_manifest_path)? { + return Ok(Some(ws_root_path)); } } Ok(None) diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/lib.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/lib.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/lib.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/lib.rs 2022-10-20 06:00:42.000000000 +0000 @@ -5,6 +5,75 @@ // Due to some of the default clippy lints being somewhat subjective and not // necessarily an improvement, we prefer to not use them at this time. #![allow(clippy::all)] +#![allow(rustdoc::private_intra_doc_links)] + +//! # Cargo as a library +//! +//! Cargo, the Rust package manager, is also provided as a library. +//! +//! There are two places you can find API documentation of cargo-the-library, +//! +//! - and +//! - . +//! +//! Each of them targets on a slightly different audience. +//! +//! ## For external tool developers +//! +//! The documentation on contains public-facing items in cargo-the-library. +//! External tool developers may find it useful when trying to reuse existing building blocks from Cargo. +//! However, using Cargo as a library has drawbacks, especially cargo-the-library is unstable, +//! and there is no clear path to stabilize it soon at the time of writing. +//! See [The Cargo Book: External tools] for more on this topic. +//! +//! Cargo API documentation on docs.rs gets updates along with each Rust release. +//! Its version always has a 0 major version to state it is unstable. +//! The minor version is always +1 of rustc's minor version +//! (that is, `cargo 0.66.0` corresponds to `rustc 1.65`). +//! +//! ## For Cargo contributors +//! +//! The documentation on contains all items in Cargo. +//! Contributors of Cargo may find it useful as a reference of Cargo's implementation details. +//! It's built with `--document-private-items` rustdoc flag, +//! so you might expect to see some noise and strange items here. +//! The Cargo team and contributors strive for jotting down every details +//! from their brains in each issue and PR. +//! However, something might just disappear in the air with no reason. +//! This documentation can be seen as their extended minds, +//! sharing designs and hacks behind both public and private interfaces. +//! +//! If you are just diving into Cargo internals, [Cargo Architecture Overview] +//! is the best material to get a broader context of how Cargo works under the hood. +//! Things also worth a read are important concepts reside in source code, +//! which Cargo developers have been crafting for a while, namely +//! +//! - [`cargo::core::resolver`](crate::core::resolver), +//! - [`cargo::core::compiler::fingerprint`](core/compiler/fingerprint/index.html), +//! - [`cargo::util::config`](crate::util::config), +//! - [`cargo::ops::fix`](ops/fix/index.html), and +//! - [`cargo::sources::registry`](crate::sources::registry). +//! +//! This API documentation is published on each push of rust-lang/cargo master branch. +//! In other words, it always reflects the latest doc comments in source code on master branch. +//! +//! ## Contribute to Cargo documentations +//! +//! The Cargo team always continues improving all external and internal documentations. +//! If you spot anything could be better, don't hesitate to discuss with the team on +//! Zulip [`t-cargo` stream], or [submit an issue] right on GitHub. +//! There is also an issue label [`A-documenting-cargo-itself`], +//! which is generally for documenting user-facing [The Cargo Book], +//! but the Cargo team is welcome any form of enhancement for the [Cargo Contributor Guide] +//! and this API documentation as well. +//! +//! [The Cargo Book: External tools]: https://doc.rust-lang.org/stable/cargo/reference/external-tools.html +//! [Cargo Architecture Overview]: https://doc.crates.io/contrib/architecture +//! [`t-cargo` stream]: https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo +//! [submit an issue]: https://github.com/rust-lang/cargo/issues/new/choose +//! [`A-documenting-cargo-itself`]: https://github.com/rust-lang/cargo/labels/A-documenting-cargo-itself +//! [The Cargo Book]: https://doc.rust-lang.org/cargo/ +//! [Cargo Contributor Guide]: https://doc.crates.io/contrib/ use crate::core::shell::Verbosity::Verbose; use crate::core::Shell; diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_add/dependency.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_add/dependency.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_add/dependency.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_add/dependency.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,4 +1,3 @@ -use std::collections::BTreeMap; use std::fmt::{Display, Formatter}; use std::path::{Path, PathBuf}; @@ -6,8 +5,6 @@ use toml_edit::KeyMut; use super::manifest::str_or_1_len_table; -use crate::core::FeatureMap; -use crate::core::FeatureValue; use crate::core::GitReference; use crate::core::SourceId; use crate::core::Summary; @@ -40,9 +37,6 @@ /// If the dependency is renamed, this is the new name for the dependency /// as a string. None if it is not renamed. pub rename: Option, - - /// Features that are exposed by the dependency - pub available_features: BTreeMap>, } impl Dependency { @@ -57,7 +51,6 @@ source: None, registry: None, rename: None, - available_features: Default::default(), } } @@ -85,37 +78,6 @@ self } - /// Set the available features of the dependency to a given vec - pub fn set_available_features( - mut self, - available_features: BTreeMap>, - ) -> Self { - self.available_features = available_features; - self - } - - /// Populate from cargo - pub fn set_available_features_from_cargo( - mut self, - available_features: &FeatureMap, - ) -> Dependency { - self.available_features = available_features - .iter() - .map(|(k, v)| { - ( - k.as_str().to_owned(), - v.iter() - .filter_map(|v| match v { - FeatureValue::Feature(f) => Some(f.as_str().to_owned()), - FeatureValue::Dep { .. } | FeatureValue::DepFeature { .. } => None, - }) - .collect::>(), - ) - }) - .collect(); - self - } - /// Set whether the dependency is optional #[allow(dead_code)] pub fn set_optional(mut self, opt: bool) -> Self { @@ -347,8 +309,6 @@ None }; - let available_features = BTreeMap::default(); - let optional = table.get("optional").and_then(|v| v.as_bool()); let dep = Self { @@ -358,7 +318,6 @@ registry, default_features, features, - available_features, optional, inherited_features: None, }; @@ -646,9 +605,7 @@ } else { RegistrySource::new(other.version().to_string()).into() }; - Dependency::new(other.name().as_str()) - .set_source(source) - .set_available_features_from_cargo(other.features()) + Dependency::new(other.name().as_str()).set_source(source) } } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_add/manifest.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_add/manifest.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_add/manifest.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_add/manifest.rs 2022-10-20 06:00:42.000000000 +0000 @@ -238,8 +238,7 @@ impl std::fmt::Display for Manifest { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let s = self.data.to_string(); - s.fmt(f) + self.data.fmt(f) } } @@ -433,6 +432,12 @@ } } +impl std::fmt::Display for LocalManifest { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.manifest.fmt(f) + } +} + #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] enum DependencyStatus { None, diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_add/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_add/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_add/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_add/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -4,11 +4,12 @@ mod dependency; mod manifest; -use anyhow::Context; +use std::collections::BTreeMap; use std::collections::BTreeSet; use std::collections::VecDeque; use std::path::Path; +use anyhow::Context as _; use cargo_util::paths; use indexmap::IndexSet; use termcolor::Color::Green; @@ -18,9 +19,12 @@ use crate::core::dependency::DepKind; use crate::core::registry::PackageRegistry; +use crate::core::FeatureValue; use crate::core::Package; +use crate::core::QueryKind; use crate::core::Registry; use crate::core::Shell; +use crate::core::Summary; use crate::core::Workspace; use crate::CargoResult; use crate::Config; @@ -61,6 +65,7 @@ let manifest_path = options.spec.manifest_path().to_path_buf(); let mut manifest = LocalManifest::try_new(&manifest_path)?; + let original_raw_manifest = manifest.to_string(); let legacy = manifest.get_legacy_sections(); if !legacy.is_empty() { anyhow::bail!( @@ -141,6 +146,16 @@ } } + if options.config.locked() { + let new_raw_manifest = manifest.to_string(); + if original_raw_manifest != new_raw_manifest { + anyhow::bail!( + "the manifest file {} needs to be updated but --locked was passed to prevent this", + manifest.path.display() + ); + } + } + if options.dry_run { options.config.shell().warn("aborting add due to dry run")?; } else { @@ -188,7 +203,7 @@ section: &DepTable, config: &Config, registry: &mut PackageRegistry<'_>, -) -> CargoResult { +) -> CargoResult { let crate_spec = arg .crate_spec .as_deref() @@ -272,9 +287,7 @@ // Overwrite with `crate_spec` old_dep.source = selected_dep.source; } - old_dep = populate_dependency(old_dep, arg); - old_dep.available_features = selected_dep.available_features; - old_dep + populate_dependency(old_dep, arg) } } else { selected_dep @@ -306,9 +319,7 @@ ))?; dependency.name = latest.name; // Normalize the name } - dependency = dependency - .set_source(latest.source.expect("latest always has a source")) - .set_available_features(latest.available_features); + dependency = dependency.set_source(latest.source.expect("latest always has a source")); } } @@ -327,7 +338,25 @@ dependency = dependency.clear_version(); } - dependency = populate_available_features(dependency, config, registry, ws)?; + let query = dependency.query(config)?; + let query = match query { + MaybeWorkspace::Workspace(_workspace) => { + let dep = find_workspace_dep(dependency.toml_key(), ws.root_manifest())?; + if let Some(features) = dep.features.clone() { + dependency = dependency.set_inherited_features(features); + } + let query = dep.query(config)?; + match query { + MaybeWorkspace::Workspace(_) => { + unreachable!("This should have been caught when parsing a workspace root") + } + MaybeWorkspace::Other(query) => query, + } + } + MaybeWorkspace::Other(query) => query, + }; + + let dependency = populate_available_features(dependency, &query, registry)?; Ok(dependency) } @@ -443,8 +472,7 @@ } MaybeWorkspace::Other(query) => { let possibilities = loop { - let fuzzy = true; - match registry.query_vec(&query, fuzzy) { + match registry.query_vec(&query, QueryKind::Fuzzy) { std::task::Poll::Ready(res) => { break res?; } @@ -485,8 +513,8 @@ } MaybeWorkspace::Other(query) => { let possibilities = loop { - let fuzzy = false; // Returns all for path/git - match registry.query_vec(&query, fuzzy) { + // Exact to avoid returning all for path/git + match registry.query_vec(&query, QueryKind::Exact) { std::task::Poll::Ready(res) => { break res?; } @@ -571,36 +599,83 @@ dependency } +/// Track presentation-layer information with the editable representation of a `[dependencies]` +/// entry (Dependency) +pub struct DependencyUI { + /// Editable representation of a `[depednencies]` entry + dep: Dependency, + /// The version of the crate that we pulled `available_features` from + available_version: Option, + /// The widest set of features compatible with `Dependency`s version requirement + available_features: BTreeMap>, +} + +impl DependencyUI { + fn new(dep: Dependency) -> Self { + Self { + dep, + available_version: None, + available_features: Default::default(), + } + } + + fn apply_summary(&mut self, summary: &Summary) { + self.available_version = Some(summary.version().clone()); + self.available_features = summary + .features() + .iter() + .map(|(k, v)| { + ( + k.as_str().to_owned(), + v.iter() + .filter_map(|v| match v { + FeatureValue::Feature(f) => Some(f.as_str().to_owned()), + FeatureValue::Dep { .. } | FeatureValue::DepFeature { .. } => None, + }) + .collect::>(), + ) + }) + .collect(); + } +} + +impl<'s> From<&'s Summary> for DependencyUI { + fn from(other: &'s Summary) -> Self { + let dep = Dependency::from(other); + let mut dep = Self::new(dep); + dep.apply_summary(other); + dep + } +} + +impl std::fmt::Display for DependencyUI { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.dep.fmt(f) + } +} + +impl std::ops::Deref for DependencyUI { + type Target = Dependency; + + fn deref(&self) -> &Self::Target { + &self.dep + } +} + /// Lookup available features fn populate_available_features( - mut dependency: Dependency, - config: &Config, + dependency: Dependency, + query: &crate::core::dependency::Dependency, registry: &mut PackageRegistry<'_>, - ws: &Workspace<'_>, -) -> CargoResult { +) -> CargoResult { + let mut dependency = DependencyUI::new(dependency); + if !dependency.available_features.is_empty() { return Ok(dependency); } - let query = dependency.query(config)?; - let query = match query { - MaybeWorkspace::Workspace(_workspace) => { - let dep = find_workspace_dep(dependency.toml_key(), ws.root_manifest())?; - if let Some(features) = dep.features.clone() { - dependency = dependency.set_inherited_features(features); - } - let query = dep.query(config)?; - match query { - MaybeWorkspace::Workspace(_) => { - unreachable!("This should have been caught when parsing a workspace root") - } - MaybeWorkspace::Other(query) => query, - } - } - MaybeWorkspace::Other(query) => query, - }; let possibilities = loop { - match registry.query_vec(&query, true) { + match registry.query_vec(&query, QueryKind::Fuzzy) { std::task::Poll::Ready(res) => { break res?; } @@ -620,12 +695,12 @@ .ok_or_else(|| { anyhow::format_err!("the crate `{dependency}` could not be found in registry index.") })?; - dependency = dependency.set_available_features_from_cargo(lowest_common_denominator.features()); + dependency.apply_summary(&lowest_common_denominator); Ok(dependency) } -fn print_msg(shell: &mut Shell, dep: &Dependency, section: &[String]) -> CargoResult<()> { +fn print_msg(shell: &mut Shell, dep: &DependencyUI, section: &[String]) -> CargoResult<()> { use std::fmt::Write; if matches!(shell.verbosity(), crate::core::shell::Verbosity::Quiet) { @@ -698,7 +773,28 @@ deactivated.sort(); if !activated.is_empty() || !deactivated.is_empty() { let prefix = format!("{:>13}", " "); - shell.write_stderr(format_args!("{}Features:\n", prefix), &ColorSpec::new())?; + let suffix = if let Some(version) = &dep.available_version { + let mut version = version.clone(); + version.build = Default::default(); + let version = version.to_string(); + // Avoid displaying the version if it will visually look like the version req that we + // showed earlier + let version_req = dep + .version() + .and_then(|v| semver::VersionReq::parse(v).ok()) + .and_then(|v| precise_version(&v)); + if version_req.as_deref() != Some(version.as_str()) { + format!(" as of v{version}") + } else { + "".to_owned() + } + } else { + "".to_owned() + }; + shell.write_stderr( + format_args!("{}Features{}:\n", prefix, suffix), + &ColorSpec::new(), + )?; for feat in activated { shell.write_stderr(&prefix, &ColorSpec::new())?; shell.write_stderr('+', &ColorSpec::new().set_bold(true).set_fg(Some(Green)))?; @@ -754,3 +850,37 @@ ))?; Dependency::from_toml(root_manifest.parent().unwrap(), toml_key, dep_item) } + +/// Convert a `semver::VersionReq` into a rendered `semver::Version` if all fields are fully +/// specified. +fn precise_version(version_req: &semver::VersionReq) -> Option { + version_req + .comparators + .iter() + .filter(|c| { + matches!( + c.op, + // Only ops we can determine a precise version from + semver::Op::Exact + | semver::Op::GreaterEq + | semver::Op::LessEq + | semver::Op::Tilde + | semver::Op::Caret + | semver::Op::Wildcard + ) + }) + .filter_map(|c| { + // Only do it when full precision is specified + c.minor.and_then(|minor| { + c.patch.map(|patch| semver::Version { + major: c.major, + minor, + patch, + pre: c.pre.clone(), + build: Default::default(), + }) + }) + }) + .max() + .map(|v| v.to_string()) +} diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_compile.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_compile.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_compile.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_compile.rs 2022-10-20 06:00:42.000000000 +0000 @@ -23,6 +23,7 @@ //! repeats until the queue is empty. use std::collections::{BTreeSet, HashMap, HashSet}; +use std::fmt::Write; use std::hash::{Hash, Hasher}; use std::sync::Arc; @@ -661,12 +662,34 @@ continue; } + let guidance = if ws.is_ephemeral() { + if ws.ignore_lock() { + "Try re-running cargo install with `--locked`".to_string() + } else { + String::new() + } + } else if !unit.is_local() { + format!( + "Either upgrade to rustc {} or newer, or use\n\ + cargo update -p {}@{} --precise ver\n\ + where `ver` is the latest version of `{}` supporting rustc {}", + version, + unit.pkg.name(), + unit.pkg.version(), + unit.pkg.name(), + current_version, + ) + } else { + String::new() + }; + anyhow::bail!( "package `{}` cannot be built because it requires rustc {} or newer, \ - while the currently active rustc version is {}", + while the currently active rustc version is {}\n{}", unit.pkg, version, current_version, + guidance, ); } } @@ -1504,19 +1527,40 @@ }; if proposals.is_empty() { - let targets = packages.iter().flat_map(|pkg| { - pkg.targets() - .iter() - .filter(|target| is_expected_kind(target)) - }); - let suggestion = closest_msg(target_name, targets, |t| t.name()); - anyhow::bail!( - "no {} target {} `{}`{}", - target_desc, - if is_glob { "matches pattern" } else { "named" }, - target_name, - suggestion - ); + let targets = packages + .iter() + .flat_map(|pkg| { + pkg.targets() + .iter() + .filter(|target| is_expected_kind(target)) + }) + .collect::>(); + let suggestion = closest_msg(target_name, targets.iter(), |t| t.name()); + if !suggestion.is_empty() { + anyhow::bail!( + "no {} target {} `{}`{}", + target_desc, + if is_glob { "matches pattern" } else { "named" }, + target_name, + suggestion + ); + } else { + let mut msg = String::new(); + writeln!( + msg, + "no {} target {} `{}`.", + target_desc, + if is_glob { "matches pattern" } else { "named" }, + target_name, + )?; + if !targets.is_empty() { + writeln!(msg, "Available {} targets:", target_desc)?; + for target in targets { + writeln!(msg, " {}", target.name())?; + } + } + anyhow::bail!(msg); + } } Ok(proposals) } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_generate_lockfile.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_generate_lockfile.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_generate_lockfile.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_generate_lockfile.rs 2022-10-20 06:00:42.000000000 +0000 @@ -36,6 +36,25 @@ } pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoResult<()> { + // Currently this is only a warning, but after a transition period this will become + // a hard error. + // See https://github.com/rust-lang/cargo/issues/10919#issuecomment-1214464756. + // We should declare the `precise` and `aggressive` arguments + // require the `package` argument in the clap. + if opts.aggressive && opts.to_update.is_empty() { + ws.config().shell().warn( + "aggressive is only supported with \"--package \", \ + this will become a hard error in a future release.", + )?; + } + + if opts.precise.is_some() && opts.to_update.is_empty() { + ws.config().shell().warn( + "precise is only supported with \"--package \", \ + this will become a hard error in a future release.", + )?; + } + if opts.aggressive && opts.precise.is_some() { anyhow::bail!("cannot specify both aggressive and precise simultaneously") } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_install.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_install.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_install.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_install.rs 2022-10-20 06:00:42.000000000 +0000 @@ -530,26 +530,12 @@ // duplicate "Updating", but since `source` is taken by value, then it // wouldn't be available for `compile_ws`. let (pkg_set, resolve) = ops::resolve_ws(&self.ws)?; - let mut sources = pkg_set.sources_mut(); - - // Checking the yanked status involves taking a look at the registry and - // maybe updating files, so be sure to lock it here. - let _lock = self.ws.config().acquire_package_cache_lock()?; - - for pkg_id in resolve.iter() { - if let Some(source) = sources.get_mut(pkg_id.source_id()) { - if source.is_yanked(pkg_id)? { - self.ws.config().shell().warn(format!( - "package `{}` in Cargo.lock is yanked in registry `{}`, \ - consider running without --locked", - pkg_id, - pkg_id.source_id().display_registry_name() - ))?; - } - } - } - - Ok(()) + ops::check_yanked( + self.ws.config(), + &pkg_set, + &resolve, + "consider running without --locked", + ) } } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_new.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_new.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_new.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_new.rs 2022-10-20 06:00:42.000000000 +0000 @@ -10,8 +10,7 @@ use std::fmt; use std::io::{BufRead, BufReader, ErrorKind}; use std::path::{Path, PathBuf}; -use std::process::Command; -use std::str::{from_utf8, FromStr}; +use std::str::FromStr; use toml_edit::easy as toml; #[derive(Clone, Copy, Debug, PartialEq)] @@ -254,8 +253,7 @@ if restricted_names::is_non_ascii_name(name) { shell.warn(format!( "the name `{}` contains non-ASCII characters\n\ - Support for non-ASCII crate names is experimental and only valid \ - on the nightly toolchain.", + Non-ASCII crate names are not supported by Rust.", name ))?; } @@ -830,14 +828,12 @@ paths::write(&path_of_source_file, default_file_content)?; // Format the newly created source file - match Command::new("rustfmt").arg(&path_of_source_file).output() { - Err(e) => log::warn!("failed to call rustfmt: {}", e), - Ok(output) => { - if !output.status.success() { - log::warn!("rustfmt failed: {:?}", from_utf8(&output.stdout)); - } - } - }; + if let Err(e) = cargo_util::ProcessBuilder::new("rustfmt") + .arg(&path_of_source_file) + .exec_with_output() + { + log::warn!("failed to call rustfmt: {:#}", e); + } } } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_package.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_package.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_package.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_package.rs 2022-10-20 06:00:42.000000000 +0000 @@ -5,6 +5,7 @@ use std::path::{Path, PathBuf}; use std::rc::Rc; use std::sync::Arc; +use std::task::Poll; use crate::core::compiler::{BuildConfig, CompileMode, DefaultExecutor, Executor}; use crate::core::resolver::CliFeatures; @@ -29,7 +30,7 @@ pub check_metadata: bool, pub allow_dirty: bool, pub verify: bool, - pub jobs: Option, + pub jobs: Option, pub keep_going: bool, pub to_package: ops::Packages, pub targets: Vec, @@ -374,7 +375,12 @@ if let Some(orig_resolve) = orig_resolve { compare_resolve(config, tmp_ws.current()?, &orig_resolve, &new_resolve)?; } - check_yanked(config, &pkg_set, &new_resolve)?; + check_yanked( + config, + &pkg_set, + &new_resolve, + "consider updating to a version that is not yanked", + )?; ops::resolve_to_string(&tmp_ws, &mut new_resolve) } @@ -716,22 +722,45 @@ Ok(()) } -fn check_yanked(config: &Config, pkg_set: &PackageSet<'_>, resolve: &Resolve) -> CargoResult<()> { +pub fn check_yanked( + config: &Config, + pkg_set: &PackageSet<'_>, + resolve: &Resolve, + hint: &str, +) -> CargoResult<()> { // Checking the yanked status involves taking a look at the registry and // maybe updating files, so be sure to lock it here. let _lock = config.acquire_package_cache_lock()?; let mut sources = pkg_set.sources_mut(); - for pkg_id in resolve.iter() { - if let Some(source) = sources.get_mut(pkg_id.source_id()) { - if source.is_yanked(pkg_id)? { - config.shell().warn(format!( - "package `{}` in Cargo.lock is yanked in registry `{}`, \ - consider updating to a version that is not yanked", - pkg_id, - pkg_id.source_id().display_registry_name() - ))?; + let mut pending: Vec = resolve.iter().collect(); + let mut results = Vec::new(); + for (_id, source) in sources.sources_mut() { + source.invalidate_cache(); + } + while !pending.is_empty() { + pending.retain(|pkg_id| { + if let Some(source) = sources.get_mut(pkg_id.source_id()) { + match source.is_yanked(*pkg_id) { + Poll::Ready(result) => results.push((*pkg_id, result)), + Poll::Pending => return true, + } } + false + }); + for (_id, source) in sources.sources_mut() { + source.block_until_ready()?; + } + } + + for (pkg_id, is_yanked) in results { + if is_yanked? { + config.shell().warn(format!( + "package `{}` in Cargo.lock is yanked in registry `{}`, {}", + pkg_id, + pkg_id.source_id().display_registry_name(), + hint + ))?; } } Ok(()) diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_test.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_test.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/cargo_test.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/cargo_test.rs 2022-10-20 06:00:42.000000000 +0000 @@ -3,9 +3,11 @@ use crate::core::{TargetKind, Workspace}; use crate::ops; use crate::util::errors::CargoResult; -use crate::util::{add_path_args, CargoTestError, Config, Test}; +use crate::util::{add_path_args, CliError, CliResult, Config}; +use anyhow::format_err; use cargo_util::{ProcessBuilder, ProcessError}; use std::ffi::OsString; +use std::fmt::Write; use std::path::{Path, PathBuf}; pub struct TestOptions { @@ -14,61 +16,87 @@ pub no_fail_fast: bool, } -pub fn run_tests( - ws: &Workspace<'_>, - options: &TestOptions, - test_args: &[&str], -) -> CargoResult> { +/// The kind of test. +/// +/// This is needed because `Unit` does not track whether or not something is a +/// benchmark. +#[derive(Copy, Clone)] +enum TestKind { + Test, + Bench, + Doctest, +} + +/// A unit that failed to run. +struct UnitTestError { + unit: Unit, + kind: TestKind, +} + +impl UnitTestError { + /// Returns the CLI args needed to target this unit. + fn cli_args(&self, ws: &Workspace<'_>, opts: &ops::CompileOptions) -> String { + let mut args = if opts.spec.needs_spec_flag(ws) { + format!("-p {} ", self.unit.pkg.name()) + } else { + String::new() + }; + let mut add = |which| write!(args, "--{which} {}", self.unit.target.name()).unwrap(); + + match self.kind { + TestKind::Test | TestKind::Bench => match self.unit.target.kind() { + TargetKind::Lib(_) => args.push_str("--lib"), + TargetKind::Bin => add("bin"), + TargetKind::Test => add("test"), + TargetKind::Bench => add("bench"), + TargetKind::ExampleLib(_) | TargetKind::ExampleBin => add("example"), + TargetKind::CustomBuild => panic!("unexpected CustomBuild kind"), + }, + TestKind::Doctest => args.push_str("--doc"), + } + args + } +} + +/// Compiles and runs tests. +/// +/// On error, the returned [`CliError`] will have the appropriate process exit +/// code that Cargo should use. +pub fn run_tests(ws: &Workspace<'_>, options: &TestOptions, test_args: &[&str]) -> CliResult { let compilation = compile_tests(ws, options)?; if options.no_run { if !options.compile_opts.build_config.emit_json() { display_no_run_information(ws, test_args, &compilation, "unittests")?; } - - return Ok(None); + return Ok(()); } - let (test, mut errors) = run_unit_tests(ws.config(), options, test_args, &compilation)?; + let mut errors = run_unit_tests(ws, options, test_args, &compilation, TestKind::Test)?; - // If we have an error and want to fail fast, then return. - if !errors.is_empty() && !options.no_fail_fast { - return Ok(Some(CargoTestError::new(test, errors))); - } - - let (doctest, docerrors) = run_doc_tests(ws, options, test_args, &compilation)?; - let test = if docerrors.is_empty() { test } else { doctest }; - errors.extend(docerrors); - if errors.is_empty() { - Ok(None) - } else { - Ok(Some(CargoTestError::new(test, errors))) - } + let doctest_errors = run_doc_tests(ws, options, test_args, &compilation)?; + errors.extend(doctest_errors); + no_fail_fast_err(ws, &options.compile_opts, &errors) } -pub fn run_benches( - ws: &Workspace<'_>, - options: &TestOptions, - args: &[&str], -) -> CargoResult> { +/// Compiles and runs benchmarks. +/// +/// On error, the returned [`CliError`] will have the appropriate process exit +/// code that Cargo should use. +pub fn run_benches(ws: &Workspace<'_>, options: &TestOptions, args: &[&str]) -> CliResult { let compilation = compile_tests(ws, options)?; if options.no_run { if !options.compile_opts.build_config.emit_json() { display_no_run_information(ws, args, &compilation, "benches")?; } - - return Ok(None); + return Ok(()); } let mut args = args.to_vec(); args.push("--bench"); - let (test, errors) = run_unit_tests(ws.config(), options, &args, &compilation)?; - - match errors.len() { - 0 => Ok(None), - _ => Ok(Some(CargoTestError::new(test, errors))), - } + let errors = run_unit_tests(ws, options, &args, &compilation, TestKind::Bench)?; + no_fail_fast_err(ws, &options.compile_opts, &errors) } fn compile_tests<'a>(ws: &Workspace<'a>, options: &TestOptions) -> CargoResult> { @@ -78,12 +106,17 @@ } /// Runs the unit and integration tests of a package. +/// +/// Returns a `Vec` of tests that failed when `--no-fail-fast` is used. +/// If `--no-fail-fast` is *not* used, then this returns an `Err`. fn run_unit_tests( - config: &Config, + ws: &Workspace<'_>, options: &TestOptions, test_args: &[&str], compilation: &Compilation<'_>, -) -> CargoResult<(Test, Vec)> { + test_kind: TestKind, +) -> Result, CliError> { + let config = ws.config(); let cwd = config.cwd(); let mut errors = Vec::new(); @@ -110,46 +143,32 @@ .shell() .verbose(|shell| shell.status("Running", &cmd))?; - let result = cmd.exec(); - - 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 let Err(e) = cmd.exec() { + let code = fail_fast_code(&e); + let unit_err = UnitTestError { + unit: unit.clone(), + kind: test_kind, + }; + report_test_error(ws, &options.compile_opts, &unit_err, e); + errors.push(unit_err); if !options.no_fail_fast { - break; + return Err(CliError::code(code)); } } } - - if errors.len() == 1 { - let (kind, name, pkg_name, e) = errors.pop().unwrap(); - Ok(( - Test::UnitTest { - kind, - name, - pkg_name, - }, - vec![e], - )) - } else { - Ok(( - Test::Multiple, - errors.into_iter().map(|(_, _, _, e)| e).collect(), - )) - } + Ok(errors) } +/// Runs doc tests. +/// +/// Returns a `Vec` of tests that failed when `--no-fail-fast` is used. +/// If `--no-fail-fast` is *not* used, then this returns an `Err`. fn run_doc_tests( ws: &Workspace<'_>, options: &TestOptions, test_args: &[&str], compilation: &Compilation<'_>, -) -> CargoResult<(Test, Vec)> { +) -> Result, CliError> { let config = ws.config(); let mut errors = Vec::new(); let doctest_xcompile = config.cli_unstable().doctest_xcompile; @@ -258,16 +277,24 @@ .shell() .verbose(|shell| shell.status("Running", p.to_string()))?; if let Err(e) = p.exec() { - let e = e.downcast::()?; - errors.push(e); + let code = fail_fast_code(&e); + let unit_err = UnitTestError { + unit: unit.clone(), + kind: TestKind::Doctest, + }; + report_test_error(ws, &options.compile_opts, &unit_err, e); + errors.push(unit_err); if !options.no_fail_fast { - return Ok((Test::Doc, errors)); + return Err(CliError::code(code)); } } } - Ok((Test::Doc, errors)) + Ok(errors) } +/// Displays human-readable descriptions of the test executables. +/// +/// This is used when `cargo test --no-run` is used. fn display_no_run_information( ws: &Workspace<'_>, test_args: &[&str], @@ -303,6 +330,11 @@ return Ok(()); } +/// Creates a [`ProcessBuilder`] for executing a single test. +/// +/// Returns a tuple `(exe_display, process)` where `exe_display` is a string +/// to display that describes the executable path in a human-readable form. +/// `process` is the `ProcessBuilder` to use for executing the test. fn cmd_builds( config: &Config, cwd: &Path, @@ -341,3 +373,67 @@ Ok((exe_display, cmd)) } + +/// Returns the error code to use when *not* using `--no-fail-fast`. +/// +/// Cargo will return the error code from the test process itself. If some +/// other error happened (like a failure to launch the process), then it will +/// return a standard 101 error code. +/// +/// When using `--no-fail-fast`, Cargo always uses the 101 exit code (since +/// there may not be just one process to report). +fn fail_fast_code(error: &anyhow::Error) -> i32 { + if let Some(proc_err) = error.downcast_ref::() { + if let Some(code) = proc_err.code { + return code; + } + } + 101 +} + +/// Returns the `CliError` when using `--no-fail-fast` and there is at least +/// one error. +fn no_fail_fast_err( + ws: &Workspace<'_>, + opts: &ops::CompileOptions, + errors: &[UnitTestError], +) -> CliResult { + // TODO: This could be improved by combining the flags on a single line when feasible. + let args: Vec<_> = errors + .iter() + .map(|unit_err| format!(" `{}`", unit_err.cli_args(ws, opts))) + .collect(); + let message = match errors.len() { + 0 => return Ok(()), + 1 => format!("1 target failed:\n{}", args.join("\n")), + n => format!("{n} targets failed:\n{}", args.join("\n")), + }; + Err(anyhow::Error::msg(message).into()) +} + +/// Displays an error on the console about a test failure. +fn report_test_error( + ws: &Workspace<'_>, + opts: &ops::CompileOptions, + unit_err: &UnitTestError, + test_error: anyhow::Error, +) { + let which = match unit_err.kind { + TestKind::Test => "test failed", + TestKind::Bench => "bench failed", + TestKind::Doctest => "doctest failed", + }; + + let mut err = format_err!("{}, to rerun pass `{}`", which, unit_err.cli_args(ws, opts)); + // Don't show "process didn't exit successfully" for simple errors. + // libtest exits with 101 for normal errors. + let is_simple = test_error + .downcast_ref::() + .and_then(|proc_err| proc_err.code) + .map_or(false, |code| code == 101); + if !is_simple { + err = test_error.context(err); + } + + crate::display_error(&err, &mut ws.config().shell()); +} diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/common_for_install_and_uninstall.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/common_for_install_and_uninstall.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/common_for_install_and_uninstall.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/common_for_install_and_uninstall.rs 2022-10-20 06:00:42.000000000 +0000 @@ -11,7 +11,7 @@ use toml_edit::easy as toml; use crate::core::compiler::Freshness; -use crate::core::{Dependency, FeatureValue, Package, PackageId, Source, SourceId}; +use crate::core::{Dependency, FeatureValue, Package, PackageId, QueryKind, Source, SourceId}; use crate::ops::{self, CompileFilter, CompileOptions}; use crate::sources::PathSource; use crate::util::errors::CargoResult; @@ -540,7 +540,7 @@ } let deps = loop { - match source.query_vec(&dep)? { + match source.query_vec(&dep, QueryKind::Exact)? { Poll::Ready(deps) => break deps, Poll::Pending => source.block_until_ready()?, } @@ -553,8 +553,20 @@ None => { let is_yanked: bool = if dep.version_req().is_exact() { let version: String = dep.version_req().to_string(); - PackageId::new(dep.package_name(), &version[1..], source.source_id()) - .map_or(false, |pkg_id| source.is_yanked(pkg_id).unwrap_or(false)) + if let Ok(pkg_id) = + PackageId::new(dep.package_name(), &version[1..], source.source_id()) + { + source.invalidate_cache(); + loop { + match source.is_yanked(pkg_id) { + Poll::Ready(Ok(is_yanked)) => break is_yanked, + Poll::Ready(Err(_)) => break false, + Poll::Pending => source.block_until_ready()?, + } + } + } else { + false + } } else { false }; diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/fix.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/fix.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/fix.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/fix.rs 2022-10-20 06:00:42.000000000 +0000 @@ -333,20 +333,23 @@ Ok(()) } +/// Provide the lock address when running in proxy mode +/// +/// Returns `None` if `fix` is not being run (not in proxy mode). Returns +/// `Some(...)` if in `fix` proxy mode +pub fn fix_get_proxy_lock_addr() -> Option { + env::var(FIX_ENV).ok() +} + /// Entry point for `cargo` running as a proxy for `rustc`. /// /// This is called every time `cargo` is run to check if it is in proxy mode. /// -/// Returns `false` if `fix` is not being run (not in proxy mode). Returns -/// `true` if in `fix` proxy mode, and the fix was complete without any -/// warnings or errors. If there are warnings or errors, this does not return, +/// If there are warnings or errors, this does not return, /// and the process exits with the corresponding `rustc` exit code. -pub fn fix_maybe_exec_rustc(config: &Config) -> CargoResult { - let lock_addr = match env::var(FIX_ENV) { - Ok(s) => s, - Err(_) => return Ok(false), - }; - +/// +/// See [`fix_get_proxy_lock_addr`] +pub fn fix_exec_rustc(config: &Config, lock_addr: &str) -> CargoResult<()> { let args = FixArgs::get()?; trace!("cargo-fix as rustc got file {:?}", args.file); @@ -392,7 +395,7 @@ // any. If stderr is empty then there's no need for the final exec at // the end, we just bail out here. if output.status.success() && output.stderr.is_empty() { - return Ok(true); + return Ok(()); } // Otherwise, if our rustc just failed, then that means that we broke the diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -13,13 +13,13 @@ pub use self::cargo_install::{install, install_list}; pub use self::cargo_new::{init, new, NewOptions, VersionControl}; pub use self::cargo_output_metadata::{output_metadata, ExportInfo, OutputMetadataOptions}; -pub use self::cargo_package::{package, package_one, PackageOpts}; +pub use self::cargo_package::{check_yanked, package, package_one, PackageOpts}; pub use self::cargo_pkgid::pkgid; pub use self::cargo_read_manifest::{read_package, read_packages}; pub use self::cargo_run::run; pub use self::cargo_test::{run_benches, run_tests, TestOptions}; pub use self::cargo_uninstall::uninstall; -pub use self::fix::{fix, fix_maybe_exec_rustc, FixOptions}; +pub use self::fix::{fix, fix_exec_rustc, fix_get_proxy_lock_addr, FixOptions}; pub use self::lockfile::{load_pkg_lockfile, resolve_to_string, write_pkg_lockfile}; pub use self::registry::HttpTimeout; pub use self::registry::{configure_http_handle, http_handle, http_handle_and_timeout}; diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/registry.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/registry.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/registry.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/registry.rs 2022-10-20 06:00:42.000000000 +0000 @@ -48,13 +48,13 @@ impl RegistryConfig { /// Returns `true` if the credential is [`None`]. /// - /// [`None`]: Credential::None + /// [`None`]: Self::None pub fn is_none(&self) -> bool { matches!(self, Self::None) } /// Returns `true` if the credential is [`Token`]. /// - /// [`Token`]: Credential::Token + /// [`Token`]: Self::Token pub fn is_token(&self) -> bool { matches!(self, Self::Token(..)) } @@ -80,7 +80,7 @@ pub index: Option, pub verify: bool, pub allow_dirty: bool, - pub jobs: Option, + pub jobs: Option, pub keep_going: bool, pub to_publish: ops::Packages, pub targets: Vec, @@ -196,10 +196,6 @@ if super::check_dep_has_version(dep, true)? { continue; } - // Allow publishing to crates.io with index.crates.io as a source replacement. - if registry_src.is_default_registry() && dep.source_id().is_default_registry() { - continue; - } // TomlManifest::prepare_for_publish will rewrite the dependency // to be just the `version` field. if dep.source_id() != registry_src { @@ -535,6 +531,13 @@ None }; let handle = http_handle(config)?; + // Workaround for the sparse+https://index.crates.io replacement index. Use the non-replaced + // source_id so that the original (github) url is used when publishing a crate. + let sid = if sid.is_default_registry() { + SourceId::crates_io(config)? + } else { + sid + }; Ok((Registry::new_handle(api_host, token, handle), reg_cfg, sid)) } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/resolve.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/resolve.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/resolve.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/resolve.rs 2022-10-20 06:00:42.000000000 +0000 @@ -209,7 +209,7 @@ Ok(resolve) } -/// Resolves all dependencies for a package using an optional previous instance. +/// Resolves all dependencies for a package using an optional previous instance /// of resolve to guide the resolution process. /// /// This also takes an optional hash set, `to_avoid`, which is a list of package @@ -386,21 +386,19 @@ let keep = |p: &PackageId| pre_patch_keep(p) && !avoid_patch_ids.contains(p); let dev_deps = ws.require_optional_deps() || has_dev_units == HasDevUnits::Yes; - // In the case where a previous instance of resolve is available, we - // want to lock as many packages as possible to the previous version - // without disturbing the graph structure. + if let Some(r) = previous { trace!("previous: {:?}", r); + + // In the case where a previous instance of resolve is available, we + // want to lock as many packages as possible to the previous version + // without disturbing the graph structure. register_previous_locks(ws, registry, r, &keep, dev_deps); - } - // Prefer to use anything in the previous lock file, aka we want to have conservative updates. - for r in previous { - for id in r.iter() { - if keep(&id) { - debug!("attempting to prefer {}", id); - version_prefs.prefer_package_id(id); - } + // Prefer to use anything in the previous lock file, aka we want to have conservative updates. + for id in r.iter().filter(keep) { + debug!("attempting to prefer {}", id); + version_prefs.prefer_package_id(id); } } @@ -796,7 +794,7 @@ writeln!(msg, "Patch `{}` {}", unused, MESSAGE)?; write!( msg, - "Perhaps you misspell the source URL being patched.\n\ + "Perhaps you misspelled the source URL being patched.\n\ Possible URLs for `[patch.]`:", )?; for id in ids.iter() { diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/vendor.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/vendor.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/ops/vendor.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/ops/vendor.rs 2022-10-20 06:00:42.000000000 +0000 @@ -60,7 +60,7 @@ #[serde(rename_all = "lowercase", untagged)] enum VendorSource { Directory { - directory: PathBuf, + directory: String, }, Registry { registry: Option, @@ -298,7 +298,10 @@ config.insert( merged_source_name.to_string(), VendorSource::Directory { - directory: opts.destination.to_path_buf(), + // Windows-flavour paths are valid here on Windows but Unix. + // This backslash normalization is for making output paths more + // cross-platform compatible. + directory: opts.destination.to_string_lossy().replace("\\", "/"), }, ); } else if !dest_dir_already_exists { diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/directory.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/directory.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/directory.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/directory.rs 2022-10-20 06:00:42.000000000 +0000 @@ -4,7 +4,7 @@ use std::task::Poll; use crate::core::source::MaybePackage; -use crate::core::{Dependency, Package, PackageId, Source, SourceId, Summary}; +use crate::core::{Dependency, Package, PackageId, QueryKind, Source, SourceId, Summary}; use crate::sources::PathSource; use crate::util::errors::CargoResult; use crate::util::Config; @@ -46,28 +46,21 @@ } impl<'cfg> Source for DirectorySource<'cfg> { - fn query(&mut self, dep: &Dependency, f: &mut dyn FnMut(Summary)) -> Poll> { - if !self.updated { - return Poll::Pending; - } - let packages = self.packages.values().map(|p| &p.0); - let matches = packages.filter(|pkg| dep.matches(pkg.summary())); - for summary in matches.map(|pkg| pkg.summary().clone()) { - f(summary); - } - Poll::Ready(Ok(())) - } - - fn fuzzy_query( + fn query( &mut self, - _dep: &Dependency, + dep: &Dependency, + kind: QueryKind, f: &mut dyn FnMut(Summary), ) -> Poll> { if !self.updated { return Poll::Pending; } let packages = self.packages.values().map(|p| &p.0); - for summary in packages.map(|pkg| pkg.summary().clone()) { + let matches = packages.filter(|pkg| match kind { + QueryKind::Exact => dep.matches(pkg.summary()), + QueryKind::Fuzzy => true, + }); + for summary in matches.map(|pkg| pkg.summary().clone()) { f(summary); } Poll::Ready(Ok(())) @@ -219,8 +212,8 @@ fn add_to_yanked_whitelist(&mut self, _pkgs: &[PackageId]) {} - fn is_yanked(&mut self, _pkg: PackageId) -> CargoResult { - Ok(false) + fn is_yanked(&mut self, _pkg: PackageId) -> Poll> { + Poll::Ready(Ok(false)) } fn invalidate_cache(&mut self) { diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/git/source.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/git/source.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/git/source.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/git/source.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,4 +1,4 @@ -use crate::core::source::{MaybePackage, Source, SourceId}; +use crate::core::source::{MaybePackage, QueryKind, Source, SourceId}; use crate::core::GitReference; use crate::core::{Dependency, Package, PackageId, Summary}; use crate::sources::git::utils::GitRemote; @@ -86,21 +86,14 @@ } impl<'cfg> Source for GitSource<'cfg> { - fn query(&mut self, dep: &Dependency, f: &mut dyn FnMut(Summary)) -> Poll> { - if let Some(src) = self.path_source.as_mut() { - src.query(dep, f) - } else { - Poll::Pending - } - } - - fn fuzzy_query( + fn query( &mut self, dep: &Dependency, + kind: QueryKind, f: &mut dyn FnMut(Summary), ) -> Poll> { if let Some(src) = self.path_source.as_mut() { - src.fuzzy_query(dep, f) + src.query(dep, kind, f) } else { Poll::Pending } @@ -234,8 +227,8 @@ fn add_to_yanked_whitelist(&mut self, _pkgs: &[PackageId]) {} - fn is_yanked(&mut self, _pkg: PackageId) -> CargoResult { - Ok(false) + fn is_yanked(&mut self, _pkg: PackageId) -> Poll> { + Poll::Ready(Ok(false)) } fn invalidate_cache(&mut self) {} diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/git/utils.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/git/utils.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/git/utils.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/git/utils.rs 2022-10-20 06:00:42.000000000 +0000 @@ -7,7 +7,7 @@ use anyhow::{anyhow, Context as _}; use cargo_util::{paths, ProcessBuilder}; use curl::easy::List; -use git2::{self, ErrorClass, ObjectType}; +use git2::{self, ErrorClass, ObjectType, Oid}; use log::{debug, info}; use serde::ser; use serde::Serialize; @@ -15,6 +15,7 @@ use std::fmt; use std::path::{Path, PathBuf}; use std::process::Command; +use std::str; use std::time::{Duration, Instant}; use url::Url; @@ -151,30 +152,16 @@ dest: &Path, cargo_config: &Config, ) -> CargoResult> { - let mut checkout = None; - if let Ok(repo) = git2::Repository::open(dest) { - let mut co = GitCheckout::new(dest, self, rev, repo); - if !co.is_fresh() { - // After a successful fetch operation the subsequent reset can - // fail sometimes for corrupt repositories where the fetch - // operation succeeds but the object isn't actually there in one - // way or another. In these situations just skip the error and - // try blowing away the whole repository and trying with a - // clone. - co.fetch(cargo_config)?; - match co.reset(cargo_config) { - Ok(()) => { - assert!(co.is_fresh()); - checkout = Some(co); - } - Err(e) => debug!("failed reset after fetch {:?}", e), - } - } else { - checkout = Some(co); - } - }; - let checkout = match checkout { - Some(c) => c, + // If the existing checkout exists, and it is fresh, use it. + // A non-fresh checkout can happen if the checkout operation was + // interrupted. In that case, the checkout gets deleted and a new + // clone is created. + let checkout = match git2::Repository::open(dest) + .ok() + .map(|repo| GitCheckout::new(dest, self, rev, repo)) + .filter(|co| co.is_fresh()) + { + Some(co) => co, None => GitCheckout::clone_into(dest, self, rev, cargo_config)?, }; checkout.update_submodules(cargo_config)?; @@ -311,14 +298,6 @@ } } - fn fetch(&mut self, cargo_config: &Config) -> CargoResult<()> { - info!("fetch {}", self.repo.path().display()); - let url = self.database.path.into_url()?; - let reference = GitReference::Rev(self.revision.to_string()); - fetch(&mut self.repo, url.as_str(), &reference, cargo_config)?; - Ok(()) - } - fn reset(&self, config: &Config) -> CargoResult<()> { // If we're interrupted while performing this reset (e.g., we die because // of a signal) Cargo needs to be sure to try to check out this repo @@ -529,7 +508,7 @@ // // If ssh-agent authentication fails, libgit2 will keep calling this // callback asking for other authentication methods to try. Check - // cred_helper_bad to make sure we only try the git credentail helper + // cred_helper_bad to make sure we only try the git credential helper // once, to avoid looping forever. if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) && cred_helper_bad.is_none() { @@ -781,11 +760,15 @@ // If we're fetching from GitHub, attempt GitHub's special fast path for // testing if we've already got an up-to-date copy of the repository - match github_up_to_date(repo, url, reference, config) { - Ok(true) => return Ok(()), - Ok(false) => {} - Err(e) => debug!("failed to check github {:?}", e), - } + let oid_to_fetch = match github_fast_path(repo, url, reference, config) { + Ok(FastPathRev::UpToDate) => return Ok(()), + Ok(FastPathRev::NeedsFetch(rev)) => Some(rev), + Ok(FastPathRev::Indeterminate) => None, + Err(e) => { + debug!("failed to check github {:?}", e); + None + } + }; // We reuse repositories quite a lot, so before we go through and update the // repo check to see if it's a little too old and could benefit from a gc. @@ -817,6 +800,8 @@ GitReference::Rev(rev) => { if rev.starts_with("refs/") { refspecs.push(format!("+{0}:{0}", rev)); + } else if let Some(oid_to_fetch) = oid_to_fetch { + refspecs.push(format!("+{0}:refs/commit/{0}", oid_to_fetch)); } else { // We don't know what the rev will point to. To handle this // situation we fetch all branches and tags, and then we pray @@ -1013,15 +998,25 @@ Ok(git2::Repository::init_opts(&path, &opts)?) } +enum FastPathRev { + /// The local rev (determined by `reference.resolve(repo)`) is already up to + /// date with what this rev resolves to on GitHub's server. + UpToDate, + /// The following SHA must be fetched in order for the local rev to become + /// up to date. + NeedsFetch(Oid), + /// Don't know whether local rev is up to date. We'll fetch _all_ branches + /// and tags from the server and see what happens. + Indeterminate, +} + /// Updating the index is done pretty regularly so we want it to be as fast as /// possible. For registries hosted on GitHub (like the crates.io index) there's /// a fast path available to use [1] to tell us that there's no updates to be /// made. /// /// This function will attempt to hit that fast path and verify that the `oid` -/// is actually the current branch of the repository. If `true` is returned then -/// no update needs to be performed, but if `false` is returned then the -/// standard update logic still needs to happen. +/// is actually the current branch of the repository. /// /// [1]: https://developer.github.com/v3/repos/commits/#get-the-sha-1-of-a-commit-reference /// @@ -1029,17 +1024,19 @@ /// just a fast path. As a result all errors are ignored in this function and we /// just return a `bool`. Any real errors will be reported through the normal /// update path above. -fn github_up_to_date( +fn github_fast_path( repo: &mut git2::Repository, url: &str, reference: &GitReference, config: &Config, -) -> CargoResult { +) -> CargoResult { let url = Url::parse(url)?; - if url.host_str() != Some("github.com") { - return Ok(false); + if !is_github(&url) { + return Ok(FastPathRev::Indeterminate); } + let local_object = reference.resolve(repo).ok(); + let github_branch_name = match reference { GitReference::Branch(branch) => branch, GitReference::Tag(tag) => tag, @@ -1047,9 +1044,33 @@ GitReference::Rev(rev) => { if rev.starts_with("refs/") { rev + } else if looks_like_commit_hash(rev) { + // `revparse_single` (used by `resolve`) is the only way to turn + // short hash -> long hash, but it also parses other things, + // like branch and tag names, which might coincidentally be + // valid hex. + // + // We only return early if `rev` is a prefix of the object found + // by `revparse_single`. Don't bother talking to GitHub in that + // case, since commit hashes are permanent. If a commit with the + // requested hash is already present in the local clone, its + // contents must be the same as what is on the server for that + // hash. + // + // If `rev` is not found locally by `revparse_single`, we'll + // need GitHub to resolve it and get a hash. If `rev` is found + // but is not a short hash of the found object, it's probably a + // branch and we also need to get a hash from GitHub, in case + // the branch has moved. + if let Some(local_object) = local_object { + if is_short_hash_of(rev, local_object) { + return Ok(FastPathRev::UpToDate); + } + } + rev } else { debug!("can't use github fast path with `rev = \"{}\"`", rev); - return Ok(false); + return Ok(FastPathRev::Indeterminate); } } }; @@ -1082,10 +1103,50 @@ handle.get(true)?; handle.url(&url)?; handle.useragent("cargo")?; - let mut headers = List::new(); - headers.append("Accept: application/vnd.github.3.sha")?; - headers.append(&format!("If-None-Match: \"{}\"", reference.resolve(repo)?))?; - handle.http_headers(headers)?; - handle.perform()?; - Ok(handle.response_code()? == 304) + handle.http_headers({ + let mut headers = List::new(); + headers.append("Accept: application/vnd.github.3.sha")?; + if let Some(local_object) = local_object { + headers.append(&format!("If-None-Match: \"{}\"", local_object))?; + } + headers + })?; + + let mut response_body = Vec::new(); + let mut transfer = handle.transfer(); + transfer.write_function(|data| { + response_body.extend_from_slice(data); + Ok(data.len()) + })?; + transfer.perform()?; + drop(transfer); // end borrow of handle so that response_code can be called + + let response_code = handle.response_code()?; + if response_code == 304 { + Ok(FastPathRev::UpToDate) + } else if response_code == 200 { + let oid_to_fetch = str::from_utf8(&response_body)?.parse::()?; + Ok(FastPathRev::NeedsFetch(oid_to_fetch)) + } else { + // Usually response_code == 404 if the repository does not exist, and + // response_code == 422 if exists but GitHub is unable to resolve the + // requested rev. + Ok(FastPathRev::Indeterminate) + } +} + +fn is_github(url: &Url) -> bool { + url.host_str() == Some("github.com") +} + +fn looks_like_commit_hash(rev: &str) -> bool { + rev.len() >= 7 && rev.chars().all(|ch| ch.is_ascii_hexdigit()) +} + +fn is_short_hash_of(rev: &str, oid: Oid) -> bool { + let long_hash = oid.to_string(); + match long_hash.get(..rev.len()) { + Some(truncated_long_hash) => truncated_long_hash.eq_ignore_ascii_case(rev), + None => false, + } } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/path.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/path.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/path.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/path.rs 2022-10-20 06:00:42.000000000 +0000 @@ -4,7 +4,7 @@ use std::task::Poll; use crate::core::source::MaybePackage; -use crate::core::{Dependency, Package, PackageId, Source, SourceId, Summary}; +use crate::core::{Dependency, Package, PackageId, QueryKind, Source, SourceId, Summary}; use crate::ops; use crate::util::{internal, CargoResult, Config}; use anyhow::Context as _; @@ -150,7 +150,7 @@ } }; - let mut filter = |path: &Path, is_dir: bool| { + let filter = |path: &Path, is_dir: bool| { let relative_path = match path.strip_prefix(root) { Ok(p) => p, Err(_) => return false, @@ -169,10 +169,10 @@ // Attempt Git-prepopulate only if no `include` (see rust-lang/cargo#4135). if no_include_option { if let Some(repo) = git_repo { - return self.list_files_git(pkg, &repo, &mut filter); + return self.list_files_git(pkg, &repo, &filter); } } - self.list_files_walk(pkg, &mut filter) + self.list_files_walk(pkg, &filter) } /// Returns `Some(git2::Repository)` if found sibling `Cargo.toml` and `.git` @@ -222,7 +222,7 @@ &self, pkg: &Package, repo: &git2::Repository, - filter: &mut dyn FnMut(&Path, bool) -> bool, + filter: &dyn Fn(&Path, bool) -> bool, ) -> CargoResult> { warn!("list_files_git {}", pkg.package_id()); let index = repo.index()?; @@ -376,7 +376,7 @@ fn list_files_walk( &self, pkg: &Package, - filter: &mut dyn FnMut(&Path, bool) -> bool, + filter: &dyn Fn(&Path, bool) -> bool, ) -> CargoResult> { let mut ret = Vec::new(); self.walk(pkg.root(), &mut ret, true, filter)?; @@ -388,7 +388,7 @@ path: &Path, ret: &mut Vec, is_root: bool, - filter: &mut dyn FnMut(&Path, bool) -> bool, + filter: &dyn Fn(&Path, bool) -> bool, ) -> CargoResult<()> { let walkdir = WalkDir::new(path) .follow_links(true) @@ -432,7 +432,11 @@ self.config.shell().warn(err)?; } Err(err) => match err.path() { - // If the error occurs with a path, simply recover from it. + // If an error occurs with a path, filter it again. + // If it is excluded, Just ignore it in this case. + // See issue rust-lang/cargo#10917 + Some(path) if !filter(path, path.is_dir()) => {} + // Otherwise, 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()), @@ -497,24 +501,21 @@ } impl<'cfg> Source for PathSource<'cfg> { - fn query(&mut self, dep: &Dependency, f: &mut dyn FnMut(Summary)) -> Poll> { - self.update()?; - for s in self.packages.iter().map(|p| p.summary()) { - if dep.matches(s) { - f(s.clone()) - } - } - Poll::Ready(Ok(())) - } - - fn fuzzy_query( + fn query( &mut self, - _dep: &Dependency, + dep: &Dependency, + kind: QueryKind, f: &mut dyn FnMut(Summary), ) -> Poll> { self.update()?; for s in self.packages.iter().map(|p| p.summary()) { - f(s.clone()) + let matched = match kind { + QueryKind::Exact => dep.matches(s), + QueryKind::Fuzzy => true, + }; + if matched { + f(s.clone()) + } } Poll::Ready(Ok(())) } @@ -562,8 +563,8 @@ fn add_to_yanked_whitelist(&mut self, _pkgs: &[PackageId]) {} - fn is_yanked(&mut self, _pkg: PackageId) -> CargoResult { - Ok(false) + fn is_yanked(&mut self, _pkg: PackageId) -> Poll> { + Poll::Ready(Ok(false)) } fn block_until_ready(&mut self) -> CargoResult<()> { diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/registry/http_remote.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/registry/http_remote.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/registry/http_remote.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/registry/http_remote.rs 2022-10-20 06:00:42.000000000 +0000 @@ -14,7 +14,7 @@ use curl::easy::{HttpVersion, List}; use curl::multi::{EasyHandle, Multi}; use log::{debug, trace}; -use std::cell::{Cell, RefCell}; +use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::fs::{self, File}; use std::path::{Path, PathBuf}; @@ -98,6 +98,9 @@ progress: RefCell>>, /// Number of downloads that have successfully finished. downloads_finished: usize, + /// Number of times the caller has requested blocking. This is used for + /// an estimate of progress. + blocking_calls: usize, } struct Download { @@ -113,10 +116,6 @@ /// ETag or Last-Modified header received from the server (if any). index_version: RefCell>, - - /// Statistics updated from the progress callback in libcurl. - total: Cell, - current: Cell, } struct CompletedDownload { @@ -159,10 +158,11 @@ results: HashMap::new(), progress: RefCell::new(Some(Progress::with_style( "Fetch", - ProgressStyle::Ratio, + ProgressStyle::Indeterminate, config, ))), downloads_finished: 0, + blocking_calls: 0, }, fresh: HashSet::new(), requested_update: false, @@ -457,15 +457,6 @@ Ok(buf.len()) })?; - // Same goes for the progress function -- it goes through thread-local storage. - handle.progress(true)?; - handle.progress_function(move |dl_total, dl_cur, _, _| { - tls::with(|downloads| match downloads { - Some(d) => d.progress(token, dl_total as u64, dl_cur as u64), - None => false, - }) - })?; - // And ditto for the header function. handle.header_function(move |buf| { if let Some((tag, value)) = Self::handle_http_header(buf) { @@ -494,8 +485,6 @@ data: RefCell::new(Vec::new()), path: path.to_path_buf(), index_version: RefCell::new(None), - total: Cell::new(0), - current: Cell::new(0), }; // Finally add the request we've lined up to the pool of requests that cURL manages. @@ -588,11 +577,11 @@ } fn block_until_ready(&mut self) -> CargoResult<()> { - let initial_pending_count = self.downloads.pending.len(); trace!( "block_until_ready: {} transfers pending", - initial_pending_count + self.downloads.pending.len() ); + self.downloads.blocking_calls += 1; loop { self.handle_completed_downloads()?; @@ -622,21 +611,31 @@ } impl<'cfg> Downloads<'cfg> { - fn progress(&self, token: usize, total: u64, cur: u64) -> bool { - let dl = &self.pending[&token].0; - dl.total.set(total); - dl.current.set(cur); - true - } - fn tick(&self) -> CargoResult<()> { let mut progress = self.progress.borrow_mut(); let progress = progress.as_mut().unwrap(); + // Since the sparse protocol discovers dependencies as it goes, + // it's not possible to get an accurate progress indication. + // + // As an approximation, we assume that the depth of the dependency graph + // is fixed, and base the progress on how many times the caller has asked + // for blocking. If there are actually additional dependencies, the progress + // bar will get stuck. If there are fewer dependencies, it will disappear + // early. It will never go backwards. + // + // The status text also contains the number of completed & pending requests, which + // gives an better indication of forward progress. + let approximate_tree_depth = 10; + progress.tick( - self.downloads_finished, - self.downloads_finished + self.pending.len(), - "", + self.blocking_calls.min(approximate_tree_depth), + approximate_tree_depth + 1, + &format!( + " {} complete; {} pending", + self.downloads_finished, + self.pending.len() + ), ) } } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/registry/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/registry/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/registry/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/registry/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -176,7 +176,7 @@ use crate::core::dependency::{DepKind, Dependency}; use crate::core::source::MaybePackage; -use crate::core::{Package, PackageId, Source, SourceId, Summary}; +use crate::core::{Package, PackageId, QueryKind, Source, SourceId, Summary}; use crate::sources::PathSource; use crate::util::hex; use crate::util::interning::InternedString; @@ -701,12 +701,18 @@ } impl<'cfg> Source for RegistrySource<'cfg> { - fn query(&mut self, dep: &Dependency, f: &mut dyn FnMut(Summary)) -> Poll> { + fn query( + &mut self, + dep: &Dependency, + kind: QueryKind, + f: &mut dyn FnMut(Summary), + ) -> Poll> { // If this is a precise dependency, then it came from a lock file and in // theory the registry is known to contain this version. If, however, we // come back with no summaries, then our registry may need to be // updated, so we fall back to performing a lazy update. - if dep.source_id().precise().is_some() && !self.ops.is_updated() { + if kind == QueryKind::Exact && dep.source_id().precise().is_some() && !self.ops.is_updated() + { debug!("attempting query without update"); let mut called = false; let pend = @@ -731,21 +737,16 @@ self.index .query_inner(dep, &mut *self.ops, &self.yanked_whitelist, &mut |s| { - if dep.matches(&s) { + let matched = match kind { + QueryKind::Exact => dep.matches(&s), + QueryKind::Fuzzy => true, + }; + if matched { f(s); } }) } - fn fuzzy_query( - &mut self, - dep: &Dependency, - f: &mut dyn FnMut(Summary), - ) -> Poll> { - self.index - .query_inner(dep, &mut *self.ops, &self.yanked_whitelist, f) - } - fn supports_checksums(&self) -> bool { true } @@ -801,14 +802,8 @@ self.yanked_whitelist.extend(pkgs); } - fn is_yanked(&mut self, pkg: PackageId) -> CargoResult { - self.invalidate_cache(); - loop { - match self.index.is_yanked(pkg, &mut *self.ops)? { - Poll::Ready(yanked) => return Ok(yanked), - Poll::Pending => self.block_until_ready()?, - } - } + fn is_yanked(&mut self, pkg: PackageId) -> Poll> { + self.index.is_yanked(pkg, &mut *self.ops) } fn block_until_ready(&mut self) -> CargoResult<()> { diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/registry/remote.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/registry/remote.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/registry/remote.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/registry/remote.rs 2022-10-20 06:00:42.000000000 +0000 @@ -163,10 +163,9 @@ // Older versions of Cargo used the single value of the hash of the HEAD commit as a `index_version`. // This is technically correct but a little too conservative. If a new commit is fetched all cached // files need to be regenerated even if a particular file was not changed. - // Cargo now reads the `index_version` in two parts the cache file is considered valid if `index_version` - // ends with the hash of the HEAD commit OR if it starts with the hash of the file's contents. - // In the future cargo can write cached files with `index_version` = `git_file_hash + ":" + `git_commit_hash`, - // but for now it still uses `git_commit_hash` to be compatible with older Cargoes. + // However if an old cargo has written such a file we still know how to read it, as long as we check for that hash value. + // + // Cargo now uses a hash of the file's contents as provided by git. fn load( &mut self, _root: &Path, @@ -178,10 +177,9 @@ } // Check if the cache is valid. let git_commit_hash = self.current_version(); - if let (Some(c), Some(i)) = (git_commit_hash, index_version) { - if i.ends_with(c.as_str()) { - return Poll::Ready(Ok(LoadResponse::CacheValid)); - } + if index_version.is_some() && index_version == git_commit_hash.as_deref() { + // This file was written by an old version of cargo, but it is still up-to-date. + return Poll::Ready(Ok(LoadResponse::CacheValid)); } // Note that the index calls this method and the filesystem is locked // in the index, so we don't need to worry about an `update_index` @@ -190,18 +188,16 @@ registry: &RemoteRegistry<'_>, path: &Path, index_version: Option<&str>, - git_commit_hash: Option<&str>, ) -> CargoResult { let repo = registry.repo()?; let tree = registry.tree()?; let entry = tree.get_path(path); let entry = entry?; - let git_file_hash = entry.id().to_string(); + let git_file_hash = Some(entry.id().to_string()); - if let Some(i) = index_version { - if i.starts_with(git_file_hash.as_str()) { - return Ok(LoadResponse::CacheValid); - } + // Check if the cache is valid. + if index_version.is_some() && index_version == git_file_hash.as_deref() { + return Ok(LoadResponse::CacheValid); } let object = entry.to_object(repo)?; @@ -212,13 +208,11 @@ Ok(LoadResponse::Data { raw_data: blob.content().to_vec(), - index_version: git_commit_hash.map(String::from), - // TODO: When the reading code has been stable for long enough (Say 8/2022) - // change to `git_file_hash + ":" + git_commit_hash` + index_version: git_file_hash, }) } - match load_helper(&self, path, index_version, git_commit_hash.as_deref()) { + match load_helper(&self, path, index_version) { Ok(result) => Poll::Ready(Ok(result)), Err(_) if !self.updated => { // If git returns an error and we haven't updated the repo, return diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/replaced.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/replaced.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/sources/replaced.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/sources/replaced.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,5 @@ use crate::core::source::MaybePackage; -use crate::core::{Dependency, Package, PackageId, Source, SourceId, Summary}; +use crate::core::{Dependency, Package, PackageId, QueryKind, Source, SourceId, Summary}; use crate::util::errors::CargoResult; use std::task::Poll; @@ -42,32 +42,17 @@ self.inner.requires_precise() } - fn query(&mut self, dep: &Dependency, f: &mut dyn FnMut(Summary)) -> Poll> { - let (replace_with, to_replace) = (self.replace_with, self.to_replace); - let dep = dep.clone().map_source(to_replace, replace_with); - - self.inner - .query(&dep, &mut |summary| { - f(summary.map_source(replace_with, to_replace)) - }) - .map_err(|e| { - e.context(format!( - "failed to query replaced source {}", - self.to_replace - )) - }) - } - - fn fuzzy_query( + fn query( &mut self, dep: &Dependency, + kind: QueryKind, f: &mut dyn FnMut(Summary), ) -> Poll> { let (replace_with, to_replace) = (self.replace_with, self.to_replace); let dep = dep.clone().map_source(to_replace, replace_with); self.inner - .fuzzy_query(&dep, &mut |summary| { + .query(&dep, kind, &mut |summary| { f(summary.map_source(replace_with, to_replace)) }) .map_err(|e| { @@ -134,7 +119,7 @@ self.inner.add_to_yanked_whitelist(&pkgs); } - fn is_yanked(&mut self, pkg: PackageId) -> CargoResult { + fn is_yanked(&mut self, pkg: PackageId) -> Poll> { self.inner.is_yanked(pkg) } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/util/command_prelude.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/command_prelude.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/util/command_prelude.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/command_prelude.rs 2022-10-20 06:00:42.000000000 +0000 @@ -69,7 +69,8 @@ self._arg( opt("jobs", "Number of parallel jobs, defaults to # of CPUs") .short('j') - .value_name("N"), + .value_name("N") + .allow_hyphen_values(true), ) ._arg(flag( "keep-going", @@ -326,6 +327,19 @@ Ok(arg) } + fn value_of_i32(&self, name: &str) -> CargoResult> { + let arg = match self._value_of(name) { + None => None, + Some(arg) => Some(arg.parse::().map_err(|_| { + clap::Error::raw( + clap::ErrorKind::ValueValidation, + format!("Invalid value: could not parse `{}` as a number", arg), + ) + })?), + }; + Ok(arg) + } + /// Returns value of the `name` command-line argument as an absolute path fn value_of_path(&self, name: &str, config: &Config) -> Option { self._value_of(name).map(|path| config.cwd().join(path)) @@ -359,8 +373,8 @@ Ok(ws) } - fn jobs(&self) -> CargoResult> { - self.value_of_u32("jobs") + fn jobs(&self) -> CargoResult> { + self.value_of_i32("jobs") } fn verbose(&self) -> u32 { diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/util/config/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/config/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/util/config/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/config/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -68,7 +68,7 @@ use self::ConfigValue as CV; use crate::core::compiler::rustdoc::RustdocExternMap; use crate::core::shell::Verbosity; -use crate::core::{features, CliUnstable, Shell, SourceId, Workspace}; +use crate::core::{features, CliUnstable, Shell, SourceId, Workspace, WorkspaceRootConfig}; use crate::ops; use crate::util::errors::CargoResult; use crate::util::toml as cargo_toml; @@ -202,6 +202,8 @@ /// NOTE: this should be set before `configure()`. If calling this from an integration test, /// consider using `ConfigBuilder::enable_nightly_features` instead. pub nightly_features_allowed: bool, + /// WorkspaceRootConfigs that have been found + pub ws_roots: RefCell>, } impl Config { @@ -285,6 +287,7 @@ progress_config: ProgressConfig::default(), env_config: LazyCell::new(), nightly_features_allowed: matches!(&*features::channel(), "nightly" | "dev"), + ws_roots: RefCell::new(HashMap::new()), } } @@ -2192,7 +2195,7 @@ pub target_dir: Option, pub incremental: Option, pub target: Option, - pub jobs: Option, + pub jobs: Option, pub rustflags: Option, pub rustdocflags: Option, pub rustc_wrapper: Option, @@ -2245,13 +2248,7 @@ }; let values = match &self.inner.val { BuildTargetConfigInner::One(s) => vec![map(s)], - BuildTargetConfigInner::Many(v) => { - if !config.cli_unstable().multitarget { - bail!("specifying an array in `build.target` config value requires `-Zmultitarget`") - } else { - v.iter().map(map).collect() - } - } + BuildTargetConfigInner::Many(v) => v.iter().map(map).collect(), }; Ok(values) } diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/util/dependency_queue.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/dependency_queue.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/util/dependency_queue.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/dependency_queue.rs 2022-10-20 06:00:42.000000000 +0000 @@ -149,15 +149,15 @@ /// /// A package is ready to be built when it has 0 un-built dependencies. If /// `None` is returned then no packages are ready to be built. - pub fn dequeue(&mut self) -> Option<(N, V)> { - let key = self + pub fn dequeue(&mut self) -> Option<(N, V, usize)> { + let (key, priority) = self .dep_map .iter() .filter(|(_, (deps, _))| deps.is_empty()) - .map(|(key, _)| key.clone()) - .max_by_key(|k| self.priority[k])?; + .map(|(key, _)| (key.clone(), self.priority[key])) + .max_by_key(|(_, priority)| *priority)?; let (_, data) = self.dep_map.remove(&key).unwrap(); - Some((key, data)) + Some((key, data, priority)) } /// Returns `true` if there are remaining packages to be built. @@ -213,19 +213,19 @@ q.queue(5, (), vec![(4, ()), (3, ())], 1); q.queue_finished(); - assert_eq!(q.dequeue(), Some((1, ()))); - assert_eq!(q.dequeue(), Some((3, ()))); + assert_eq!(q.dequeue(), Some((1, (), 5))); + assert_eq!(q.dequeue(), Some((3, (), 4))); assert_eq!(q.dequeue(), None); q.finish(&3, &()); assert_eq!(q.dequeue(), None); q.finish(&1, &()); - assert_eq!(q.dequeue(), Some((2, ()))); + assert_eq!(q.dequeue(), Some((2, (), 4))); assert_eq!(q.dequeue(), None); q.finish(&2, &()); - assert_eq!(q.dequeue(), Some((4, ()))); + assert_eq!(q.dequeue(), Some((4, (), 3))); assert_eq!(q.dequeue(), None); q.finish(&4, &()); - assert_eq!(q.dequeue(), Some((5, ()))); + assert_eq!(q.dequeue(), Some((5, (), 2))); } #[test] @@ -238,16 +238,16 @@ q.queue(4, (), vec![(2, ()), (3, ())], 1); q.queue_finished(); - assert_eq!(q.dequeue(), Some((3, ()))); - assert_eq!(q.dequeue(), Some((1, ()))); + assert_eq!(q.dequeue(), Some((3, (), 9))); + assert_eq!(q.dequeue(), Some((1, (), 4))); assert_eq!(q.dequeue(), None); q.finish(&3, &()); assert_eq!(q.dequeue(), None); q.finish(&1, &()); - assert_eq!(q.dequeue(), Some((2, ()))); + assert_eq!(q.dequeue(), Some((2, (), 3))); assert_eq!(q.dequeue(), None); q.finish(&2, &()); - assert_eq!(q.dequeue(), Some((4, ()))); + assert_eq!(q.dequeue(), Some((4, (), 2))); assert_eq!(q.dequeue(), None); q.finish(&4, &()); assert_eq!(q.dequeue(), None); diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/util/errors.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/errors.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/util/errors.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/errors.rs 2022-10-20 06:00:42.000000000 +0000 @@ -1,9 +1,6 @@ #![allow(unknown_lints)] -use crate::core::{TargetKind, Workspace}; -use crate::ops::CompileOptions; use anyhow::Error; -use cargo_util::ProcessError; use std::fmt; use std::path::PathBuf; @@ -198,91 +195,6 @@ impl<'a> ::std::iter::FusedIterator for ManifestCauses<'a> {} // ============================================================================= -// Cargo test errors. - -/// Error when testcases fail -#[derive(Debug)] -pub struct CargoTestError { - pub test: Test, - pub desc: String, - pub code: Option, - pub causes: Vec, -} - -impl fmt::Display for CargoTestError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.desc.fmt(f) - } -} - -impl std::error::Error for CargoTestError {} - -#[derive(Debug)] -pub enum Test { - Multiple, - Doc, - UnitTest { - kind: TargetKind, - name: String, - pkg_name: String, - }, -} - -impl CargoTestError { - pub fn new(test: Test, errors: Vec) -> Self { - if errors.is_empty() { - panic!("Cannot create CargoTestError from empty Vec") - } - let desc = errors - .iter() - .map(|error| error.desc.clone()) - .collect::>() - .join("\n"); - CargoTestError { - test, - desc, - code: errors[0].code, - causes: errors, - } - } - - pub fn hint(&self, ws: &Workspace<'_>, opts: &CompileOptions) -> String { - match self.test { - Test::UnitTest { - ref kind, - ref name, - ref pkg_name, - } => { - let pkg_info = if opts.spec.needs_spec_flag(ws) { - format!("-p {} ", pkg_name) - } else { - String::new() - }; - - match *kind { - TargetKind::Bench => { - format!("test failed, to rerun pass '{}--bench {}'", pkg_info, name) - } - TargetKind::Bin => { - format!("test failed, to rerun pass '{}--bin {}'", pkg_info, name) - } - TargetKind::Lib(_) => format!("test failed, to rerun pass '{}--lib'", pkg_info), - TargetKind::Test => { - format!("test failed, to rerun pass '{}--test {}'", pkg_info, name) - } - TargetKind::ExampleBin | TargetKind::ExampleLib(_) => { - format!("test failed, to rerun pass '{}--example {}", pkg_info, name) - } - _ => "test failed.".into(), - } - } - Test::Doc => "test failed, to rerun pass '--doc'".into(), - _ => "test failed.".into(), - } - } -} - -// ============================================================================= // CLI errors pub type CliResult = Result<(), CliError>; diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/util/flock.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/flock.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/util/flock.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/flock.rs 2022-10-20 06:00:42.000000000 +0000 @@ -378,7 +378,6 @@ // 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.64.0ubuntu0.libgit2/src/cargo/util/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/util/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -6,8 +6,8 @@ pub(crate) use self::counter::MetricsCounter; pub use self::dependency_queue::DependencyQueue; pub use self::diagnostic_server::RustfixDiagnosticServer; -pub use self::errors::{internal, CargoResult, CliResult, Test}; -pub use self::errors::{CargoTestError, CliError}; +pub use self::errors::CliError; +pub use self::errors::{internal, CargoResult, CliResult}; pub use self::flock::{FileLock, Filesystem}; pub use self::graph::Graph; pub use self::hasher::StableHasher; diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/util/progress.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/progress.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/util/progress.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/progress.rs 2022-10-20 06:00:42.000000000 +0000 @@ -15,6 +15,7 @@ pub enum ProgressStyle { Percentage, Ratio, + Indeterminate, } struct Throttle { @@ -253,6 +254,7 @@ let stats = match self.style { ProgressStyle::Percentage => format!(" {:6.02}%", pct * 100.0), ProgressStyle::Ratio => format!(" {}/{}", cur, max), + ProgressStyle::Indeterminate => String::new(), }; let extra_len = stats.len() + 2 /* [ and ] */ + 15 /* status header */; let display_width = match self.width().checked_sub(extra_len) { diff -Nru cargo-0.64.0ubuntu0.libgit2/src/cargo/util/toml/mod.rs cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/toml/mod.rs --- cargo-0.64.0ubuntu0.libgit2/src/cargo/util/toml/mod.rs 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/cargo/util/toml/mod.rs 2022-10-20 06:00:42.000000000 +0000 @@ -3,7 +3,7 @@ use std::marker::PhantomData; use std::path::{Path, PathBuf}; use std::rc::Rc; -use std::str; +use std::str::{self, FromStr}; use anyhow::{anyhow, bail, Context as _}; use cargo_platform::Platform; @@ -381,7 +381,7 @@ package: Option, public: Option, - /// One ore more of 'bin', 'cdylib', 'staticlib', 'bin:'. + /// One or more of `bin`, `cdylib`, `staticlib`, `bin:`. artifact: Option, /// If set, the artifact should also be a dependency lib: Option, @@ -1017,19 +1017,16 @@ impl MaybeWorkspace { fn resolve<'a>( self, - cargo_features: &Features, label: &str, get_ws_field: impl FnOnce() -> CargoResult, ) -> CargoResult { match self { MaybeWorkspace::Defined(value) => Ok(value), - MaybeWorkspace::Workspace(TomlWorkspaceField { workspace: true }) => { - cargo_features.require(Feature::workspace_inheritance())?; - get_ws_field().context(format!( + MaybeWorkspace::Workspace(TomlWorkspaceField { workspace: true }) => get_ws_field() + .context(format!( "error inheriting `{}` from workspace root manifest's `workspace.package.{}`", label, label - )) - } + )), MaybeWorkspace::Workspace(TomlWorkspaceField { workspace: false }) => Err(anyhow!( "`workspace=false` is unsupported for `package.{}`", label, @@ -1044,6 +1041,43 @@ } } +fn maybe_workspace_vec_string<'de, D>( + deserializer: D, +) -> Result>>, D::Error> +where + D: de::Deserializer<'de>, +{ + struct Visitor; + + impl<'de> de::Visitor<'de> for Visitor { + type Value = Option>>; + + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + formatter.write_str("vector of strings") + } + + fn visit_seq(self, v: V) -> Result + where + V: de::SeqAccess<'de>, + { + let seq = de::value::SeqAccessDeserializer::new(v); + let defined = Vec::::deserialize(seq).map(MaybeWorkspace::Defined)?; + Ok(Some(defined)) + } + + fn visit_map(self, map: V) -> Result + where + V: de::MapAccess<'de>, + { + let mvd = de::value::MapAccessDeserializer::new(map); + let workspace = TomlWorkspaceField::deserialize(mvd).map(MaybeWorkspace::Workspace)?; + Ok(Some(workspace)) + } + } + + deserializer.deserialize_any(Visitor) +} + #[derive(Deserialize, Serialize, Clone, Debug)] pub struct TomlWorkspaceField { workspace: bool, @@ -1063,6 +1097,8 @@ name: InternedString, #[serde(deserialize_with = "version_trim_whitespace")] version: MaybeWorkspace, + #[serde(default)] + #[serde(deserialize_with = "maybe_workspace_vec_string")] authors: Option>>, build: Option, metabuild: Option, @@ -1071,7 +1107,11 @@ #[serde(rename = "forced-target")] forced_target: Option, links: Option, + #[serde(default)] + #[serde(deserialize_with = "maybe_workspace_vec_string")] exclude: Option>>, + #[serde(default)] + #[serde(deserialize_with = "maybe_workspace_vec_string")] include: Option>>, publish: Option>, workspace: Option, @@ -1087,7 +1127,11 @@ homepage: Option>, documentation: Option>, readme: Option>, + #[serde(default)] + #[serde(deserialize_with = "maybe_workspace_vec_string")] keywords: Option>>, + #[serde(default)] + #[serde(deserialize_with = "maybe_workspace_vec_string")] categories: Option>>, license: Option>, license_file: Option>, @@ -1345,7 +1389,26 @@ .unwrap() .clone(); package.workspace = None; - package.resolver = ws.resolve_behavior().to_manifest(); + let current_resolver = package + .resolver + .as_ref() + .map(|r| ResolveBehavior::from_manifest(r)) + .unwrap_or_else(|| { + package + .edition + .as_ref() + .and_then(|e| e.as_defined()) + .map(|e| Edition::from_str(e)) + .unwrap_or(Ok(Edition::Edition2015)) + .map(|e| e.default_resolve_behavior()) + })?; + if ws.resolve_behavior() != current_resolver { + // This ensures the published crate if built as a root (e.g. `cargo install`) will + // use the same resolver behavior it was tested with in the workspace. + // To avoid forcing a higher MSRV we don't explicitly set this if it would implicitly + // result in the same thing. + package.resolver = Some(ws.resolve_behavior().to_manifest()); + } if let Some(license_file) = &package.license_file { let license_file = license_file .as_defined() @@ -1549,18 +1612,23 @@ let project = &mut project.ok_or_else(|| anyhow!("no `package` section found"))?; let workspace_config = match (me.workspace.as_ref(), project.workspace.as_ref()) { - (Some(config), None) => { - let mut inheritable = config.package.clone().unwrap_or_default(); + (Some(toml_config), None) => { + let mut inheritable = toml_config.package.clone().unwrap_or_default(); inheritable.update_ws_path(package_root.to_path_buf()); - inheritable.update_deps(config.dependencies.clone()); - WorkspaceConfig::Root(WorkspaceRootConfig::new( + inheritable.update_deps(toml_config.dependencies.clone()); + let ws_root_config = WorkspaceRootConfig::new( package_root, - &config.members, - &config.default_members, - &config.exclude, + &toml_config.members, + &toml_config.default_members, + &toml_config.exclude, &Some(inheritable), - &config.metadata, - )) + &toml_config.metadata, + ); + config + .ws_roots + .borrow_mut() + .insert(package_root.to_path_buf(), ws_root_config.clone()); + WorkspaceConfig::Root(ws_root_config) } (None, root) => WorkspaceConfig::Member { root: root.cloned(), @@ -1587,7 +1655,7 @@ let version = project .version .clone() - .resolve(&features, "version", || inherit()?.version())?; + .resolve("version", || inherit()?.version())?; project.version = MaybeWorkspace::Defined(version.clone()); @@ -1595,7 +1663,7 @@ let edition = if let Some(edition) = project.edition.clone() { let edition: Edition = edition - .resolve(&features, "edition", || inherit()?.edition())? + .resolve("edition", || inherit()?.edition())? .parse() .with_context(|| "failed to parse the `edition` key")?; project.edition = Some(MaybeWorkspace::Defined(edition.to_string())); @@ -1620,7 +1688,7 @@ let rust_version = if let Some(rust_version) = &project.rust_version { let rust_version = rust_version .clone() - .resolve(&features, "rust_version", || inherit()?.rust_version())?; + .resolve("rust_version", || inherit()?.rust_version())?; let req = match semver::VersionReq::parse(&rust_version) { // Exclude semver operators like `^` and pre-release identifiers Ok(req) if rust_version.chars().all(|c| c.is_ascii_digit() || c == '.') => req, @@ -1711,7 +1779,6 @@ }; fn process_dependencies( - features: &Features, cx: &mut Context<'_, '_>, new_deps: Option<&BTreeMap>, kind: Option, @@ -1731,7 +1798,7 @@ let mut deps: BTreeMap = BTreeMap::new(); for (n, v) in dependencies.iter() { - let resolved = v.clone().resolve(features, n, cx, || inherit())?; + let resolved = v.clone().resolve(n, cx, || inherit())?; let dep = resolved.to_dependency(n, cx, kind)?; validate_package_name(dep.name_in_toml().as_str(), "dependency name", "")?; cx.deps.push(dep); @@ -1742,7 +1809,6 @@ // Collect the dependencies. let dependencies = process_dependencies( - &features, &mut cx, me.dependencies.as_ref(), None, @@ -1757,7 +1823,6 @@ .as_ref() .or_else(|| me.dev_dependencies2.as_ref()); let dev_deps = process_dependencies( - &features, &mut cx, dev_deps, Some(DepKind::Development), @@ -1772,7 +1837,6 @@ .as_ref() .or_else(|| me.build_dependencies2.as_ref()); let build_deps = process_dependencies( - &features, &mut cx, build_deps, Some(DepKind::Build), @@ -1788,7 +1852,6 @@ Some(platform) }; let deps = process_dependencies( - &features, &mut cx, platform.dependencies.as_ref(), None, @@ -1804,7 +1867,6 @@ .as_ref() .or_else(|| platform.build_dependencies2.as_ref()); let build_deps = process_dependencies( - &features, &mut cx, build_deps, Some(DepKind::Build), @@ -1820,7 +1882,6 @@ .as_ref() .or_else(|| platform.dev_dependencies2.as_ref()); let dev_deps = process_dependencies( - &features, &mut cx, dev_deps, Some(DepKind::Development), @@ -1867,13 +1928,13 @@ let exclude = project .exclude .clone() - .map(|mw| mw.resolve(&features, "exclude", || inherit()?.exclude())) + .map(|mw| mw.resolve("exclude", || inherit()?.exclude())) .transpose()? .unwrap_or_default(); let include = project .include .clone() - .map(|mw| mw.resolve(&features, "include", || inherit()?.include())) + .map(|mw| mw.resolve("include", || inherit()?.include())) .transpose()? .unwrap_or_default(); let empty_features = BTreeMap::new(); @@ -1890,67 +1951,63 @@ description: project .description .clone() - .map(|mw| mw.resolve(&features, "description", || inherit()?.description())) + .map(|mw| mw.resolve("description", || inherit()?.description())) .transpose()?, homepage: project .homepage .clone() - .map(|mw| mw.resolve(&features, "homepage", || inherit()?.homepage())) + .map(|mw| mw.resolve("homepage", || inherit()?.homepage())) .transpose()?, documentation: project .documentation .clone() - .map(|mw| mw.resolve(&features, "documentation", || inherit()?.documentation())) + .map(|mw| mw.resolve("documentation", || inherit()?.documentation())) .transpose()?, readme: readme_for_project( package_root, project .readme .clone() - .map(|mw| mw.resolve(&features, "readme", || inherit()?.readme(package_root))) + .map(|mw| mw.resolve("readme", || inherit()?.readme(package_root))) .transpose()?, ), authors: project .authors .clone() - .map(|mw| mw.resolve(&features, "authors", || inherit()?.authors())) + .map(|mw| mw.resolve("authors", || inherit()?.authors())) .transpose()? .unwrap_or_default(), license: project .license .clone() - .map(|mw| mw.resolve(&features, "license", || inherit()?.license())) + .map(|mw| mw.resolve("license", || inherit()?.license())) .transpose()?, license_file: project .license_file .clone() - .map(|mw| { - mw.resolve(&features, "license", || { - inherit()?.license_file(package_root) - }) - }) + .map(|mw| mw.resolve("license", || inherit()?.license_file(package_root))) .transpose()?, repository: project .repository .clone() - .map(|mw| mw.resolve(&features, "repository", || inherit()?.repository())) + .map(|mw| mw.resolve("repository", || inherit()?.repository())) .transpose()?, keywords: project .keywords .clone() - .map(|mw| mw.resolve(&features, "keywords", || inherit()?.keywords())) + .map(|mw| mw.resolve("keywords", || inherit()?.keywords())) .transpose()? .unwrap_or_default(), categories: project .categories .clone() - .map(|mw| mw.resolve(&features, "categories", || inherit()?.categories())) + .map(|mw| mw.resolve("categories", || inherit()?.categories())) .transpose()? .unwrap_or_default(), badges: me .badges .clone() - .map(|mw| mw.resolve(&features, "badges", || inherit()?.badges())) + .map(|mw| mw.resolve("badges", || inherit()?.badges())) .transpose()? .unwrap_or_default(), links: project.links.clone(), @@ -2010,11 +2067,10 @@ profiles.validate(&features, &mut warnings)?; } - let publish = project.publish.clone().map(|publish| { - publish - .resolve(&features, "publish", || inherit()?.publish()) - .unwrap() - }); + let publish = project + .publish + .clone() + .map(|publish| publish.resolve("publish", || inherit()?.publish()).unwrap()); project.publish = publish.clone().map(|p| MaybeWorkspace::Defined(p)); @@ -2206,18 +2262,23 @@ .map(|r| ResolveBehavior::from_manifest(r)) .transpose()?; let workspace_config = match me.workspace { - Some(ref config) => { - let mut inheritable = config.package.clone().unwrap_or_default(); + Some(ref toml_config) => { + let mut inheritable = toml_config.package.clone().unwrap_or_default(); inheritable.update_ws_path(root.to_path_buf()); - inheritable.update_deps(config.dependencies.clone()); - WorkspaceConfig::Root(WorkspaceRootConfig::new( + inheritable.update_deps(toml_config.dependencies.clone()); + let ws_root_config = WorkspaceRootConfig::new( root, - &config.members, - &config.default_members, - &config.exclude, + &toml_config.members, + &toml_config.default_members, + &toml_config.exclude, &Some(inheritable), - &config.metadata, - )) + &toml_config.metadata, + ); + config + .ws_roots + .borrow_mut() + .insert(root.to_path_buf(), ws_root_config.clone()); + WorkspaceConfig::Root(ws_root_config) } None => { bail!("virtual manifests must be configured with [workspace]"); @@ -2334,16 +2395,30 @@ fn inheritable_from_path( config: &Config, - resolved_path: PathBuf, + workspace_path: PathBuf, ) -> CargoResult { - let key = resolved_path.parent().unwrap(); - let source_id = SourceId::for_path(key)?; - let (man, _) = read_manifest(&resolved_path, source_id, config)?; + // Workspace path should have Cargo.toml at the end + let workspace_path_root = workspace_path.parent().unwrap(); + + // Let the borrow exit scope so that it can be picked up if there is a need to + // read a manifest + if let Some(ws_root) = config.ws_roots.borrow().get(workspace_path_root) { + return Ok(ws_root.inheritable().clone()); + }; + + let source_id = SourceId::for_path(workspace_path_root)?; + let (man, _) = read_manifest(&workspace_path, source_id, config)?; match man.workspace_config() { - WorkspaceConfig::Root(root) => Ok(root.inheritable().clone()), + WorkspaceConfig::Root(root) => { + config + .ws_roots + .borrow_mut() + .insert(workspace_path, root.clone()); + Ok(root.inheritable().clone()) + } _ => bail!( "root of a workspace inferred but wasn't a root: {}", - resolved_path.display() + workspace_path.display() ), } } @@ -2455,7 +2530,6 @@ impl TomlDependency { fn resolve<'a>( self, - cargo_features: &Features, label: &str, cx: &mut Context<'_, '_>, get_inheritable: impl FnOnce() -> CargoResult<&'a InheritableFields>, @@ -2468,7 +2542,6 @@ features, optional, }) => { - cargo_features.require(Feature::workspace_inheritance())?; let inheritable = get_inheritable()?; inheritable.get_dependency(label).context(format!( "error reading `dependencies.{}` from workspace root manifest's `workspace.dependencies.{}`", diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/contrib/src/process/release.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/contrib/src/process/release.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/contrib/src/process/release.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/contrib/src/process/release.md 2022-10-20 06:00:42.000000000 +0000 @@ -28,6 +28,46 @@ [`dist` bootstrap module]: https://github.com/rust-lang/rust/blob/master/src/bootstrap/dist.rs +## Submodule updates + +Cargo is tracked in the [rust-lang/rust] repository using a [git submodule]. +It is updated manually about once a week by a Cargo team member. +However, anyone is welcome to update it as needed. + +[@ehuss] has a tool called [subup](https://github.com/ehuss/subup) to automate the process of updating the submodule, updating the lockfile, running tests, and creating a PR. +Running the tests ahead-of-time helps avoid long cycle times waiting for bors if there are any errors. +Subup will also provide a message to include in the PR with a list of all PRs it covers. +Posting this in the PR message also helps create reference links on each Cargo PR to the submodule update PR to help track when it gets merged. + +The following is an example of the command to run in a local clone of rust-lang/rust to run a certain set of tests of things that are likely to get broken by a Cargo update: + +```bash +subup --up-branch update-cargo \ + --commit-message "Update cargo" \ + --test="src/tools/linkchecker tidy \ + src/tools/cargo \ + src/tools/rustfmt \ + src/tools/rls" \ + src/tools/cargo +``` + +If doing a [beta backport](#beta-backports), the command is similar, but needs to point to the correct branches: + +```bash +subup --up-branch update-beta-cargo \ + --rust-branch beta \ + --set-config rust.channel=beta \ + --commit-message "[beta] Update cargo" \ + --test="src/tools/linkchecker tidy \ + src/tools/cargo \ + src/tools/rustfmt \ + src/tools/rls" \ + rust-1.63.0:src/tools/cargo +``` + +[@ehuss]: https://github.com/ehuss/ +[git submodule]: https://git-scm.com/book/en/v2/Git-Tools-Submodules + ## Version updates Shortly after each major release, a Cargo team member will post a PR to update @@ -53,6 +93,23 @@ avoid churning incompatible version numbers. This process should be improved in the future! +[@ehuss] has a tool called [cargo-new-release] to automate the process of doing a version bump. +It runs through several steps: +1. Creates a branch +2. Updates the version numbers +3. Creates a changelog for anything on the master branch that is not part of beta +4. Creates a changelog for anything on the beta branch + +It opens a browser tab for every PR in order to review each change. +It places each PR in the changelog with its title, but usually every PR should be rewritten to explain the change from the user's perspective. +Each PR should also be categorized as an Addition, Change, Fix, or Nightly-only change. +Most PRs are deleted, since they are not relevant to users of Cargo. +For example, remove all PRs related to Cargo internals, infrastructure, documentation, error changes, refactorings, etc. +Usually about half of the PRs get removed. +This process usually takes @ehuss about an hour to finish. + +[@ehuss]: https://github.com/ehuss/ +[cargo-new-release]: https://github.com/ehuss/cargo-new-release [`crates/` directory]: https://github.com/rust-lang/cargo/tree/master/crates ## Docs publishing diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/contrib/src/process/working-on-cargo.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/contrib/src/process/working-on-cargo.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/contrib/src/process/working-on-cargo.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/contrib/src/process/working-on-cargo.md 2022-10-20 06:00:42.000000000 +0000 @@ -122,6 +122,21 @@ The reviewer might point out changes deemed necessary. Large or tricky changes may require several passes of review and changes. +### Status labeling + +PRs will get marked with [labels] like [`S-waiting-on-review`] or [`S-waiting-on-author`] to indicate their status. +The [`@rustbot`] bot can be used by anyone to adjust the labels. +If a PR gets marked as `S-waiting-on-author`, and you have pushed new changes that you would like to be reviewed, you can write a comment on the PR with the text `@rustbot ready`. +The bot will switch the labels on the PR. + +More information about these commands can be found at the [shortcuts documentation]. + +[labels]: https://github.com/rust-lang/cargo/labels +[`S-waiting-on-review`]: https://github.com/rust-lang/cargo/labels/S-waiting-on-review +[`S-waiting-on-author`]: https://github.com/rust-lang/cargo/labels/S-waiting-on-author +[`@rustbot`]: https://github.com/rustbot +[shortcuts documentation]: https://github.com/rust-lang/triagebot/wiki/Shortcuts + ## The merging process After a reviewer has approved your PR, they will issue a command to the [bors] diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/contrib/src/SUMMARY.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/contrib/src/SUMMARY.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/contrib/src/SUMMARY.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/contrib/src/SUMMARY.md 2022-10-20 06:00:42.000000000 +0000 @@ -17,4 +17,5 @@ - [Running Tests](./tests/running.md) - [Writing Tests](./tests/writing.md) - [Benchmarking and Profiling](./tests/profiling.md) + - [Crater](./tests/crater.md) - [Design Principles](./design.md) diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/contrib/src/tests/crater.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/contrib/src/tests/crater.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/contrib/src/tests/crater.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/contrib/src/tests/crater.md 2022-10-20 06:00:42.000000000 +0000 @@ -0,0 +1,122 @@ +# Crater + +[Crater](https://github.com/rust-lang/crater) is a tool for compiling and running tests for _every_ crate on [crates.io](https://crates.io) (and a few on GitHub). +It is mainly used for checking the extent of breakage when implementing potentially breaking changes and ensuring lack of breakage by running beta vs stable compiler versions. + +Essentially it runs some `cargo` command on every crate twice; once against the "start" toolchain and again against the "end" toolchain. +For example, "start" could be the stable release, and "end" could be beta. +If it passes in "start" but fails with "end", then that is reported as a regression. + +There is a bot called [craterbot] which is used to run crater on hardware managed by the rust-lang organization. + +Crater is run by the release team during the beta cycle. +If there are any regressions that look like they are caused by Cargo, they should contact the Cargo team to decide how to handle it. + +## Running crater + +If you have a change that you want to test before the beta release, or you want to test behavior that is not normally exercised by crater, you can do a manual run of crater. +Roughly the steps are: + +1. Create a branch with your changes. + + In your clone of cargo, make the changes to incorporate whatever new thing you want to test and push it to a branch on your fork on GitHub. + +2. Get a clone of + +3. Create a branch in your rust-lang/rust clone to add your changes. + +4. Change the `src/tools/cargo` submodule to point to your new branch. + + Modify `.gitmodules` to point to your clone and branch of cargo with the changes you want to test. + For example: + + ```bash + git submodule set-url src/tools/cargo https://github.com/ehuss/cargo.git + git submodule set-branch --branch my-awesome-feature src/tools/cargo + git submodule update --remote src/tools/cargo + git add .gitmodules src/tools/cargo + git commit + ``` + +5. Create an PR on rust-lang/rust. + + Push your submodule changes to GitHub and make a PR. + Start the PR title with `[EXPERIMENT]` to make it clear what the PR is for and assign yourself or @ghost. + +6. Make a "try" build. + + A "try" build creates a full release of x86_64-unknown-linux-gnu and stores it on rust-lang servers. + This can be done with a comment `@bors try` on the PR (all Cargo team members should have permission to do this). + +7. Run crater. + + Look at the [craterbot] docs to determine the command that you want to run. + There are different modes like `check-only`, `build-and-test`, `rustdoc`, etc. + + You can also choose how many crates to run against. + If you are uncertain if your cargo changes will work correctly, it might be a good idea to run against `top-100` first to check its behavior. + This will run much faster. + You can do a full run afterwards. + + After the try build finishes (which should take a couple hours), ask someone to make a crater run. + The Cargo team does not have that permission, so just ask someone on Zulip. + They will need to write a comment to `@craterbot` with the command that you have specified. + +8. Wait. + + Crater can take anywhere from a few hours to a few weeks to run depending on how long the [craterbot queue](https://crater.rust-lang.org/) is and which mode you picked and the priority of your job. + When the crater run finishes, craterbot will post a comment to the PR with a link to a report of the results. + +9. Investigate the report. + + Look through the report which contains links to build logs for any regressions or errors. + +10. Close the PR. + + Whenever you are done doing crater runs, close your PR. + +[craterbot]: https://github.com/rust-lang/crater/blob/master/docs/bot-usage.md + + +## Advanced crater modes + +Crater only has a few built-in modes, such as running `cargo check` or `cargo test`. +You can pass extra flags with `+cargoflags`. + +More complex tests can be accomplished by customizing Cargo to perform whatever actions you want. +Since crater essentially runs `cargo check`, you can modify the `check` command to perform whichever actions you want. +For example, to test `cargo fix --edition`, [this commit](https://github.com/ehuss/cargo/commit/6901690a6f8d519efb4fabf48c1c2b94af0c3bd8) intercepted `cargo check` and modified it to instead: + +1. Only run on crates with the 2018 edition. +2. Run `cargo fix --edition`. +3. Modify the manifest to switch to the 2021 edition. +4. Run `cargo check` to verify. + +If you need to compare the before and after of a command that is not part of crater's built-in modes, that can be more difficult. +Two possible options: + +* Work with the infra team to add a new mode. +* Build two custom try builds. + Each one should modify the `cargo check` command as described above. + The "start" build should perform whichever action you want with an otherwise unmodified cargo. + The "end" build should perform whichever action you want with your modified cargo. + Then, in the `@craterbot` command, specify the start and end hashes of the two try builds. + +## Limitations + +There are some limitations of crater to consider when running Cargo: + +* A crater run without regressions is not a green light to move forward. + * A large portion of Rust code is not tested, such as closed-source projects or things otherwise not collected by crater. + * Many crates can't build in crater's environment or are otherwise broken. + * Some crates have flaky tests. +* Crater runs in an isolated environment. + * It only runs on Linux x86-64. + * It does not have network access. + * The crate source is in a read-only mount. +* Crater does several steps before running the test (using its own copy of the stable toolchain): + * It generates a lockfile using `generate-lockfile` and includes `-Zno-index-update` to prevent index updates (which makes it run much faster). + * All dependencies are downloaded ahead-of-time with `cargo fetch`. +* The built-in modes pass several flags to cargo such as `--frozen` or `--message-format=json`. + It will sometimes use `--all-targets` and sometimes not. + Check the [crater source](https://github.com/rust-lang/crater/blob/master/src/runner/test.rs) for more details on how it works. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/contrib/src/tests/writing.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/contrib/src/tests/writing.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/contrib/src/tests/writing.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/contrib/src/tests/writing.md 2022-10-20 06:00:42.000000000 +0000 @@ -50,13 +50,7 @@ } ``` -`#[cargo_test]`: -- This is used in place of `#[test]` -- This attribute injects code which does some setup before starting the - test, creating a filesystem "sandbox" under the "cargo integration test" - directory for each test such as - `/path/to/cargo/target/cit/t123/` -- The sandbox will contain a `home` directory that will be used instead of your normal home directory +The [`#[cargo_test]` attribute](#cargo_test-attribute) is used in place of `#[test]` to inject some setup code. [`ProjectBuilder`] via `project()`: - Each project is in a separate directory in the sandbox @@ -68,27 +62,57 @@ - See [`support::compare`] for an explanation of the string pattern matching. Patterns are used to make it easier to match against the expected output. +#### `#[cargo_test]` attribute + +The `#[cargo_test]` attribute injects code which does some setup before starting the test. +It will create a filesystem "sandbox" under the "cargo integration test" directory for each test, such as `/path/to/cargo/target/tmp/cit/t123/`. +The sandbox will contain a `home` directory that will be used instead of your normal home directory. + +The `#[cargo_test]` attribute takes several options that will affect how the test is generated. +They are listed in parentheses separated with commas, such as: + +```rust,ignore +#[cargo_test(nightly, reason = "-Zfoo is unstable")] +``` + +The options it supports are: + +* `nightly` — This will cause the test to be ignored if not running on the nightly toolchain. + This is useful for tests that use unstable options in `rustc` or `rustdoc`. + These tests are run in Cargo's CI, but are disabled in rust-lang/rust's CI due to the difficulty of updating both repos simultaneously. + A `reason` field is required to explain why it is nightly-only. +* `build_std_real` — This is a "real" `-Zbuild-std` test (in the `build_std` integration test). + This only runs on nightly, and only if the environment variable `CARGO_RUN_BUILD_STD_TESTS` is set (these tests on run on Linux). +* `build_std_mock` — This is a "mock" `-Zbuild-std` test (which uses a mock standard library). + This only runs on nightly, and is disabled for windows-gnu. +* `requires_` — This indicates a command that is required to be installed to be run. + For example, `requires_rustfmt` means the test will only run if the executable `rustfmt` is installed. + These tests are *always* run on CI. + This is mainly used to avoid requiring contributors from having every dependency installed. +* `>=1.64` — This indicates that the test will only run with the given version of `rustc` or newer. + This can be used when a new `rustc` feature has been stabilized that the test depends on. + If this is specified, a `reason` is required to explain why it is being checked. + #### Testing Nightly Features If you are testing a Cargo feature that only works on "nightly" Cargo, then -you need to call `masquerade_as_nightly_cargo` on the process builder like -this: +you need to call `masquerade_as_nightly_cargo` on the process builder and pass +the name of the feature as the reason, like this: ```rust,ignore -p.cargo("build").masquerade_as_nightly_cargo() +p.cargo("build").masquerade_as_nightly_cargo(&["print-im-a-teapot"]) ``` If you are testing a feature that only works on *nightly rustc* (such as -benchmarks), then you should exit the test if it is not running with nightly -rust, like this: +benchmarks), then you should use the `nightly` option of the `cargo_test` +attribute, like this: ```rust,ignore -if !is_nightly() { - // Add a comment here explaining why this is necessary. - return; -} +#[cargo_test(nightly, reason = "-Zfoo is unstable")] ``` +This will cause the test to be ignored if not running on the nightly toolchain. + #### Specifying Dependencies You should not write any tests that use the network such as contacting @@ -129,7 +153,7 @@ `tests/testsuite///mod.rs`: ```rust,ignore use cargo_test_support::prelude::*; -use cargo_test_support::compare::assert; +use cargo_test_support::compare::assert_ui; use cargo_test_support::Project; use cargo_test_support::curr_dir; @@ -139,7 +163,7 @@ let project_root = project.root(); let cwd = &project_root; - snapbox::cmd::Command::cargo() + snapbox::cmd::Command::cargo_ui() .arg("run") .arg_line("--bin foo") .current_dir(cwd) @@ -148,7 +172,7 @@ .stdout_matches_path(curr_dir!().join("stdout.log")) .stderr_matches_path(curr_dir!().join("stderr.log")); - assert().subset_matches(curr_dir!().join("out"), &project_root); + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); } ``` @@ -170,13 +194,13 @@ - The project is copied from a directory in the repo - Each project is in a separate directory in the sandbox -[`Command`] via `Command::cargo()`: +[`Command`] via `Command::cargo_ui()`: - Set up and run a command. [`OutputAssert`] via `Command::assert()`: - Perform assertions on the result of the [`Command`] -[`Assert`] via `assert()`: +[`Assert`] via `assert_ui()`: - Verify the command modified the file system as expected #### Updating Snapshots @@ -192,25 +216,24 @@ #### Testing Nightly Features If you are testing a Cargo feature that only works on "nightly" Cargo, then -you need to call `masquerade_as_nightly_cargo` on the process builder like -this: +you need to call `masquerade_as_nightly_cargo` on the process builder and pass +the name of the feature as the reason, like this: ```rust,ignore snapbox::cmd::Command::cargo() - .masquerade_as_nightly_cargo() + .masquerade_as_nightly_cargo(&["print-im-a-teapot"]) ``` If you are testing a feature that only works on *nightly rustc* (such as -benchmarks), then you should exit the test if it is not running with nightly -rust, like this: +benchmarks), then you should use the `nightly` option of the `cargo_test` +attribute, like this: ```rust,ignore -if !is_nightly() { - // Add a comment here explaining why this is necessary. - return; -} +#[cargo_test(nightly, reason = "-Zfoo is unstable")] ``` +This will cause the test to be ignored if not running on the nightly toolchain. + ### Platform-specific Notes When checking output, use `/` for paths even on Windows: the actual output diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-add.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-add.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-add.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-add.md 2022-10-20 06:00:42.000000000 +0000 @@ -31,6 +31,11 @@ When you add a package that is already present, the existing entry will be updated with the flags specified. +Upon successful invocation, the enabled (`+`) and disabled (`-`) [features] of the specified +dependency will be listed in the command's output. + +[features]: ../reference/features.md + ## OPTIONS ### Source options diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-bench.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-bench.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-bench.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-bench.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-bench(1) {{*set actionverb="Benchmark"}} {{*set nouns="benchmarks"}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-build.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-build.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-build.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-build.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,6 @@ # cargo-build(1) {{*set actionverb="Build"}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-check.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-check.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-check.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-check.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,6 @@ # cargo-check(1) {{*set actionverb="Check"}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-clean.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-clean.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-clean.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-clean.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,6 @@ # cargo-clean(1) {{*set actionverb="Clean"}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-doc.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-doc.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-doc.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-doc.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,6 @@ # cargo-doc(1) {{*set actionverb="Document"}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-fetch.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-fetch.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-fetch.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-fetch.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-fetch(1) {{*set actionverb="Fetch"}} {{*set target-default-to-all-arch=true}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-fix.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-fix.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-fix.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-fix.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,6 @@ # cargo-fix(1) {{*set actionverb="Fix"}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-package.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-package.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-package.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-package.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-package(1) {{*set actionverb="Package"}} {{*set noall=true}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-publish.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-publish.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-publish.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-publish.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,6 @@ # cargo-publish(1) {{*set actionverb="Publish"}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-rustc.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-rustc.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-rustc.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-rustc.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,6 @@ # cargo-rustc(1) {{*set actionverb="Build"}} +{{*set multitarget=true}} ## NAME @@ -70,6 +71,19 @@ {{> options-timings }} +{{#option "`--crate-type` _crate-type_"}} +Build for the given crate type. This flag accepts a comma-separated list of +1 or more crate types, of which the allowed values are the same as `crate-type` +field in the manifest for configurating a Cargo target. See +[`crate-type` field](../reference/cargo-targets.html#the-crate-type-field) +for possible values. + +If the manifest contains a list, and `--crate-type` is provided, +the command-line argument value will override what is in the manifest. + +This flag only works when building a `lib` or `example` library target. +{{/option}} + {{/options}} ### Output Options @@ -123,5 +137,9 @@ cargo rustc --lib -- -Z print-type-sizes +3. Override `crate-type` field in Cargo.toml with command-line option: + + cargo rustc --lib --crate-type lib,cdylib + ## SEE ALSO {{man "cargo" 1}}, {{man "cargo-build" 1}}, {{man "rustc" 1}} diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-rustdoc.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-rustdoc.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-rustdoc.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-rustdoc.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,6 @@ # cargo-rustdoc(1) {{*set actionverb="Document"}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-test.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-test.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/cargo-test.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/cargo-test.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-test(1) {{*set actionverb="Test"}} {{*set nouns="tests"}} +{{*set multitarget=true}} ## NAME diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-add.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-add.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-add.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-add.txt 2022-10-20 06:00:42.000000000 +0000 @@ -32,6 +32,10 @@ When you add a package that is already present, the existing entry will be updated with the flags specified. + Upon successful invocation, the enabled (+) and disabled (-) features + of the specified + dependency will be listed in the command's output. + OPTIONS Source options --git url @@ -141,8 +145,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-bench.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-bench.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-bench.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-bench.txt 2022-10-20 06:00:42.000000000 +0000 @@ -208,7 +208,8 @@ Benchmark for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -237,12 +238,13 @@ (rather than the default) is unstable and requires -Zunstable-options. Valid output formats: - o html: Write a human-readable file cargo-timing.html to the - target/cargo-timings directory with a report of the compilation. - Also write a report to the same directory with a timestamp in the - filename if you want to look at older runs. HTML output is - suitable for human consumption only, and does not provide - machine-readable timing data. + o html (unstable, requires -Zunstable-options): Write a + human-readable file cargo-timing.html to the target/cargo-timings + directory with a report of the compilation. Also write a report + to the same directory with a timestamp in the filename if you + want to look at older runs. HTML output is suitable for human + consumption only, and does not provide machine-readable timing + data. o json (unstable, requires -Zunstable-options): Emit machine-readable JSON information about timing information. @@ -309,7 +311,7 @@ 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 + diagnostics 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. @@ -353,8 +355,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. @@ -372,7 +379,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-build.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-build.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-build.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-build.txt 2022-10-20 06:00:42.000000000 +0000 @@ -140,7 +140,8 @@ Build for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -173,12 +174,13 @@ (rather than the default) is unstable and requires -Zunstable-options. Valid output formats: - o html: Write a human-readable file cargo-timing.html to the - target/cargo-timings directory with a report of the compilation. - Also write a report to the same directory with a timestamp in the - filename if you want to look at older runs. HTML output is - suitable for human consumption only, and does not provide - machine-readable timing data. + o html (unstable, requires -Zunstable-options): Write a + human-readable file cargo-timing.html to the target/cargo-timings + directory with a report of the compilation. Also write a report + to the same directory with a timestamp in the filename if you + want to look at older runs. HTML output is suitable for human + consumption only, and does not provide machine-readable timing + data. o json (unstable, requires -Zunstable-options): Emit machine-readable JSON information about timing information. @@ -248,7 +250,7 @@ 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 + diagnostics 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. @@ -302,8 +304,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. @@ -317,7 +324,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-check.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-check.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-check.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-check.txt 2022-10-20 06:00:42.000000000 +0000 @@ -137,7 +137,8 @@ Check for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -177,12 +178,13 @@ (rather than the default) is unstable and requires -Zunstable-options. Valid output formats: - o html: Write a human-readable file cargo-timing.html to the - target/cargo-timings directory with a report of the compilation. - Also write a report to the same directory with a timestamp in the - filename if you want to look at older runs. HTML output is - suitable for human consumption only, and does not provide - machine-readable timing data. + o html (unstable, requires -Zunstable-options): Write a + human-readable file cargo-timing.html to the target/cargo-timings + directory with a report of the compilation. Also write a report + to the same directory with a timestamp in the filename if you + want to look at older runs. HTML output is suitable for human + consumption only, and does not provide machine-readable timing + data. o json (unstable, requires -Zunstable-options): Emit machine-readable JSON information about timing information. @@ -243,7 +245,7 @@ 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 + diagnostics 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. @@ -287,8 +289,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. @@ -302,7 +309,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-clean.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-clean.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-clean.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-clean.txt 2022-10-20 06:00:42.000000000 +0000 @@ -43,7 +43,8 @@ Clean for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -118,8 +119,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-doc.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-doc.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-doc.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-doc.txt 2022-10-20 06:00:42.000000000 +0000 @@ -115,7 +115,8 @@ Document for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -148,12 +149,13 @@ (rather than the default) is unstable and requires -Zunstable-options. Valid output formats: - o html: Write a human-readable file cargo-timing.html to the - target/cargo-timings directory with a report of the compilation. - Also write a report to the same directory with a timestamp in the - filename if you want to look at older runs. HTML output is - suitable for human consumption only, and does not provide - machine-readable timing data. + o html (unstable, requires -Zunstable-options): Write a + human-readable file cargo-timing.html to the target/cargo-timings + directory with a report of the compilation. Also write a report + to the same directory with a timestamp in the filename if you + want to look at older runs. HTML output is suitable for human + consumption only, and does not provide machine-readable timing + data. o json (unstable, requires -Zunstable-options): Emit machine-readable JSON information about timing information. @@ -214,7 +216,7 @@ 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 + diagnostics 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. @@ -258,8 +260,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. @@ -273,7 +280,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-fetch.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-fetch.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-fetch.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-fetch.txt 2022-10-20 06:00:42.000000000 +0000 @@ -28,7 +28,8 @@ Fetch for the given architecture. The default is all architectures. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -103,8 +104,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-fix.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-fix.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-fix.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-fix.txt 2022-10-20 06:00:42.000000000 +0000 @@ -210,7 +210,8 @@ Fix for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -250,12 +251,13 @@ (rather than the default) is unstable and requires -Zunstable-options. Valid output formats: - o html: Write a human-readable file cargo-timing.html to the - target/cargo-timings directory with a report of the compilation. - Also write a report to the same directory with a timestamp in the - filename if you want to look at older runs. HTML output is - suitable for human consumption only, and does not provide - machine-readable timing data. + o html (unstable, requires -Zunstable-options): Write a + human-readable file cargo-timing.html to the target/cargo-timings + directory with a report of the compilation. Also write a report + to the same directory with a timestamp in the filename if you + want to look at older runs. HTML output is suitable for human + consumption only, and does not provide machine-readable timing + data. o json (unstable, requires -Zunstable-options): Emit machine-readable JSON information about timing information. @@ -316,7 +318,7 @@ 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 + diagnostics 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. @@ -360,8 +362,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. @@ -375,7 +382,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-generate-lockfile.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-generate-lockfile.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-generate-lockfile.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-generate-lockfile.txt 2022-10-20 06:00:42.000000000 +0000 @@ -79,8 +79,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-init.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-init.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-init.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-init.txt 2022-10-20 06:00:42.000000000 +0000 @@ -87,8 +87,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-install.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-install.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-install.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-install.txt 2022-10-20 06:00:42.000000000 +0000 @@ -213,12 +213,13 @@ (rather than the default) is unstable and requires -Zunstable-options. Valid output formats: - o html: Write a human-readable file cargo-timing.html to the - target/cargo-timings directory with a report of the compilation. - Also write a report to the same directory with a timestamp in the - filename if you want to look at older runs. HTML output is - suitable for human consumption only, and does not provide - machine-readable timing data. + o html (unstable, requires -Zunstable-options): Write a + human-readable file cargo-timing.html to the target/cargo-timings + directory with a report of the compilation. Also write a report + to the same directory with a timestamp in the filename if you + want to look at older runs. HTML output is suitable for human + consumption only, and does not provide machine-readable timing + data. o json (unstable, requires -Zunstable-options): Emit machine-readable JSON information about timing information. @@ -255,7 +256,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather @@ -310,7 +313,7 @@ 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 + diagnostics 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. @@ -323,8 +326,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-locate-project.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-locate-project.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-locate-project.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-locate-project.txt 2022-10-20 06:00:42.000000000 +0000 @@ -62,8 +62,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-login.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-login.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-login.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-login.txt 2022-10-20 06:00:42.000000000 +0000 @@ -62,8 +62,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-metadata.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-metadata.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-metadata.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-metadata.txt 2022-10-20 06:00:42.000000000 +0000 @@ -391,8 +391,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-new.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-new.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-new.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-new.txt 2022-10-20 06:00:42.000000000 +0000 @@ -82,8 +82,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-owner.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-owner.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-owner.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-owner.txt 2022-10-20 06:00:42.000000000 +0000 @@ -89,8 +89,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-package.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-package.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-package.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-package.txt 2022-10-20 06:00:42.000000000 +0000 @@ -112,7 +112,8 @@ Package for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -187,7 +188,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather @@ -227,8 +230,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-pkgid.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-pkgid.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-pkgid.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-pkgid.txt 2022-10-20 06:00:42.000000000 +0000 @@ -109,8 +109,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-publish.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-publish.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-publish.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-publish.txt 2022-10-20 06:00:42.000000000 +0000 @@ -79,7 +79,8 @@ Publish for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -154,7 +155,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather @@ -194,8 +197,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-run.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-run.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-run.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-run.txt 2022-10-20 06:00:42.000000000 +0000 @@ -93,12 +93,13 @@ (rather than the default) is unstable and requires -Zunstable-options. Valid output formats: - o html: Write a human-readable file cargo-timing.html to the - target/cargo-timings directory with a report of the compilation. - Also write a report to the same directory with a timestamp in the - filename if you want to look at older runs. HTML output is - suitable for human consumption only, and does not provide - machine-readable timing data. + o html (unstable, requires -Zunstable-options): Write a + human-readable file cargo-timing.html to the target/cargo-timings + directory with a report of the compilation. Also write a report + to the same directory with a timestamp in the filename if you + want to look at older runs. HTML output is suitable for human + consumption only, and does not provide machine-readable timing + data. o json (unstable, requires -Zunstable-options): Emit machine-readable JSON information about timing information. @@ -159,7 +160,7 @@ 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 + diagnostics 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. @@ -203,8 +204,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. @@ -218,7 +224,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-rustc.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-rustc.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-rustc.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-rustc.txt 2022-10-20 06:00:42.000000000 +0000 @@ -131,7 +131,8 @@ Build for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -181,16 +182,30 @@ (rather than the default) is unstable and requires -Zunstable-options. Valid output formats: - o html: Write a human-readable file cargo-timing.html to the - target/cargo-timings directory with a report of the compilation. - Also write a report to the same directory with a timestamp in the - filename if you want to look at older runs. HTML output is - suitable for human consumption only, and does not provide - machine-readable timing data. + o html (unstable, requires -Zunstable-options): Write a + human-readable file cargo-timing.html to the target/cargo-timings + directory with a report of the compilation. Also write a report + to the same directory with a timestamp in the filename if you + want to look at older runs. HTML output is suitable for human + consumption only, and does not provide machine-readable timing + data. o json (unstable, requires -Zunstable-options): Emit machine-readable JSON information about timing information. + --crate-type crate-type + Build for the given crate type. This flag accepts a comma-separated + list of 1 or more crate types, of which the allowed values are the + same as crate-type field in the manifest for configurating a Cargo + target. See crate-type field + + for possible values. + + If the manifest contains a list, and --crate-type is provided, the + command-line argument value will override what is in the manifest. + + This flag only works when building a lib or example library target. + Output Options --target-dir directory Directory for all generated artifacts and intermediate files. May @@ -247,7 +262,7 @@ 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 + diagnostics 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. @@ -291,8 +306,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. @@ -306,7 +326,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather @@ -339,6 +361,10 @@ cargo rustc --lib -- -Z print-type-sizes + 3. Override crate-type field in Cargo.toml with command-line option: + + cargo rustc --lib --crate-type lib,cdylib + SEE ALSO cargo(1), cargo-build(1), rustc(1) diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-rustdoc.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-rustdoc.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-rustdoc.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-rustdoc.txt 2022-10-20 06:00:42.000000000 +0000 @@ -131,7 +131,8 @@ Document for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -164,12 +165,13 @@ (rather than the default) is unstable and requires -Zunstable-options. Valid output formats: - o html: Write a human-readable file cargo-timing.html to the - target/cargo-timings directory with a report of the compilation. - Also write a report to the same directory with a timestamp in the - filename if you want to look at older runs. HTML output is - suitable for human consumption only, and does not provide - machine-readable timing data. + o html (unstable, requires -Zunstable-options): Write a + human-readable file cargo-timing.html to the target/cargo-timings + directory with a report of the compilation. Also write a report + to the same directory with a timestamp in the filename if you + want to look at older runs. HTML output is suitable for human + consumption only, and does not provide machine-readable timing + data. o json (unstable, requires -Zunstable-options): Emit machine-readable JSON information about timing information. @@ -230,7 +232,7 @@ 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 + diagnostics 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. @@ -274,8 +276,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. @@ -289,7 +296,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-search.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-search.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-search.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-search.txt 2022-10-20 06:00:42.000000000 +0000 @@ -59,8 +59,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-test.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-test.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-test.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-test.txt 2022-10-20 06:00:42.000000000 +0000 @@ -222,7 +222,8 @@ Test for the given architecture. The default is the host architecture. The general format of the triple is ---. Run rustc --print target-list for - a list of supported targets. + a list of supported targets. This flag may be specified multiple + times. This may also be specified with the build.target config value . @@ -255,12 +256,13 @@ (rather than the default) is unstable and requires -Zunstable-options. Valid output formats: - o html: Write a human-readable file cargo-timing.html to the - target/cargo-timings directory with a report of the compilation. - Also write a report to the same directory with a timestamp in the - filename if you want to look at older runs. HTML output is - suitable for human consumption only, and does not provide - machine-readable timing data. + o html (unstable, requires -Zunstable-options): Write a + human-readable file cargo-timing.html to the target/cargo-timings + directory with a report of the compilation. Also write a report + to the same directory with a timestamp in the filename if you + want to look at older runs. HTML output is suitable for human + consumption only, and does not provide machine-readable timing + data. o json (unstable, requires -Zunstable-options): Emit machine-readable JSON information about timing information. @@ -327,7 +329,7 @@ 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 + diagnostics 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. @@ -371,8 +373,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. @@ -392,7 +399,9 @@ Number of parallel jobs to run. May also be specified with the build.jobs config value . Defaults to - the number of CPUs. + the number of logical CPUs. If negative, it sets the maximum number + of parallel jobs to the number of logical CPUs plus provided value. + Should not be 0. --keep-going Build as many crates in the dependency graph as possible, rather diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-tree.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-tree.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-tree.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-tree.txt 2022-10-20 06:00:42.000000000 +0000 @@ -269,8 +269,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo.txt 2022-10-20 06:00:42.000000000 +0000 @@ -188,8 +188,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-uninstall.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-uninstall.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-uninstall.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-uninstall.txt 2022-10-20 06:00:42.000000000 +0000 @@ -71,8 +71,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-update.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-update.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-update.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-update.txt 2022-10-20 06:00:42.000000000 +0000 @@ -109,8 +109,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-vendor.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-vendor.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-vendor.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-vendor.txt 2022-10-20 06:00:42.000000000 +0000 @@ -105,8 +105,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-verify-project.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-verify-project.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-verify-project.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-verify-project.txt 2022-10-20 06:00:42.000000000 +0000 @@ -82,8 +82,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-yank.txt cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-yank.txt --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-yank.txt 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/generated_txt/cargo-yank.txt 2022-10-20 06:00:42.000000000 +0000 @@ -85,8 +85,13 @@ for more information about how toolchain overrides work. - --config KEY=VALUE - Overrides a Cargo configuration value. + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. -h, --help Prints help information. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/includes/options-jobs.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/includes/options-jobs.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/includes/options-jobs.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/includes/options-jobs.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,5 +1,7 @@ {{#option "`-j` _N_" "`--jobs` _N_"}} Number of parallel jobs to run. May also be specified with the `build.jobs` [config value](../reference/config.html). Defaults to -the number of CPUs. +the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0. {{/option}} diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/includes/options-message-format.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/includes/options-message-format.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/includes/options-message-format.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/includes/options-message-format.md 2022-10-20 06:00:42.000000000 +0000 @@ -14,7 +14,7 @@ - `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 +- `json-render-diagnostics`: Instruct Cargo to not include rustc diagnostics 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`. diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/includes/options-target-triple.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/includes/options-target-triple.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/includes/options-target-triple.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/includes/options-target-triple.md 2022-10-20 06:00:42.000000000 +0000 @@ -5,6 +5,7 @@ {{~/if}} The general format of the triple is `---`. Run `rustc --print target-list` for a list of supported targets. +{{~#if multitarget }} This flag may be specified multiple times. {{~/if}} This may also be specified with the `build.target` [config value](../reference/config.html). diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/includes/options-timings.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/includes/options-timings.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/includes/options-timings.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/includes/options-timings.md 2022-10-20 06:00:42.000000000 +0000 @@ -5,7 +5,7 @@ Specifying an output format (rather than the default) is unstable and requires `-Zunstable-options`. Valid output formats: -- `html`: Write a human-readable file `cargo-timing.html` to the +- `html` (unstable, requires `-Zunstable-options`): Write a human-readable file `cargo-timing.html` to the `target/cargo-timings` directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/man/includes/section-options-common.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/includes/section-options-common.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/man/includes/section-options-common.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/man/includes/section-options-common.md 2022-10-20 06:00:42.000000000 +0000 @@ -10,8 +10,10 @@ for more information about how toolchain overrides work. {{/option}} -{{#option "`--config` KEY=VALUE"}} -Overrides a Cargo configuration value. +{{#option "`--config` _KEY=VALUE_ or _PATH_"}} +Overrides a Cargo configuration value. The argument should be in TOML syntax of `KEY=VALUE`, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the [command-line overrides section](../reference/config.html#command-line-overrides) for more information. {{/option}} {{#option "`-h`" "`--help`"}} diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-add.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-add.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-add.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-add.md 2022-10-20 06:00:42.000000000 +0000 @@ -31,6 +31,11 @@ When you add a package that is already present, the existing entry will be updated with the flags specified. +Upon successful invocation, the enabled (`+`) and disabled (`-`) [features] of the specified +dependency will be listed in the command's output. + +[features]: ../reference/features.md + ## OPTIONS ### Source options @@ -177,8 +182,10 @@ for more information about how toolchain overrides work. -
--config KEY=VALUE
-
Overrides a Cargo configuration value.
+
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
-h
diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-bench.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-bench.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-bench.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-bench.md 2022-10-20 06:00:42.000000000 +0000 @@ -2,6 +2,7 @@ + ## NAME cargo-bench - Execute benchmarks of a package @@ -255,7 +256,7 @@
--target triple
Benchmark for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

+list of supported targets. This flag may be specified multiple times.

This may also be specified with the build.target config value.

Note that specifying this flag makes Cargo run in a different mode where the @@ -283,7 +284,7 @@ Specifying an output format (rather than the default) is unstable and requires -Zunstable-options. Valid output formats:

    -
  • html: Write a human-readable file cargo-timing.html to the +
  • html (unstable, requires -Zunstable-options): Write a human-readable file cargo-timing.html to the target/cargo-timings directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, @@ -363,7 +364,7 @@
  • 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 +
  • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics 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.
  • @@ -420,8 +421,10 @@ for more information about how toolchain overrides work.
-
--config KEY=VALUE
-
Overrides a Cargo configuration value.
+
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
-h
@@ -447,7 +450,9 @@
--jobs N
Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
+the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
--keep-going
diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-build.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-build.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-build.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-build.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-build(1) + ## NAME cargo-build - Compile the current package @@ -182,7 +183,7 @@
--target triple
Build for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

+list of supported targets. This flag may be specified multiple times.

This may also be specified with the build.target config value.

Note that specifying this flag makes Cargo run in a different mode where the @@ -217,7 +218,7 @@ Specifying an output format (rather than the default) is unstable and requires -Zunstable-options. Valid output formats:

    -
  • html: Write a human-readable file cargo-timing.html to the +
  • html (unstable, requires -Zunstable-options): Write a human-readable file cargo-timing.html to the target/cargo-timings directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, @@ -299,7 +300,7 @@
  • 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 +
  • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics 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.
  • @@ -364,8 +365,10 @@ for more information about how toolchain overrides work.
-
--config KEY=VALUE
-
Overrides a Cargo configuration value.
+
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
-h
@@ -387,7 +390,9 @@
--jobs N
Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
+the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
--keep-going
diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-check.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-check.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-check.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-check.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-check(1) + ## NAME cargo-check - Check the current package @@ -177,7 +178,7 @@
--target triple
Check for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

+list of supported targets. This flag may be specified multiple times.

This may also be specified with the build.target config value.

Note that specifying this flag makes Cargo run in a different mode where the @@ -216,7 +217,7 @@ Specifying an output format (rather than the default) is unstable and requires -Zunstable-options. Valid output formats:

    -
  • html: Write a human-readable file cargo-timing.html to the +
  • html (unstable, requires -Zunstable-options): Write a human-readable file cargo-timing.html to the target/cargo-timings directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, @@ -289,7 +290,7 @@
  • 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 +
  • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics 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.
  • @@ -345,8 +346,10 @@ for more information about how toolchain overrides work.
-
--config KEY=VALUE
-
Overrides a Cargo configuration value.
+
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
-h
@@ -368,7 +371,9 @@
--jobs N
Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
+the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
--keep-going
diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-clean.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-clean.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-clean.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-clean.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-clean(1) + ## NAME cargo-clean - Remove generated artifacts @@ -59,7 +60,7 @@
--target triple
Clean for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

+list of supported targets. This flag may be specified multiple times.

This may also be specified with the build.target config value.

Note that specifying this flag makes Cargo run in a different mode where the @@ -149,8 +150,10 @@ for more information about how toolchain overrides work.

-
--config KEY=VALUE
-
Overrides a Cargo configuration value.
+
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
-h
diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-doc.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-doc.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-doc.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-doc.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-doc(1) + ## NAME cargo-doc - Build a package's documentation @@ -155,7 +156,7 @@
--target triple
Document for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

+list of supported targets. This flag may be specified multiple times.

This may also be specified with the build.target config value.

Note that specifying this flag makes Cargo run in a different mode where the @@ -190,7 +191,7 @@ Specifying an output format (rather than the default) is unstable and requires -Zunstable-options. Valid output formats:

    -
  • html: Write a human-readable file cargo-timing.html to the +
  • html (unstable, requires -Zunstable-options): Write a human-readable file cargo-timing.html to the target/cargo-timings directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, @@ -263,7 +264,7 @@
  • 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 +
  • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics 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.
  • @@ -319,8 +320,10 @@ for more information about how toolchain overrides work.
-
--config KEY=VALUE
-
Overrides a Cargo configuration value.
+
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
-h
@@ -342,7 +345,9 @@
--jobs N
Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
+the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
--keep-going
diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-fetch.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-fetch.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-fetch.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-fetch.md 2022-10-20 06:00:42.000000000 +0000 @@ -2,6 +2,7 @@ + ## NAME cargo-fetch - Fetch dependencies of a package from the network @@ -34,7 +35,7 @@
--target triple
Fetch for the given architecture. The default is all architectures. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

+list of supported targets. This flag may be specified multiple times.

This may also be specified with the build.target config value.

Note that specifying this flag makes Cargo run in a different mode where the @@ -123,8 +124,10 @@ for more information about how toolchain overrides work.

-
--config KEY=VALUE
-
Overrides a Cargo configuration value.
+
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
-h
diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-fix.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-fix.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-fix.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-fix.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-fix(1) + ## NAME cargo-fix - Automatically fix lint warnings reported by rustc @@ -257,7 +258,7 @@
--target triple
Fix for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

+list of supported targets. This flag may be specified multiple times.

This may also be specified with the build.target config value.

Note that specifying this flag makes Cargo run in a different mode where the @@ -296,7 +297,7 @@ Specifying an output format (rather than the default) is unstable and requires -Zunstable-options. Valid output formats:

    -
  • html: Write a human-readable file cargo-timing.html to the +
  • html (unstable, requires -Zunstable-options): Write a human-readable file cargo-timing.html to the target/cargo-timings directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, @@ -369,7 +370,7 @@
  • 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 +
  • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics 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.
  • @@ -425,8 +426,10 @@ for more information about how toolchain overrides work.
-
--config KEY=VALUE
-
Overrides a Cargo configuration value.
+
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
-h
@@ -448,7 +451,9 @@
--jobs N
Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
+the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
--keep-going
diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-generate-lockfile.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-generate-lockfile.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-generate-lockfile.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-generate-lockfile.md 2022-10-20 06:00:42.000000000 +0000 @@ -98,8 +98,10 @@ for more information about how toolchain overrides work. -
--config KEY=VALUE
-
Overrides a Cargo configuration value.
+
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
-h
diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-init.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-init.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-init.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-init.md 2022-10-20 06:00:42.000000000 +0000 @@ -111,8 +111,10 @@ for more information about how toolchain overrides work. -
--config KEY=VALUE
-
Overrides a Cargo configuration value.
+
--config KEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
-h
diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-install.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-install.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-install.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-install.md 2022-10-20 06:00:42.000000000 +0000 @@ -243,7 +243,7 @@ Specifying an output format (rather than the default) is unstable and requires -Zunstable-options. Valid output formats:

    -
  • html: Write a human-readable file cargo-timing.html to the +
  • html (unstable, requires -Zunstable-options): Write a human-readable file cargo-timing.html to the target/cargo-timings directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, @@ -293,7 +293,9 @@
    --jobs N
    Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
    +the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
    --keep-going
    @@ -351,7 +353,7 @@
  • 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 +
  • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics 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.
  • @@ -373,8 +375,10 @@ for more information about how toolchain overrides work. -
    --config KEY=VALUE
    -
    Overrides a Cargo configuration value.
    +
    --config KEY=VALUE or PATH
    +
    Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
    -h
    diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-locate-project.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-locate-project.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-locate-project.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-locate-project.md 2022-10-20 06:00:42.000000000 +0000 @@ -87,8 +87,10 @@ for more information about how toolchain overrides work. -
    --config KEY=VALUE
    -
    Overrides a Cargo configuration value.
    +
    --config KEY=VALUE or PATH
    +
    Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
    -h
    diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-login.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-login.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-login.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-login.md 2022-10-20 06:00:42.000000000 +0000 @@ -79,8 +79,10 @@ for more information about how toolchain overrides work. -
    --config KEY=VALUE
    -
    Overrides a Cargo configuration value.
    +
    --config KEY=VALUE or PATH
    +
    Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
    -h
    diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo.md 2022-10-20 06:00:42.000000000 +0000 @@ -221,8 +221,10 @@ for more information about how toolchain overrides work. -
    --config KEY=VALUE
    -
    Overrides a Cargo configuration value.
    +
    --config KEY=VALUE or PATH
    +
    Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
    -h
    diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-metadata.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-metadata.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-metadata.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-metadata.md 2022-10-20 06:00:42.000000000 +0000 @@ -427,8 +427,10 @@ for more information about how toolchain overrides work. -
    --config KEY=VALUE
    -
    Overrides a Cargo configuration value.
    +
    --config KEY=VALUE or PATH
    +
    Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
    -h
    diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-new.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-new.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-new.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-new.md 2022-10-20 06:00:42.000000000 +0000 @@ -106,8 +106,10 @@ for more information about how toolchain overrides work. -
    --config KEY=VALUE
    -
    Overrides a Cargo configuration value.
    +
    --config KEY=VALUE or PATH
    +
    Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
    -h
    diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-owner.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-owner.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-owner.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-owner.md 2022-10-20 06:00:42.000000000 +0000 @@ -117,8 +117,10 @@ for more information about how toolchain overrides work. -
    --config KEY=VALUE
    -
    Overrides a Cargo configuration value.
    +
    --config KEY=VALUE or PATH
    +
    Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
    -h
    diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-package.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-package.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-package.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-package.md 2022-10-20 06:00:42.000000000 +0000 @@ -2,6 +2,7 @@ + ## NAME cargo-package - Assemble the local package into a distributable tarball @@ -133,7 +134,7 @@
    --target triple
    Package for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

    +list of supported targets. This flag may be specified multiple times.

    This may also be specified with the build.target config value.

    Note that specifying this flag makes Cargo run in a different mode where the @@ -225,7 +226,9 @@

    --jobs N
    Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
    +the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
    --keep-going
    @@ -280,8 +283,10 @@ for more information about how toolchain overrides work. -
    --config KEY=VALUE
    -
    Overrides a Cargo configuration value.
    +
    --config KEY=VALUE or PATH
    +
    Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
    -h
    diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-pkgid.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-pkgid.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-pkgid.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-pkgid.md 2022-10-20 06:00:42.000000000 +0000 @@ -127,8 +127,10 @@ for more information about how toolchain overrides work. -
    --config KEY=VALUE
    -
    Overrides a Cargo configuration value.
    +
    --config KEY=VALUE or PATH
    +
    Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
    -h
    diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-publish.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-publish.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-publish.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-publish.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-publish(1) + ## NAME cargo-publish - Upload a package to the registry @@ -99,7 +100,7 @@
    --target triple
    Publish for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

    +list of supported targets. This flag may be specified multiple times.

    This may also be specified with the build.target config value.

    Note that specifying this flag makes Cargo run in a different mode where the @@ -191,7 +192,9 @@

    --jobs N
    Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
    +the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
    --keep-going
    @@ -246,8 +249,10 @@ for more information about how toolchain overrides work. -
    --config KEY=VALUE
    -
    Overrides a Cargo configuration value.
    +
    --config KEY=VALUE or PATH
    +
    Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
    -h
    diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-run.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-run.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-run.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-run.md 2022-10-20 06:00:42.000000000 +0000 @@ -125,7 +125,7 @@ Specifying an output format (rather than the default) is unstable and requires -Zunstable-options. Valid output formats:

      -
    • html: Write a human-readable file cargo-timing.html to the +
    • html (unstable, requires -Zunstable-options): Write a human-readable file cargo-timing.html to the target/cargo-timings directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, @@ -199,7 +199,7 @@
    • 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 +
    • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics 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.
    • @@ -258,8 +258,10 @@ for more information about how toolchain overrides work. -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      @@ -281,7 +283,9 @@
      --jobs N
      Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
      +the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
      --keep-going
      diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-rustc.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-rustc.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-rustc.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-rustc.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-rustc(1) + ## NAME cargo-rustc - Compile the current package, and pass extra options to the compiler @@ -169,7 +170,7 @@
      --target triple
      Build for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

      +list of supported targets. This flag may be specified multiple times.

      This may also be specified with the build.target config value.

      Note that specifying this flag makes Cargo run in a different mode where the @@ -214,7 +215,7 @@ Specifying an output format (rather than the default) is unstable and requires -Zunstable-options. Valid output formats:

        -
      • html: Write a human-readable file cargo-timing.html to the +
      • html (unstable, requires -Zunstable-options): Write a human-readable file cargo-timing.html to the target/cargo-timings directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, @@ -226,6 +227,17 @@ +
        --crate-type crate-type
        +
        Build for the given crate type. This flag accepts a comma-separated list of +1 or more crate types, of which the allowed values are the same as crate-type +field in the manifest for configurating a Cargo target. See +crate-type field +for possible values.

        +

        If the manifest contains a list, and --crate-type is provided, +the command-line argument value will override what is in the manifest.

        +

        This flag only works when building a lib or example library target.

        + + ### Output Options @@ -288,7 +300,7 @@
      • 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 +
      • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics 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.
      • @@ -347,8 +359,10 @@ for more information about how toolchain overrides work.
      -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      @@ -370,7 +384,9 @@
      --jobs N
      Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
      +the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
      --keep-going
      @@ -410,5 +426,9 @@ cargo rustc --lib -- -Z print-type-sizes +3. Override `crate-type` field in Cargo.toml with command-line option: + + cargo rustc --lib --crate-type lib,cdylib + ## SEE ALSO [cargo(1)](cargo.html), [cargo-build(1)](cargo-build.html), [rustc(1)](https://doc.rust-lang.org/rustc/index.html) diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-rustdoc.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-rustdoc.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-rustdoc.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-rustdoc.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,6 +1,7 @@ # cargo-rustdoc(1) + ## NAME cargo-rustdoc - Build a package's documentation, using specified custom flags @@ -174,7 +175,7 @@
      --target triple
      Document for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

      +list of supported targets. This flag may be specified multiple times.

      This may also be specified with the build.target config value.

      Note that specifying this flag makes Cargo run in a different mode where the @@ -209,7 +210,7 @@ Specifying an output format (rather than the default) is unstable and requires -Zunstable-options. Valid output formats:

        -
      • html: Write a human-readable file cargo-timing.html to the +
      • html (unstable, requires -Zunstable-options): Write a human-readable file cargo-timing.html to the target/cargo-timings directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, @@ -282,7 +283,7 @@
      • 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 +
      • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics 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.
      • @@ -338,8 +339,10 @@ for more information about how toolchain overrides work.
      -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      @@ -361,7 +364,9 @@
      --jobs N
      Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
      +the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
      --keep-going
      diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-search.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-search.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-search.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-search.md 2022-10-20 06:00:42.000000000 +0000 @@ -83,8 +83,10 @@ for more information about how toolchain overrides work. -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-test.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-test.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-test.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-test.md 2022-10-20 06:00:42.000000000 +0000 @@ -2,6 +2,7 @@ + ## NAME cargo-test - Execute unit and integration tests of a package @@ -269,7 +270,7 @@
      --target triple
      Test for the given architecture. The default is the host architecture. The general format of the triple is <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a -list of supported targets.

      +list of supported targets. This flag may be specified multiple times.

      This may also be specified with the build.target config value.

      Note that specifying this flag makes Cargo run in a different mode where the @@ -304,7 +305,7 @@ Specifying an output format (rather than the default) is unstable and requires -Zunstable-options. Valid output formats:

        -
      • html: Write a human-readable file cargo-timing.html to the +
      • html (unstable, requires -Zunstable-options): Write a human-readable file cargo-timing.html to the target/cargo-timings directory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, @@ -384,7 +385,7 @@
      • 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 +
      • json-render-diagnostics: Instruct Cargo to not include rustc diagnostics 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.
      • @@ -443,8 +444,10 @@ for more information about how toolchain overrides work.
      -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      @@ -473,7 +476,9 @@
      --jobs N
      Number of parallel jobs to run. May also be specified with the build.jobs config value. Defaults to -the number of CPUs.
      +the number of logical CPUs. If negative, it sets the maximum number of +parallel jobs to the number of logical CPUs plus provided value. +Should not be 0.
      --keep-going
      diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-tree.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-tree.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-tree.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-tree.md 2022-10-20 06:00:42.000000000 +0000 @@ -313,8 +313,10 @@ for more information about how toolchain overrides work. -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-uninstall.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-uninstall.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-uninstall.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-uninstall.md 2022-10-20 06:00:42.000000000 +0000 @@ -93,8 +93,10 @@ for more information about how toolchain overrides work. -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-update.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-update.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-update.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-update.md 2022-10-20 06:00:42.000000000 +0000 @@ -138,8 +138,10 @@ for more information about how toolchain overrides work. -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-vendor.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-vendor.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-vendor.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-vendor.md 2022-10-20 06:00:42.000000000 +0000 @@ -134,8 +134,10 @@ for more information about how toolchain overrides work. -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-verify-project.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-verify-project.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-verify-project.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-verify-project.md 2022-10-20 06:00:42.000000000 +0000 @@ -104,8 +104,10 @@ for more information about how toolchain overrides work. -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-yank.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-yank.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/commands/cargo-yank.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/commands/cargo-yank.md 2022-10-20 06:00:42.000000000 +0000 @@ -113,8 +113,10 @@ for more information about how toolchain overrides work. -
      --config KEY=VALUE
      -
      Overrides a Cargo configuration value.
      +
      --config KEY=VALUE or PATH
      +
      Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE, +or provided as a path to an extra configuration file. This flag may be specified multiple times. +See the command-line overrides section for more information.
      -h
      diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/guide/cargo-toml-vs-cargo-lock.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/guide/cargo-toml-vs-cargo-lock.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/guide/cargo-toml-vs-cargo-lock.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/guide/cargo-toml-vs-cargo-lock.md 2022-10-20 06:00:42.000000000 +0000 @@ -43,7 +43,8 @@ build would include new commits while yours would not. Therefore, we would get different builds. This would be bad because we want reproducible builds. -We could fix this problem by putting a `rev` line in our `Cargo.toml`: +We could fix this problem by defining a specific `rev` value in our `Cargo.toml`, +so Cargo could know exactly which revision to use when building the package: ```toml [dependencies] diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/config.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/config.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/config.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/config.md 2022-10-20 06:00:42.000000000 +0000 @@ -59,6 +59,7 @@ t = "test" r = "run" rr = "run --release" +recursive_example = "rr --example recursions" space_example = ["run", "--release", "--", "\"command list\""] [build] @@ -237,13 +238,28 @@ ### Config-relative paths -Paths in config files may be absolute, relative, or a bare name without any -path separators. Paths for executables without a path separator will use the -`PATH` environment variable to search for the executable. Paths for -non-executables will be relative to where the config value is defined. For -config files, that is relative to the parent directory of the `.cargo` -directory where the value was defined. For environment variables it is -relative to the current working directory. +Paths in config files may be absolute, relative, or a bare name without any path separators. +Paths for executables without a path separator will use the `PATH` environment variable to search for the executable. +Paths for non-executables will be relative to where the config value is defined. + +In particular, rules are: + +* For environment variables, paths are relative to the current working directory. +* For config values loaded directly from the [`--config KEY=VALUE`](#command-line-overrides) option, + paths are relative to the current working directory. +* For config files, paths are relative to the parent directory of the directory where the config files were defined, + no matter those files are from either the [hierarchical probing](#hierarchical-structure) + or the [`--config `](#command-line-overrides) option. + +> **Note:** To maintain consistency with existing `.cargo/config.toml` probing behavior, +> it is by design that a path in a config file passed via `--config ` +> is also relative to two levels up from the config file itself. +> +> To avoid unexpected results, the rule of thumb is putting your extra config files +> at the same level of discovered `.cargo/config.toml` in your porject. +> For instance, given a project `/my/project`, +> it is recommended to put config files under `/my/project/.cargo` +> or a new directory at the same level, such as `/my/project/.config`. ```toml # Relative path examples. @@ -335,6 +351,14 @@ Aliases are not allowed to redefine existing built-in commands. +Aliases are recursive: + +```toml +[alias] +rr = "run --release" +recursive_example = "rr --example recursions" +``` + #### `[build]` The `[build]` table controls build-time operations and compiler settings. @@ -344,7 +368,9 @@ * Default: number of logical CPUs * Environment: `CARGO_BUILD_JOBS` -Sets the maximum number of compiler processes to run in parallel. +Sets the maximum number of compiler processes to run in parallel. If negative, +it sets the maximum number of compiler processes to the number of logical CPUs +plus provided value. Should not be 0. Can be overridden with the `--jobs` CLI option. @@ -361,7 +387,8 @@ * Environment: `CARGO_BUILD_RUSTC_WRAPPER` or `RUSTC_WRAPPER` Sets a wrapper to execute instead of `rustc`. The first argument passed to the -wrapper is the path to the actual `rustc`. +wrapper is the path to the actual executable to use +(i.e., `build.rustc`, if that is set, or `"rustc"` otherwise). ##### `build.rustc-workspace-wrapper` * Type: string (program path) @@ -369,7 +396,8 @@ * Environment: `CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER` or `RUSTC_WORKSPACE_WRAPPER` Sets a wrapper to execute instead of `rustc`, for workspace members only. -The first argument passed to the wrapper is the path to the actual `rustc`. +The first argument passed to the wrapper is the path to the actual +executable to use (i.e., `build.rustc`, if that is set, or `"rustc"` otherwise). It affects the filename hash so that artifacts produced by the wrapper are cached separately. ##### `build.rustdoc` @@ -380,16 +408,25 @@ Sets the executable to use for `rustdoc`. ##### `build.target` -* Type: string +* Type: string or array of strings * Default: host platform * Environment: `CARGO_BUILD_TARGET` -The default target platform triple to compile to. +The default target platform triples to compile to. + +This allows passing either a string or an array of strings. Each string value +is a target platform triple. The selected build targets will be built for each +of the selected architectures. -This may also be a relative path to a `.json` target spec file. +The string value may also be a relative path to a `.json` target spec file. Can be overridden with the `--target` CLI option. +```toml +[build] +target = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"] +``` + ##### `build.target-dir` * Type: string (path) * Default: "target" diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/environment-variables.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/environment-variables.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/environment-variables.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/environment-variables.md 2022-10-20 06:00:42.000000000 +0000 @@ -9,6 +9,11 @@ You can override these environment variables to change Cargo's behavior on your system: +* `CARGO_LOG` - Cargo uses the [`env_logger`] crate to display debug log messages. + The `CARGO_LOG` environment variable can be set to enable debug logging, + with a value such as `trace`, `debug`, or `warn`. + Usually it is only used during debugging. For more details refer to the + [Debug logging]. * `CARGO_HOME` — Cargo maintains a local cache of the registry index and of git checkouts of crates. By default these are stored under `$HOME/.cargo` (`%USERPROFILE%\.cargo` on Windows), but this variable overrides the @@ -21,32 +26,35 @@ * `RUSTC` — Instead of running `rustc`, Cargo will execute this specified compiler instead. See [`build.rustc`] to set via config. * `RUSTC_WRAPPER` — Instead of simply running `rustc`, Cargo will execute this - specified wrapper instead, passing as its command-line arguments the rustc - invocation, with the first argument being `rustc`. Useful to set up a build - cache tool such as `sccache`. See [`build.rustc-wrapper`] to set via config. -* `RUSTC_WORKSPACE_WRAPPER` — Instead of simply running `rustc`, Cargo will - execute this specified wrapper instead for workspace members only, passing + specified wrapper, passing as its command-line arguments the rustc + invocation, with the first argument being the path to the actual rustc. + Useful to set up a build cache tool such as `sccache`. See + [`build.rustc-wrapper`] to set via config. Setting this to the empty string + overwrites the config and resets cargo to not use a wrapper. +* `RUSTC_WORKSPACE_WRAPPER` — Instead of simply running `rustc`, for workspace + members Cargo will execute this specified wrapper, passing as its command-line arguments the rustc invocation, with the first argument - being `rustc`. It affects the filename hash so that artifacts produced by - the wrapper are cached separately. See [`build.rustc-workspace-wrapper`] - to set via config. + being the path to the actual rustc. It affects the filename hash + so that artifacts produced by the wrapper are cached separately. + See [`build.rustc-workspace-wrapper`] to set via config. Setting this to the empty string + overwrites the config and resets cargo to not use a wrapper for workspace members. * `RUSTDOC` — Instead of running `rustdoc`, Cargo will execute this specified `rustdoc` instance instead. See [`build.rustdoc`] to set via config. * `RUSTDOCFLAGS` — A space-separated list of custom flags to pass to all `rustdoc` invocations that Cargo performs. In contrast with [`cargo rustdoc`], this is useful for passing a flag to *all* `rustdoc` instances. See [`build.rustdocflags`] for some more ways to set flags. This string is - split by whitespace; for a more robust encoding of multiple arguments, + split by whitespace; for a more robust encoding of multiple arguments, see `CARGO_ENCODED_RUSTDOCFLAGS`. -* `CARGO_ENCODED_RUSTDOCFLAGS` - A list of custom flags separated by `0x1f` +* `CARGO_ENCODED_RUSTDOCFLAGS` - A list of custom flags separated by `0x1f` (ASCII Unit Separator) to pass to all `rustdoc` invocations that Cargo performs. * `RUSTFLAGS` — A space-separated list of custom flags to pass to all compiler invocations that Cargo performs. In contrast with [`cargo rustc`], this is useful for passing a flag to *all* compiler instances. See [`build.rustflags`] for some more ways to set flags. This string is - split by whitespace; for a more robust encoding of multiple arguments, + split by whitespace; for a more robust encoding of multiple arguments, see `CARGO_ENCODED_RUSTFLAGS`. -* `CARGO_ENCODED_RUSTFLAGS` - A list of custom flags separated by `0x1f` +* `CARGO_ENCODED_RUSTFLAGS` - A list of custom flags separated by `0x1f` (ASCII Unit Separator) to pass to all compiler invocations that Cargo performs. * `CARGO_INCREMENTAL` — If this is set to 1 then Cargo will force [incremental compilation] to be enabled for the current compilation, and when set to 0 it @@ -366,6 +374,8 @@ 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]. +[`env_logger`]: https://docs.rs/env_logger +[debug logging]: https://doc.crates.io/contrib/architecture/console.html#debug-logging [unix-like platforms]: ../../reference/conditional-compilation.html#unix-and-windows [windows-like platforms]: ../../reference/conditional-compilation.html#unix-and-windows [target family]: ../../reference/conditional-compilation.html#target_family diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/future-incompat-report.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/future-incompat-report.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/future-incompat-report.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/future-incompat-report.md 2022-10-20 06:00:42.000000000 +0000 @@ -1,24 +1,37 @@ ### Future incompat report -Cargo checks for future-incompatible warnings in all dependencies. These are warnings for +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. +For example, you may see something like this at the end of a build: + +```text +warning: the following packages contain code that will be rejected by a future + version of Rust: rental v0.5.5 +note: to see what the problems were, use the option `--future-incompat-report`, + or run `cargo report future-incompatibilities --id 1` +``` + 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: +## Configuration -``` +This feature can be configured through a [`[future-incompat-report]`][config] +section in `.cargo/config.toml`. Currently, the supported options are: + +```toml [future-incompat-report] -frequency = FREQUENCY +frequency = "always" ``` -The supported values for `FREQUENCY` are `always` and `never`, which control +The supported values for the frequency are `"always"` and `"never"`, which control whether or not a message is printed out at the end of `cargo build` / `cargo check`. + +[config]: config.md#future-incompat-report diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/manifest.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/manifest.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/manifest.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/manifest.md 2022-10-20 06:00:42.000000000 +0000 @@ -74,11 +74,15 @@ inferred lib and bin targets. The name must use only [alphanumeric] characters or `-` or `_`, and cannot be empty. + Note that [`cargo new`] and [`cargo init`] impose some additional restrictions on the package name, such as enforcing that it is a valid Rust identifier and not -a keyword. [crates.io] imposes even more restrictions, such as -enforcing only ASCII characters, not a reserved name, not a special Windows -name such as "nul", is not too long, etc. +a keyword. [crates.io] imposes even more restrictions, such as: + +- Only ASCII characters are allowed. +- Do not use reserved names. +- Do not use special Windows name such as "nul". +- Use a maximum of 64 characters of length. [alphanumeric]: ../../std/primitive.char.html#method.is_alphanumeric diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/overriding-dependencies.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/overriding-dependencies.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/overriding-dependencies.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/overriding-dependencies.md 2022-10-20 06:00:42.000000000 +0000 @@ -266,6 +266,12 @@ baz = { git = 'https://github.com/example/patched-baz', branch = 'my-branch' } ``` +> **Note**: The `[patch]` table can also be specified as a [configuration +> option](config.md), such as in a `.cargo/config.toml` file or a CLI option +> like `--config 'patch.crates-io.rand.path="rand"'`. This can be useful for +> local-only changes that you don't want to commit, or temporarily testing a +> patch. + The `[patch]` table is made of dependency-like sub-tables. Each key after `[patch]` is a URL of the source that is being patched, or the name of a registry. The name `crates-io` may be used to override the default registry diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/profiles.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/profiles.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/profiles.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/profiles.md 2022-10-20 06:00:42.000000000 +0000 @@ -246,7 +246,7 @@ #### dev The `dev` profile is used for normal development and debugging. It is the -default for build commands like [`cargo build`]. +default for build commands like [`cargo build`], and is used for `cargo install --debug`. The default settings for the `dev` profile are: diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/registries.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/registries.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/registries.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/registries.md 2022-10-20 06:00:42.000000000 +0000 @@ -320,9 +320,10 @@ using the [`cargo login`] command, or by passing the token on the command-line. -Responses use a 200 response code for both success and errors. Cargo looks at -the JSON response to determine if there was success or failure. Failure -responses have a JSON object with the following structure: +Responses use the 200 response code for success. +Errors should use an appropriate response code, such as 404. +Failure +responses should have a JSON object with the following structure: ```javascript { @@ -336,10 +337,10 @@ } ``` -Servers may also respond with a 404 response code to indicate the requested -resource is not found (for example, an unknown crate name). However, using a -200 response with an `errors` object allows a registry to provide a more -detailed error message if desired. +If the response has this structure Cargo will display the detailed message to the user, even if the response code is 200. +If the response code indicates an error and the content does not have this structure, Cargo will display to the user a + message intended to help debugging the server error. A server returning an `errors` object allows a registry to provide a more +detailed or user-centric error message. For backwards compatibility, servers should ignore any unexpected query parameters or JSON fields. If a JSON field is missing, it should be assumed to diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/resolver.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/resolver.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/resolver.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/resolver.md 2022-10-20 06:00:42.000000000 +0000 @@ -37,7 +37,8 @@ `0.1.0` and `0.2.0` are not. Similarly, `0.0.1` and `0.0.2` are not compatible. -As a quick refresher, the *version requirement* syntax Cargo uses for +As a quick refresher, the +[*version requirement* syntax][Specifying Dependencies] Cargo uses for dependencies is: Requirement | Example | Equivalence | Description diff -Nru cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/specifying-dependencies.md cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/specifying-dependencies.md --- cargo-0.64.0ubuntu0.libgit2/src/doc/src/reference/specifying-dependencies.md 2022-07-01 18:13:04.000000000 +0000 +++ cargo-0.66.0+ds0ubuntu0.libgit2/src/doc/src/reference/specifying-dependencies.md 2022-10-20 06:00:42.000000000 +0000 @@ -454,8 +454,44 @@ log-debug = ['bar/log-debug'] # using 'foo/log-debug' would be an error! ``` +### Inheriting a dependency from a workspace + +Dependencies can be inherited from a workspace by specifying the +dependency in the workspace's [`[workspace.dependencies]`][workspace.dependencies] table. +After that, add it to the `[dependencies]` table with `workspace = true`. + +Along with the `workspace` key, dependencies can also include these keys: +- [`optional`][optional]: Note that the`[workspace.dependencies]` table is not allowed to specify `optional`. +- [`features`][features]: These are additive with the features declared in the `[workspace.dependencies]` + +Other than `optional` and `features`, inherited dependencies cannot use any other +dependency key (such as `version` or `default-features`). + +Dependencies in the `[dependencies]`, `[dev-dependencies]`, `[build-dependencies]`, and +`[target."...".dependencies]` sections support the ability to reference the +`[workspace.dependencies]` definition of dependencies. + +```toml +[project] +name = "bar" +version = "0.2.0" + +[dependencies] +regex = { workspace = true, features = ["unicode"] } + +[build-dependencies] +cc.workspace = true + +[dev-dependencies] +rand = { workspace = true, optional = true } +``` + + [crates.io]: https://crates.io/ [dev-dependencies]: #development-dependencies +[workspace.dependencies]: workspaces.md#the-workspacedependencies-table +[optional]: features.md#optional-dependencies +[features]: features.md