From 3c6d458440c3d134b5279722e278a0e007d66f7c Mon Sep 17 00:00:00 2001 From: Michael Henry Date: Fri, 22 May 2020 11:15:24 -0400 Subject: [PATCH 01/15] Support `{prefix}` and `{lowerprefix}` markers in `config.json` `dl` key. These new markers allow Cargo to supply a directory name (similar to that used in crates.io-index) as part of a crate's download URL, enabling simpler hosting of crates. Previously, a `file` URL would need to put all crates into a single huge directory (such as `/srv/crates/`), e.g.: file:///srv/crates/{crate}/{crate}-{version}.crate With the `{prefix}` marker, a more efficient directory structure may be used, e.g.: file:///srv/crates/{prefix}/{crate}/{crate}-{version}.crate An example crate of `cargo-0.44.1.crate` would map to the path: /srv/crates/ca/rg/cargo/cargo-0.44.1.crate --- src/cargo/sources/registry/mod.rs | 12 ++++++--- src/cargo/sources/registry/remote.rs | 40 +++++++++++++++++++++++++--- src/doc/src/reference/registries.md | 22 +++++++++++++-- 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index d49b46318e9..44328b29fbd 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -185,6 +185,8 @@ pub const CRATES_IO_INDEX: &str = "https://github.com/rust-lang/crates.io-index" pub const CRATES_IO_REGISTRY: &str = "crates-io"; const CRATE_TEMPLATE: &str = "{crate}"; const VERSION_TEMPLATE: &str = "{version}"; +const PREFIX_TEMPLATE: &str = "{prefix}"; +const LOWER_PREFIX_TEMPLATE: &str = "{lowerprefix}"; pub struct RegistrySource<'cfg> { source_id: SourceId, @@ -203,10 +205,14 @@ pub struct RegistryConfig { /// The string is a template which will generate the download URL for the /// tarball of a specific version of a crate. The substrings `{crate}` and /// `{version}` will be replaced with the crate's name and version - /// respectively. + /// respectively. The substring `{prefix}` will be replaced with the + /// crate's prefix directory name, and the substring `{lowerprefix}` will + /// be replaced with the crate's prefix directory name converted to + /// lowercase. /// - /// For backwards compatibility, if the string does not contain `{crate}` or - /// `{version}`, it will be extended with `/{crate}/{version}/download` to + /// For backwards compatibility, if the string does not contain any + /// markers (`{crate}`, `{version}`, `{prefix}`, or ``{lowerprefix}`), it + /// will be extended with `/{crate}/{version}/download` to /// support registries like crates.io which were created before the /// templating setup was created. pub dl: String, diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index 6dc4db00cc0..79c4a60d586 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -1,7 +1,10 @@ use crate::core::{InternedString, PackageId, SourceId}; use crate::sources::git; use crate::sources::registry::MaybeLock; -use crate::sources::registry::{RegistryConfig, RegistryData, CRATE_TEMPLATE, VERSION_TEMPLATE}; +use crate::sources::registry::{ + RegistryConfig, RegistryData, CRATE_TEMPLATE, LOWER_PREFIX_TEMPLATE, PREFIX_TEMPLATE, + VERSION_TEMPLATE, +}; use crate::util::errors::{CargoResult, CargoResultExt}; use crate::util::paths; use crate::util::{Config, Filesystem, Sha256}; @@ -16,6 +19,15 @@ use std::mem; use std::path::Path; use std::str; +fn make_crate_prefix(name: &str) -> String { + match name.len() { + 1 => format!("1"), + 2 => format!("2"), + 3 => format!("3/{}", &name[..1]), + _ => format!("{}/{}", &name[0..2], &name[2..4]), + } +} + pub struct RemoteRegistry<'cfg> { index_path: Filesystem, cache_path: Filesystem, @@ -250,12 +262,19 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { let config = self.config()?.unwrap(); let mut url = config.dl; - if !url.contains(CRATE_TEMPLATE) && !url.contains(VERSION_TEMPLATE) { + if !url.contains(CRATE_TEMPLATE) + && !url.contains(VERSION_TEMPLATE) + && !url.contains(PREFIX_TEMPLATE) + && !url.contains(LOWER_PREFIX_TEMPLATE) + { write!(url, "/{}/{}/download", CRATE_TEMPLATE, VERSION_TEMPLATE).unwrap(); } + let prefix = make_crate_prefix(&*pkg.name()); let url = url .replace(CRATE_TEMPLATE, &*pkg.name()) - .replace(VERSION_TEMPLATE, &pkg.version().to_string()); + .replace(VERSION_TEMPLATE, &pkg.version().to_string()) + .replace(PREFIX_TEMPLATE, &prefix) + .replace(LOWER_PREFIX_TEMPLATE, &prefix.to_lowercase()); Ok(MaybeLock::Download { url, @@ -314,3 +333,18 @@ impl<'cfg> Drop for RemoteRegistry<'cfg> { self.tree.borrow_mut().take(); } } + +#[cfg(test)] +mod tests { + use super::make_crate_prefix; + + #[test] + fn crate_prefix() { + assert_eq!(make_crate_prefix("a"), "1"); + assert_eq!(make_crate_prefix("ab"), "2"); + assert_eq!(make_crate_prefix("abc"), "3/a"); + assert_eq!(make_crate_prefix("Abc"), "3/A"); + assert_eq!(make_crate_prefix("AbCd"), "Ab/Cd"); + assert_eq!(make_crate_prefix("aBcDe"), "aB/cD"); + } +} diff --git a/src/doc/src/reference/registries.md b/src/doc/src/reference/registries.md index 33d4955bbe0..f0148ca67ee 100644 --- a/src/doc/src/reference/registries.md +++ b/src/doc/src/reference/registries.md @@ -128,8 +128,11 @@ looks like: The keys are: - `dl`: This is the URL for downloading crates listed in the index. The value may have the markers `{crate}` and `{version}` which are replaced with the - name and version of the crate to download. If the markers are not present, - then the value `/{crate}/{version}/download` is appended to the end. + name and version of the crate to download, or the marker `{prefix}` which is + replaced with the crate's prefix, or the marker `{lowerprefix}` which is + replaced with the crate's prefix converted to lowercase. If none of the + markers are present, then the value `/{crate}/{version}/download` is appended + to the end. See below for more about crate prefixes. - `api`: This is the base URL for the web API. This key is optional, but if it is not specified, commands such as [`cargo publish`] will not work. The web API is described below. @@ -159,6 +162,21 @@ directories: > package names in `Cargo.toml` and the index JSON data are case-sensitive and > may contain upper and lower case characters. +The directory name above is calculated based on the package name converted to +lowercase; it is represented by the marker `{lowerprefix}`. When the original +package name is used without case conversion, the resulting directory name is +represented by the marker `{prefix}`. For example, the package `MyCrate` would +have a `{prefix}` of `My/Cr` and a `{lowerprefix}` of `my/cr`. In general, +using `{prefix}` is recommended over `{lowerprefix}`, but there are pros and +cons to each choice. Using `{prefix}` on case-insensitive filesystems results +in (harmless-but-inelegant) directory aliasing. For example, `crate` and +`CrateTwo` have `{prefix}` values of `cr/at` and `Cr/at`; these are distinct on +Unix machines but alias to the same directory on Windows. Using directories +with normalized case avoids aliasing, but on case-sensitive filesystems it's +harder to suport older versions of Cargo that lack `{prefix}`/`{lowerprefix}`. +For example, nginx rewrite rules can easily construct `{prefix}` but can't +perform case-conversion to construct `{lowerprefix}`. + Registries should consider enforcing limitations on package names added to their index. Cargo itself allows names with any [alphanumeric], `-`, or `_` characters. [crates.io] imposes its own limitations, including the following: From 50a537bf93b8f34240777eeed5964a1c9b478d87 Mon Sep 17 00:00:00 2001 From: ReggaeMuffin <644950+reggaemuffin@users.noreply.github.com> Date: Sat, 23 May 2020 16:23:49 +0100 Subject: [PATCH 02/15] Add CARGO_BIN_NAME and CARGO_CRATE_NAME to rustc/rustdoc env CARGO_BIN_NAME is added for binary compilation units, CARGO_CRATE_NAME is added for binary and library units. The `crate_env_vars` test was updated to test for this. The test is currently only checking behavior for the binary compile unit. --- src/cargo/core/compiler/compilation.rs | 22 +++++++++++++++------- tests/testsuite/build.rs | 11 ++++++++++- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/cargo/core/compiler/compilation.rs b/src/cargo/core/compiler/compilation.rs index 7324618ff45..b8fb670c299 100644 --- a/src/cargo/core/compiler/compilation.rs +++ b/src/cargo/core/compiler/compilation.rs @@ -151,17 +151,15 @@ impl<'cfg> Compilation<'cfg> { self.rustc_process.clone() }; - self.fill_env(rustc, &unit.pkg, unit.kind, true) + let cmd = fill_rustc_tool_env(rustc, unit); + self.fill_env(cmd, &unit.pkg, unit.kind, true) } /// See `process`. pub fn rustdoc_process(&self, unit: &Unit) -> CargoResult { - let mut p = self.fill_env( - process(&*self.config.rustdoc()?), - &unit.pkg, - unit.kind, - true, - )?; + let rustdoc = process(&*self.config.rustdoc()?); + let cmd = fill_rustc_tool_env(rustdoc, unit); + let mut p = self.fill_env(cmd, &unit.pkg, unit.kind, true)?; if unit.target.edition() != Edition::Edition2015 { p.arg(format!("--edition={}", unit.target.edition())); } @@ -295,6 +293,16 @@ impl<'cfg> Compilation<'cfg> { } } +/// Prepares a rustc_tool process with additional environment variables +/// that are only relevant in a context that has a unit +fn fill_rustc_tool_env(mut cmd: ProcessBuilder, unit: &Unit) -> ProcessBuilder { + if unit.target.is_bin() { + cmd.env("CARGO_BIN_NAME", unit.target.name()); + } + cmd.env("CARGO_CRATE_NAME", unit.target.crate_name()); + cmd +} + fn pre_version_component(v: &Version) -> String { if v.pre.is_empty() { return String::new(); diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 6605e1f5366..f3b5e401d98 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1230,6 +1230,10 @@ fn crate_env_vars() { homepage = "https://example.com" repository = "https://example.com/repo.git" authors = ["wycats@example.com"] + + [[bin]] + name = "foo-bar" + path = "src/main.rs" "#, ) .file( @@ -1248,6 +1252,9 @@ fn crate_env_vars() { static HOMEPAGE: &'static str = env!("CARGO_PKG_HOMEPAGE"); static REPOSITORY: &'static str = env!("CARGO_PKG_REPOSITORY"); static DESCRIPTION: &'static str = env!("CARGO_PKG_DESCRIPTION"); + static BIN_NAME: &'static str = env!("CARGO_BIN_NAME"); + static CRATE_NAME: &'static str = env!("CARGO_CRATE_NAME"); + fn main() { let s = format!("{}-{}-{} @ {} in {}", VERSION_MAJOR, @@ -1256,6 +1263,8 @@ fn crate_env_vars() { assert_eq!(s, foo::version()); println!("{}", s); assert_eq!("foo", PKG_NAME); + assert_eq!("foo-bar", BIN_NAME); + assert_eq!("foo_bar", CRATE_NAME); assert_eq!("https://example.com", HOMEPAGE); assert_eq!("https://example.com/repo.git", REPOSITORY); assert_eq!("This is foo", DESCRIPTION); @@ -1284,7 +1293,7 @@ fn crate_env_vars() { p.cargo("build -v").run(); println!("bin"); - p.process(&p.bin("foo")) + p.process(&p.bin("foo-bar")) .with_stdout("0-5-1 @ alpha.1 in [CWD]") .run(); From 7cc6d95e4103fbd954c9d36183e0fa0d79312326 Mon Sep 17 00:00:00 2001 From: ReggaeMuffin <644950+reggaemuffin@users.noreply.github.com> Date: Sat, 23 May 2020 16:45:37 +0100 Subject: [PATCH 03/15] Add documentation for both environment variables --- src/doc/src/reference/environment-variables.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/doc/src/reference/environment-variables.md b/src/doc/src/reference/environment-variables.md index bb03e5ef454..217f3ef7c6b 100644 --- a/src/doc/src/reference/environment-variables.md +++ b/src/doc/src/reference/environment-variables.md @@ -184,6 +184,8 @@ let version = env!("CARGO_PKG_VERSION"); * `CARGO_PKG_DESCRIPTION` — The description from the manifest of your package. * `CARGO_PKG_HOMEPAGE` — The home page from the manifest of your package. * `CARGO_PKG_REPOSITORY` — The repository from the manifest of your package. +* `CARGO_CRATE_NAME` — The name of the crate that is currently being compiled. +* `CARGO_BIN_NAME` — The name of the binary that is currently being compiled (if it is a binary). * `OUT_DIR` — If the package has a build script, this is set to the folder where the build script should place its output. See below for more information. (Only set during compilation.) From b375bea147edda469b3442b9e89390180a442256 Mon Sep 17 00:00:00 2001 From: Michael Henry Date: Thu, 28 May 2020 16:24:16 -0400 Subject: [PATCH 04/15] Improve the wording of `dl` documentation. --- src/doc/src/reference/registries.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/doc/src/reference/registries.md b/src/doc/src/reference/registries.md index f0148ca67ee..6b49cd0dc05 100644 --- a/src/doc/src/reference/registries.md +++ b/src/doc/src/reference/registries.md @@ -127,12 +127,17 @@ looks like: The keys are: - `dl`: This is the URL for downloading crates listed in the index. The value - may have the markers `{crate}` and `{version}` which are replaced with the - name and version of the crate to download, or the marker `{prefix}` which is - replaced with the crate's prefix, or the marker `{lowerprefix}` which is - replaced with the crate's prefix converted to lowercase. If none of the - markers are present, then the value `/{crate}/{version}/download` is appended - to the end. See below for more about crate prefixes. + may have the following markers which will be replaced with their + corresponding value: + + - `{crate}`: The name of crate. + - `{version}`: The crate version. + - `{prefix}`: A directory prefix computed from the crate name. For example, + a crate named `cargo` has a prefix of `ca/rg`. See below for details. + - `{lowerprefix}`: Lowercase variant of `{prefix}`. + + If none of the markers are present, then the value + `/{crate}/{version}/download` is appended to the end. - `api`: This is the base URL for the web API. This key is optional, but if it is not specified, commands such as [`cargo publish`] will not work. The web API is described below. From 7ad7427ced99dadd76295963615dc9d903462802 Mon Sep 17 00:00:00 2001 From: Marvin Hofmann <644950+reggaemuffin@users.noreply.github.com> Date: Sun, 31 May 2020 21:01:03 +0100 Subject: [PATCH 05/15] Update documentation as per review --- src/doc/src/reference/environment-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/src/reference/environment-variables.md b/src/doc/src/reference/environment-variables.md index 217f3ef7c6b..f1c96f1ac39 100644 --- a/src/doc/src/reference/environment-variables.md +++ b/src/doc/src/reference/environment-variables.md @@ -185,7 +185,7 @@ let version = env!("CARGO_PKG_VERSION"); * `CARGO_PKG_HOMEPAGE` — The home page from the manifest of your package. * `CARGO_PKG_REPOSITORY` — The repository from the manifest of your package. * `CARGO_CRATE_NAME` — The name of the crate that is currently being compiled. -* `CARGO_BIN_NAME` — The name of the binary that is currently being compiled (if it is a binary). +* `CARGO_BIN_NAME` — The name of the binary that is currently being compiled (if it is a binary). This name does not include any file extension, such as `.exe`. * `OUT_DIR` — If the package has a build script, this is set to the folder where the build script should place its output. See below for more information. (Only set during compilation.) From 9907039c99d9ce2ced2e6c81c7328a04a461452b Mon Sep 17 00:00:00 2001 From: Hanif Bin Ariffin Date: Wed, 3 Jun 2020 11:13:22 -0400 Subject: [PATCH 06/15] Attemtping to solve Workspace using relative path. --- src/cargo/core/workspace.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 5931a9a5c7f..bf2ca3d330c 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -145,7 +145,13 @@ impl<'cfg> Workspace<'cfg> { pub fn new(manifest_path: &Path, config: &'cfg Config) -> CargoResult> { let mut ws = Workspace::new_default(manifest_path.to_path_buf(), config); ws.target_dir = config.target_dir()?; - ws.root_manifest = ws.find_root(manifest_path)?; + + if manifest_path.is_relative() { + ws.root_manifest = Some(std::env::current_dir()?); + } else { + ws.root_manifest = ws.find_root(manifest_path)?; + } + ws.find_members()?; ws.resolve_behavior = match ws.root_maybe() { MaybePackage::Package(p) => p.manifest().resolve_behavior(), From 6eefe3c2367e269643deee609fbbd558d987bf30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 4 Jun 2020 00:44:59 +0200 Subject: [PATCH 07/15] fix clippy warnings --- crates/cargo-platform/src/error.rs | 5 +---- src/cargo/core/compiler/fingerprint.rs | 4 ++-- src/cargo/core/compiler/rustdoc.rs | 6 +++--- src/cargo/core/registry.rs | 2 +- src/cargo/core/workspace.rs | 2 +- src/cargo/lib.rs | 2 +- src/cargo/ops/cargo_install.rs | 4 ++-- src/cargo/ops/cargo_read_manifest.rs | 2 +- src/cargo/util/flock.rs | 2 +- src/cargo/util/process_builder.rs | 12 +++++------- src/cargo/util/toml/mod.rs | 2 +- tests/testsuite/main.rs | 2 +- 12 files changed, 20 insertions(+), 25 deletions(-) diff --git a/crates/cargo-platform/src/error.rs b/crates/cargo-platform/src/error.rs index 19a15a1e132..bf4b35f271d 100644 --- a/crates/cargo-platform/src/error.rs +++ b/crates/cargo-platform/src/error.rs @@ -6,6 +6,7 @@ pub struct ParseError { orig: String, } +#[non_exhaustive] #[derive(Debug)] pub enum ParseErrorKind { UnterminatedString, @@ -17,9 +18,6 @@ pub enum ParseErrorKind { IncompleteExpr(&'static str), UnterminatedExpression(String), InvalidTarget(String), - - #[doc(hidden)] - __Nonexhaustive, } impl fmt::Display for ParseError { @@ -53,7 +51,6 @@ impl fmt::Display for ParseErrorKind { write!(f, "unexpected content `{}` found after cfg expression", s) } InvalidTarget(s) => write!(f, "invalid target specifier: {}", s), - __Nonexhaustive => unreachable!(), } } } diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index 4e554202ec0..4adab7efbcf 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -894,7 +894,7 @@ impl Fingerprint { if a.name != b.name { let e = format_err!("`{}` != `{}`", a.name, b.name) .context("unit dependency name changed"); - return Err(e.into()); + return Err(e); } if a.fingerprint.hash() != b.fingerprint.hash() { @@ -906,7 +906,7 @@ impl Fingerprint { b.fingerprint.hash() ) .context("unit dependency information changed"); - return Err(e.into()); + return Err(e); } } diff --git a/src/cargo/core/compiler/rustdoc.rs b/src/cargo/core/compiler/rustdoc.rs index ad0524a2fbc..d32f2d6912f 100644 --- a/src/cargo/core/compiler/rustdoc.rs +++ b/src/cargo/core/compiler/rustdoc.rs @@ -79,7 +79,7 @@ pub fn add_root_urls( return Ok(()); } let map = config.doc_extern_map()?; - if map.registries.len() == 0 && map.std.is_none() { + if map.registries.is_empty() && map.std.is_none() { // Skip doing unnecessary work. return Ok(()); } @@ -90,13 +90,13 @@ pub fn add_root_urls( .keys() .filter_map(|name| { if let Ok(index_url) = config.get_registry_index(name) { - return Some((name, index_url)); + Some((name, index_url)) } else { log::warn!( "`doc.extern-map.{}` specifies a registry that is not defined", name ); - return None; + None } }) .collect(); diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 2f63c26203a..160ca770ad7 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -294,7 +294,7 @@ impl<'cfg> PackageRegistry<'cfg> { .expect("loaded source not present"); let summaries = source.query_vec(dep)?; let (summary, should_unlock) = - summary_for_patch(orig_patch, &locked, summaries, source).chain_err(|| { + summary_for_patch(orig_patch, locked, summaries, source).chain_err(|| { format!( "patch for `{}` in `{}` failed to resolve", orig_patch.package_name(), diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 5931a9a5c7f..aec08c79e3a 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -863,7 +863,7 @@ impl<'cfg> Workspace<'cfg> { let err = anyhow::format_err!("{}", warning.message); let cx = anyhow::format_err!("failed to parse manifest at `{}`", path.display()); - return Err(err.context(cx).into()); + return Err(err.context(cx)); } else { let msg = if self.root_manifest.is_none() { warning.message.to_string() diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 19cbd49c101..29eb110884c 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -28,7 +28,7 @@ #![allow(clippy::unneeded_field_pattern)] // false positives in target-specific code, for details see // https://github.com/rust-lang/cargo/pull/7251#pullrequestreview-274914270 -#![allow(clippy::identity_conversion)] +#![allow(clippy::useless_conversion)] use crate::core::shell::Verbosity::Verbose; use crate::core::Shell; diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 9b1b08a7254..1c7f5df9985 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -570,8 +570,8 @@ where // best-effort check to see if we can avoid hitting the network. if let Ok(pkg) = select_dep_pkg(source, dep, config, false) { let (_ws, rustc, target) = - make_ws_rustc_target(&config, opts, &source.source_id(), pkg.clone())?; - if let Ok(true) = is_installed(&pkg, config, opts, &rustc, &target, root, &dst, force) { + make_ws_rustc_target(config, opts, &source.source_id(), pkg.clone())?; + if let Ok(true) = is_installed(&pkg, config, opts, &rustc, &target, root, dst, force) { return Ok(Some(pkg)); } } diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index df1083fc30e..95975c8c153 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -112,7 +112,7 @@ fn walk(path: &Path, callback: &mut dyn FnMut(&Path) -> CargoResult) -> Ca Err(e) => { let cx = format!("failed to read directory `{}`", path.display()); let e = anyhow::Error::from(e); - return Err(e.context(cx).into()); + return Err(e.context(cx)); } }; for dir in dirs { diff --git a/src/cargo/util/flock.rs b/src/cargo/util/flock.rs index 2d732bb7ae3..985ef6e24e0 100644 --- a/src/cargo/util/flock.rs +++ b/src/cargo/util/flock.rs @@ -307,7 +307,7 @@ fn acquire( if !error_contended(&e) { let e = anyhow::Error::from(e); let cx = format!("failed to lock file: {}", path.display()); - return Err(e.context(cx).into()); + return Err(e.context(cx)); } } } diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index 953f8ae58af..f2303981402 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -381,13 +381,11 @@ mod imp { pub fn exec_replace(process_builder: &ProcessBuilder) -> CargoResult<()> { let mut command = process_builder.build_command(); let error = command.exec(); - Err(anyhow::Error::from(error) - .context(process_error( - &format!("could not execute process {}", process_builder), - None, - None, - )) - .into()) + Err(anyhow::Error::from(error).context(process_error( + &format!("could not execute process {}", process_builder), + None, + None, + ))) } } diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index b1688b85744..d39d0935600 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -163,7 +163,7 @@ and this will become a hard error in the future.", } let first_error = anyhow::Error::from(first_error); - Err(first_error.context("could not parse input as TOML").into()) + Err(first_error.context("could not parse input as TOML")) } type TomlLibTarget = TomlTarget; diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index 7aec3227b40..56c00c7a3f9 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -3,7 +3,7 @@ #![allow(clippy::blacklisted_name)] #![allow(clippy::explicit_iter_loop)] #![allow(clippy::redundant_closure)] -#![allow(clippy::block_in_if_condition_stmt)] // clippy doesn't agree with rustfmt 😂 +#![allow(clippy::blocks_in_if_conditions)] // clippy doesn't agree with rustfmt 😂 #![allow(clippy::inefficient_to_string)] // this causes suggestions that result in `(*s).to_string()` #![warn(clippy::needless_borrow)] #![warn(clippy::redundant_clone)] From 84f1dc1b5990068e2df1f0fec3656e55ed2c4b9f Mon Sep 17 00:00:00 2001 From: Hanif Bin Ariffin Date: Wed, 3 Jun 2020 11:38:34 -0400 Subject: [PATCH 08/15] Passing a relative path to Workspace now bails with proper message. Previously, this failure will return an unhelpful warning. This commit adds an error message saying that the argument for `manifest_path` must be an absolute path. --- src/cargo/core/workspace.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index bf2ca3d330c..c356f65add1 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -147,7 +147,10 @@ impl<'cfg> Workspace<'cfg> { ws.target_dir = config.target_dir()?; if manifest_path.is_relative() { - ws.root_manifest = Some(std::env::current_dir()?); + anyhow::bail!( + "manifest_path:{:?} is not an absolute path. Please provide an absolute path.", + manifest_path + ) } else { ws.root_manifest = ws.find_root(manifest_path)?; } From f975c2e5889c4a6b16568e9b68ec9ec85ec8f795 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Thu, 4 Jun 2020 16:14:17 -0700 Subject: [PATCH 09/15] Don't hash executable filenames on apple platforms. --- src/cargo/core/compiler/context/compilation_files.rs | 9 ++++++++- tests/testsuite/build.rs | 2 +- tests/testsuite/collisions.rs | 4 ++-- tests/testsuite/freshness.rs | 6 +++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/cargo/core/compiler/context/compilation_files.rs b/src/cargo/core/compiler/context/compilation_files.rs index 04d75fe0ac5..5d2cf4efce9 100644 --- a/src/cargo/core/compiler/context/compilation_files.rs +++ b/src/cargo/core/compiler/context/compilation_files.rs @@ -608,6 +608,12 @@ fn should_use_metadata(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool { // - wasm32 executables: When using emscripten, the path to the .wasm file // is embedded in the .js file, so we don't want the hash in there. // TODO: Is this necessary for wasm32-unknown-unknown? + // - apple executables: The executable name is used in the dSYM directory + // (such as `target/debug/foo.dSYM/Contents/Resources/DWARF/foo-64db4e4bf99c12dd`). + // Unfortunately this causes problems with our current backtrace + // implementation which looks for a file matching the exe name exactly. + // See https://github.com/rust-lang/rust/issues/72550#issuecomment-638501691 + // for more details. // // This is only done for local packages, as we don't expect to export // dependencies. @@ -622,7 +628,8 @@ fn should_use_metadata(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool { if (unit.target.is_dylib() || unit.target.is_cdylib() || (unit.target.is_executable() && short_name.starts_with("wasm32-")) - || (unit.target.is_executable() && short_name.contains("msvc"))) + || (unit.target.is_executable() && short_name.contains("msvc")) + || (unit.target.is_executable() && short_name.contains("-apple-"))) && unit.pkg.package_id().source_id().is_path() && env::var("__CARGO_DEFAULT_LIB_METADATA").is_err() { diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 260b0f11f76..42a72dd8db1 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -4149,7 +4149,7 @@ fn uplift_dsym_of_bin_on_mac() { assert!(p.target_debug_dir().join("foo.dSYM").is_dir()); assert!(p.target_debug_dir().join("b.dSYM").is_dir()); assert!(p.target_debug_dir().join("b.dSYM").is_symlink()); - assert!(p.target_debug_dir().join("examples/c.dSYM").is_symlink()); + assert!(p.target_debug_dir().join("examples/c.dSYM").is_dir()); assert!(!p.target_debug_dir().join("c.dSYM").exists()); assert!(!p.target_debug_dir().join("d.dSYM").exists()); } diff --git a/tests/testsuite/collisions.rs b/tests/testsuite/collisions.rs index e81ef90919f..5b94aae28ec 100644 --- a/tests/testsuite/collisions.rs +++ b/tests/testsuite/collisions.rs @@ -91,9 +91,9 @@ This may become a hard error in the future; see Date: Wed, 27 May 2020 19:33:35 +0000 Subject: [PATCH 10/15] Auto merge of #8290 - ehuss:fix-lld-freshness, r=alexcrichton Fix fingerprinting for lld on Windows with dylib. This fixes an issue where if `lld` is used on Windows, dynamic libraries will never be treated as "fresh". This is a regression from #8210 where Cargo is expecting export files to be created, but lld does not create these. The solution is to ignore "Auxiliary" files in fingerprinting, which AFAIK aren't really needed (only the primary output files really matter). Fixes #8284 --- src/cargo/core/compiler/fingerprint.rs | 2 +- tests/testsuite/freshness.rs | 36 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index 145a622bb1f..b432839850a 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -1229,7 +1229,7 @@ fn calculate_normal(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult Date: Fri, 5 Jun 2020 14:31:21 +0000 Subject: [PATCH 11/15] Auto merge of #8329 - ehuss:apple-no-hash, r=alexcrichton Don't hash executable filenames on apple platforms. Due to some recent changes to the backtrace crate, backtraces on apple platforms haven't been working (they are missing line/filename information). The reason is that previously libbacktrace would hunt through the directory for any matching file in the `.dSYM` directory. The new implementation expects a file matching the executable name exactly (which no longer includes the hash because Cargo renames it). The solution here is to not include a hash in the executable filename. This matches the behavior on Windows which does it for a similar reason (paths are embedded in pdb files). The downside is that switching between different settings (like different features) causes Cargo to rebuild the binary each time. I don't think this is a particularly common use case, at least I've not heard any complaints about this behavior on Windows. Fixes https://github.com/rust-lang/rust/issues/72550 --- src/cargo/core/compiler/context/compilation_files.rs | 9 ++++++++- tests/testsuite/build.rs | 2 +- tests/testsuite/collisions.rs | 4 ++-- tests/testsuite/freshness.rs | 6 +++--- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/cargo/core/compiler/context/compilation_files.rs b/src/cargo/core/compiler/context/compilation_files.rs index 04d75fe0ac5..5d2cf4efce9 100644 --- a/src/cargo/core/compiler/context/compilation_files.rs +++ b/src/cargo/core/compiler/context/compilation_files.rs @@ -608,6 +608,12 @@ fn should_use_metadata(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool { // - wasm32 executables: When using emscripten, the path to the .wasm file // is embedded in the .js file, so we don't want the hash in there. // TODO: Is this necessary for wasm32-unknown-unknown? + // - apple executables: The executable name is used in the dSYM directory + // (such as `target/debug/foo.dSYM/Contents/Resources/DWARF/foo-64db4e4bf99c12dd`). + // Unfortunately this causes problems with our current backtrace + // implementation which looks for a file matching the exe name exactly. + // See https://github.com/rust-lang/rust/issues/72550#issuecomment-638501691 + // for more details. // // This is only done for local packages, as we don't expect to export // dependencies. @@ -622,7 +628,8 @@ fn should_use_metadata(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool { if (unit.target.is_dylib() || unit.target.is_cdylib() || (unit.target.is_executable() && short_name.starts_with("wasm32-")) - || (unit.target.is_executable() && short_name.contains("msvc"))) + || (unit.target.is_executable() && short_name.contains("msvc")) + || (unit.target.is_executable() && short_name.contains("-apple-"))) && unit.pkg.package_id().source_id().is_path() && env::var("__CARGO_DEFAULT_LIB_METADATA").is_err() { diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 204d23cef0e..f176e77a19e 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -4149,7 +4149,7 @@ fn uplift_dsym_of_bin_on_mac() { assert!(p.target_debug_dir().join("foo.dSYM").is_dir()); assert!(p.target_debug_dir().join("b.dSYM").is_dir()); assert!(p.target_debug_dir().join("b.dSYM").is_symlink()); - assert!(p.target_debug_dir().join("examples/c.dSYM").is_symlink()); + assert!(p.target_debug_dir().join("examples/c.dSYM").is_dir()); assert!(!p.target_debug_dir().join("c.dSYM").exists()); assert!(!p.target_debug_dir().join("d.dSYM").exists()); } diff --git a/tests/testsuite/collisions.rs b/tests/testsuite/collisions.rs index e81ef90919f..5b94aae28ec 100644 --- a/tests/testsuite/collisions.rs +++ b/tests/testsuite/collisions.rs @@ -91,9 +91,9 @@ This may become a hard error in the future; see Date: Fri, 5 Jun 2020 10:15:15 -0700 Subject: [PATCH 12/15] Bump to 0.47.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e1e70d5373c..afbe02084cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo" -version = "0.46.0" +version = "0.47.0" edition = "2018" authors = ["Yehuda Katz ", "Carl Lerche ", From f05ef874bc74217510800effbbf5cb9b6a4ce02f Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Fri, 5 Jun 2020 14:04:24 -0400 Subject: [PATCH 13/15] Remove unneeded mut and loop --- src/cargo/core/resolver/resolve.rs | 7 +++--- src/cargo/ops/resolve.rs | 36 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/cargo/core/resolver/resolve.rs b/src/cargo/core/resolver/resolve.rs index 030f956cdb2..80904299f79 100644 --- a/src/cargo/core/resolver/resolve.rs +++ b/src/cargo/core/resolver/resolve.rs @@ -119,10 +119,9 @@ impl Resolve { pub fn register_used_patches(&mut self, patches: &[Summary]) { for summary in patches { - if self.iter().any(|id| id == summary.package_id()) { - continue; - } - self.unused_patches.push(summary.package_id()); + if !self.graph.contains(&summary.package_id()) { + self.unused_patches.push(summary.package_id()) + }; } } diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index e3341fe2768..7d6065374c9 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -216,15 +216,14 @@ pub fn resolve_with_previous<'cfg>( // // TODO: this seems like a hokey reason to single out the registry as being // different. - let mut to_avoid_sources: HashSet = HashSet::new(); - if let Some(to_avoid) = to_avoid { - to_avoid_sources.extend( - to_avoid - .iter() + let to_avoid_sources: HashSet = to_avoid + .map(|set| { + set.iter() .map(|p| p.source_id()) - .filter(|s| !s.is_registry()), - ); - } + .filter(|s| !s.is_registry()) + .collect() + }) + .unwrap_or_default(); let pre_patch_keep = |p: &PackageId| { !to_avoid_sources.contains(&p.source_id()) @@ -286,18 +285,23 @@ pub fn resolve_with_previous<'cfg>( // 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. - let mut try_to_use = HashSet::new(); if let Some(r) = previous { trace!("previous: {:?}", r); register_previous_locks(ws, registry, r, &keep); - - // Everything in the previous lock file we want to keep is prioritized - // in dependency selection if it comes up, aka we want to have - // conservative updates. - try_to_use.extend(r.iter().filter(keep).inspect(|id| { - debug!("attempting to prefer {}", id); - })); } + // Everything in the previous lock file we want to keep is prioritized + // in dependency selection if it comes up, aka we want to have + // conservative updates. + let try_to_use = previous + .map(|r| { + r.iter() + .filter(keep) + .inspect(|id| { + debug!("attempting to prefer {}", id); + }) + .collect() + }) + .unwrap_or_default(); if register_patches { registry.lock_patches(); From 2011649f508e63083a13214ef5c650e14a9330f6 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 5 Jun 2020 11:45:47 -0700 Subject: [PATCH 14/15] Update changelog for 1.45. --- CHANGELOG.md | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c31ec59641..652dd52e5f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,40 @@ # Changelog +## Cargo 1.46 (2020-08-27) +[9fcb8c1d...HEAD](https://github.com/rust-lang/cargo/compare/9fcb8c1d...HEAD) + +### Added + +### Changed +- A warning is now displayed if a git dependency includes a `#` fragment in + the URL. This was potentially confusing because Cargo itself displays git + URLs with this syntax, but it does not have any meaning outside of the + `Cargo.lock` file, and would not work properly. + [#8297](https://github.com/rust-lang/cargo/pull/8297) + +### Fixed +- Fixed a rare situation where an update to `Cargo.lock` failed once, but then + subsequent runs allowed it proceed. + [#8274](https://github.com/rust-lang/cargo/pull/8274) +- Removed assertion that Windows dylibs must have a `.dll` extension. Some + custom JSON spec targets may change the extension. + [#8310](https://github.com/rust-lang/cargo/pull/8310) +- Updated libgit2, which brings in a fix for zlib errors for some remote + git servers like googlesource.com. + [#8320](https://github.com/rust-lang/cargo/pull/8320) + +### Nightly only +- Added `-Zrustdoc-map` feature which provides external mappings for rustdoc + (such as https://docs.rs/ links). + [docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#rustdoc-map) + [#8287](https://github.com/rust-lang/cargo/pull/8287) +- Fixed feature calculation when a proc-macro is declared in `Cargo.toml` with + an underscore (like `proc_macro = true`). + [#8319](https://github.com/rust-lang/cargo/pull/8319) + + ## Cargo 1.45 (2020-07-16) -[ebda5065e...HEAD](https://github.com/rust-lang/cargo/compare/ebda5065e...HEAD) +[ebda5065e...rust-1.45.0](https://github.com/rust-lang/cargo/compare/ebda5065...rust-1.45.0) ### Added @@ -29,11 +62,105 @@ directory. Some obscure scenarios can cause an old dylib to be referenced between builds, and this ensures that all the latest copies are used. [#8139](https://github.com/rust-lang/cargo/pull/8139) +- `package.exclude` can now match directory names. If a directory is + specified, the entire directory will be excluded, and Cargo will not attempt + to inspect it further. Previously Cargo would try to check every file in the + directory which could cause problems if the directory contained unreadable + files. + [#8095](https://github.com/rust-lang/cargo/pull/8095) +- When packaging with `cargo publish` or `cargo package`, Cargo can use git to + guide its decision on which files to include. Previously this git-based + logic required a `Cargo.toml` file to exist at the root of the repository. + This is no longer required, so Cargo will now use git-based guidance even if + there is not a `Cargo.toml` in the root of the repository. + [#8095](https://github.com/rust-lang/cargo/pull/8095) +- While unpacking a crate on Windows, if it fails to write a file because the + file is a reserved Windows filename (like "aux.rs"), Cargo will display an + extra message to explain why it failed. + [#8136](https://github.com/rust-lang/cargo/pull/8136) +- Failures to set mtime on files are now ignored. Some filesystems did not + support this. + [#8185](https://github.com/rust-lang/cargo/pull/8185) +- Certain classes of git errors will now recommend enabling + `net.git-fetch-with-cli`. + [#8166](https://github.com/rust-lang/cargo/pull/8166) +- When doing an LTO build, Cargo will now instruct rustc not to perform + codegen when possible. This may result in a faster build and use less disk + space. Additionally, for non-LTO builds, Cargo will instruct rustc to not + embed LLVM bitcode in libraries, which should decrease their size. + [#8192](https://github.com/rust-lang/cargo/pull/8192) + [#8226](https://github.com/rust-lang/cargo/pull/8226) + [#8254](https://github.com/rust-lang/cargo/pull/8254) +- The implementation for `cargo clean -p` has been rewritten so that it can + more accurately remove the files for a specific package. + [#8210](https://github.com/rust-lang/cargo/pull/8210) +- The way Cargo computes the outputs from a build has been rewritten to be + more complete and accurate. Newly tracked files will be displayed in JSON + messages, and may be uplifted to the output directory in some cases. Some of + the changes from this are: + + - `.exp` export files on Windows MSVC dynamic libraries are now tracked. + - Proc-macros on Windows track import/export files. + - All targets (like tests, etc.) that generate separate debug files + (pdb/dSYM) are tracked. + - Added .map files for wasm32-unknown-emscripten. + - macOS dSYM directories are tracked for all dynamic libraries + (dylib/cdylib/proc-macro) and for build scripts. + + There are a variety of other changes as a consequence of this: + + - Binary examples on Windows MSVC with a hyphen will now show up twice in + the examples directory (`foo_bar.exe` and `foo-bar.exe`). Previously Cargo + just renamed the file instead of hard-linking it. + - Example libraries now follow the same rules for hyphen/underscore + translation as normal libs (they will now use underscores). + + [#8210](https://github.com/rust-lang/cargo/pull/8210) +- Cargo attempts to scrub any secrets from the debug log for HTTP debugging. + [#8222](https://github.com/rust-lang/cargo/pull/8222) +- Context has been added to many of Cargo's filesystem operations, so that + error messages now provide more information, such as the path that caused + the problem. + [#8232](https://github.com/rust-lang/cargo/pull/8232) +- Several commands now ignore the error if stdout or stderr is closed while it + is running. For example `cargo install --list | grep -q cargo-fuzz` would + previously sometimes panic because `grep -q` may close stdout before the + command finishes. Regular builds continue to fail if stdout or stderr is + closed, matching the behavior of many other build systems. + [#8236](https://github.com/rust-lang/cargo/pull/8236) +- If `cargo install` is given an exact version, like `--version=1.2.3`, it + will now avoid updating the index if that version is already installed, and + exit quickly indicating it is already installed. + [#8022](https://github.com/rust-lang/cargo/pull/8022) +- Changes to the `[patch]` section will now attempt to automatically update + `Cargo.lock` to the new version. It should now also provide better error + messages for the rare cases where it is unable to automatically update. + [#8248](https://github.com/rust-lang/cargo/pull/8248) ### Fixed - Fixed copying Windows `.pdb` files to the output directory when the filename contained dashes. [#8123](https://github.com/rust-lang/cargo/pull/8123) +- Fixed error where Cargo would fail when scanning if a package is inside a + git repository when any of its ancestor paths is a symlink. + [#8186](https://github.com/rust-lang/cargo/pull/8186) +- Fixed `cargo update` with an unused `[patch]` so that it does not get + stuck and refuse to update. + [#8243](https://github.com/rust-lang/cargo/pull/8243) +- Fixed a situation where Cargo would hang if stderr is closed, and the + compiler generated a large number of messages. + [#8247](https://github.com/rust-lang/cargo/pull/8247) +- Fixed backtraces on macOS not showing filenames or line numbers. As a + consequence of this, binary executables on apple targets do not include a + hash in the filename in Cargo's cache. This means Cargo can only track one + copy, so if you switch features or rustc versions, Cargo will need to + rebuild the executable. + [#8329](https://github.com/rust-lang/cargo/pull/8329) + [#8335](https://github.com/rust-lang/cargo/pull/8335) +- Fixed fingerprinting when using lld on Windows with a dylib. Cargo was + erroneously thinking the dylib was never fresh. + [#8290](https://github.com/rust-lang/cargo/pull/8290) + [#8335](https://github.com/rust-lang/cargo/pull/8335) ### Nightly only - Fixed passing the full path for `--target` to `rustdoc` when using JSON spec @@ -44,9 +171,22 @@ - Added new `resolver` field to `Cargo.toml` to opt-in to the new feature resolver. [#8129](https://github.com/rust-lang/cargo/pull/8129) +- `-Zbuild-std` no longer treats std dependencies as "local". This means that + it won't use incremental compilation for those dependencies, removes them + from dep-info files, and caps lints at "allow". + [#8177](https://github.com/rust-lang/cargo/pull/8177) +- Added `-Zmultitarget` which allows multiple `--target` flags to build the + same thing for multiple targets at once. + [docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#multitarget) + [#8167](https://github.com/rust-lang/cargo/pull/8167) +- Added `strip` option to the profile to remove symbols and debug information. + [docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#profile-strip-option) + [#8246](https://github.com/rust-lang/cargo/pull/8246) +- Fixed panic with `cargo tree --target=all -Zfeatures=all`. + [#8269](https://github.com/rust-lang/cargo/pull/8269) ## Cargo 1.44 (2020-06-04) -[bda50510...ebda5065e](https://github.com/rust-lang/cargo/compare/bda50510...ebda5065e) +[bda50510...rust-1.44.0](https://github.com/rust-lang/cargo/compare/bda50510...rust-1.44.0) ### Added - 🔥 Added the `cargo tree` command. @@ -96,6 +236,10 @@ [#8090](https://github.com/rust-lang/cargo/pull/8090) - Added a certain class of HTTP2 errors as "spurious" that will get retried. [#8102](https://github.com/rust-lang/cargo/pull/8102) +- Allow `cargo package --list` to succeed, even if there are other validation + errors (such as `Cargo.lock` generation problem, or missing dependencies). + [#8175](https://github.com/rust-lang/cargo/pull/8175) + [#8215](https://github.com/rust-lang/cargo/pull/8215) ### Fixed - Cargo no longer buffers excessive amounts of compiler output in memory. @@ -115,6 +259,8 @@ - Protect against some (unknown) situations where Cargo could panic when the system monotonic clock doesn't appear to be monotonic. [#8114](https://github.com/rust-lang/cargo/pull/8114) +- Fixed panic with `cargo clean -p` if the package has a build script. + [#8216](https://github.com/rust-lang/cargo/pull/8216) ### Nightly only - Fixed panic with new feature resolver and required-features. From 45523c23dadf4721aa7b69ba2e25f36e499a8a87 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 7 Jun 2020 15:09:47 -0700 Subject: [PATCH 15/15] Fix tree completions. --- src/etc/_cargo | 13 +++++-------- src/etc/cargo.bashcomp.sh | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/etc/_cargo b/src/etc/_cargo index ce257ab0bdb..f906d149168 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -274,16 +274,13 @@ _cargo() { tree) _arguments -s -S $common $features $triple $manifest \ '(-p --package)'{-p+,--package=}'[package to use as the root]:package:_cargo_package_names' \ - '--no-filter-targets[return dependencies for all targets]' \ - '--no-dev-dependencies[skip dev dependencies]' \ - '(-i --invert)'{-i,--invert}'[invert the tree]' \ - '--no-indent[display as a list]' \ - '--prefix-depth[display as a list with numeric depth]' \ + '(-i --invert)'{-i+,--invert=}'[invert the tree for the given package]:package:_cargo_package_names' \ + '--prefix=[line prefix]:prefix:(depth indent none)' \ '--no-dedupe[repeat shared dependencies]' \ '(-d --duplicates)'{-d,--duplicates}'[packages with multiple versions]' \ - '--charset=[utf8 or ascii]' \ - '(-f --format)'{-f,--format=}'[format string]' \ - '--graph-features[show features]' \ + '--charset=[utf8 or ascii]:charset:(utf8 ascii)' \ + '(-f --format)'{-f,--format=}'[format string]:format' \ + '(-e --edges)'{-e,--edges=}'[edge kinds]:kind:(features normal build dev all no-dev no-build no-normal)' \ ;; uninstall) diff --git a/src/etc/cargo.bashcomp.sh b/src/etc/cargo.bashcomp.sh index e7f0af04093..aa6626f1114 100644 --- a/src/etc/cargo.bashcomp.sh +++ b/src/etc/cargo.bashcomp.sh @@ -73,7 +73,7 @@ _cargo() local opt__rustdoc="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --target --release --open --target-dir --profile" local opt__search="$opt_common $opt_lock --limit --index --registry" local opt__test="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --doc --target --no-run --release --no-fail-fast --target-dir --profile" - local opt__tree="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock --target --no-filter-targets --no-dev-dependencies -i --invert --no-indent --prefix-depth --no-dedupe --duplicates -d --charset -f --format --graph-features" + local opt__tree="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock --target -i --invert --prefix --no-dedupe --duplicates -d --charset -f --format -e --edges" local opt__uninstall="$opt_common $opt_lock $opt_pkg --bin --root" local opt__update="$opt_common $opt_mani $opt_lock $opt_pkg --aggressive --precise --dry-run" local opt__vendor="$opt_common $opt_mani $opt_lock $opt_sync --no-delete --respect-source-config --versioned-dirs"