Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into tmp2
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanAD committed Nov 13, 2022
2 parents aa58f9b + f5cdfa4 commit aa50042
Show file tree
Hide file tree
Showing 95 changed files with 2,338 additions and 260 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ jobs:

# Deny warnings on CI to avoid warnings getting into the codebase.
- run: cargo test --features 'deny-warnings'
# The testsuite generates a huge amount of data, and fetch-smoke-test was
# running out of disk space.
- name: Clear test output
run: |
df -h
rm -rf target/tmp
df -h
- name: Check operability of rustc invocation with argfile
env:
__CARGO_TEST_FORCE_ARGFILE: 1
Expand Down Expand Up @@ -111,7 +118,7 @@ jobs:
cargo check --manifest-path benches/capture/Cargo.toml
# The testsuite generates a huge amount of data, and fetch-smoke-test was
# running out of disk space.
- name: Clear test output
- name: Clear benchmark output
run: |
df -h
rm -rf target/tmp
Expand Down
125 changes: 124 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,137 @@
# Changelog

## Cargo 1.67 (2023-01-26)
[7e484fc1...HEAD](https://github.com/rust-lang/cargo/compare/7e484fc1...HEAD)

### Added

- `cargo remove` now cleans up the root workspace manifest after a
successful removal of an inherited dependency from a workspace member.
[#11242](https://github.com/rust-lang/cargo/pull/11242)
- `cargo package` and `cargo publish` now report total and compressed crate size
after packaging.
[#11270](https://github.com/rust-lang/cargo/pull/11270)
- Suggests `cargo fix` when some compilation warnings/errors can be auto-fixed.
[#10989](https://github.com/rust-lang/cargo/pull/10989)

### Changed

- ❗ Cargo now reuses the value of `$CARGO` if it's already set in the environment,
and forwards the value when executing external subcommands and build scripts.
[#11285](https://github.com/rust-lang/cargo/pull/11285)
- Updated the internal HTTP library libcurl with various fixes and updates.
[#11307](https://github.com/rust-lang/cargo/pull/11307)
[#11326](https://github.com/rust-lang/cargo/pull/11326)

### Fixed

- Fixed `cargo clean` for removing fingerprints and build script
artifacts of only the requested package
[#10621](https://github.com/rust-lang/cargo/pull/10621)

### Nightly only

## Cargo 1.66 (2022-12-15)
[08250398...HEAD](https://github.com/rust-lang/cargo/compare/08250398...HEAD)
[08250398...rust-1.66.0](https://github.com/rust-lang/cargo/compare/08250398...rust-1.66.0)

### Added

- 🎉 Added `cargo remove` command for removing dependencies from `Cargo.toml`.
[docs](https://doc.rust-lang.org/nightly/cargo/commands/cargo-remove.html)
[#11059](https://github.com/rust-lang/cargo/pull/11059)
[#11099](https://github.com/rust-lang/cargo/pull/11099)
[#11193](https://github.com/rust-lang/cargo/pull/11193)
[#11204](https://github.com/rust-lang/cargo/pull/11204)
[#11227](https://github.com/rust-lang/cargo/pull/11227)
- Added support for git dependencies having git submodules with relative paths.
[#11106](https://github.com/rust-lang/cargo/pull/11106)
- Cargo now sends requests with a `Accept-Encoding` header to registries.
[#11292](https://github.com/rust-lang/cargo/pull/11292)
- Cargo now forwards non-UTF8 arguments to external subcommands.
[#11118](https://github.com/rust-lang/cargo/pull/11118)

### Changed

- ❗ Disambiguate source replacements from various angles.
[RFC-3289](https://github.com/rust-lang/rfcs/blob/master/text/3289-source_replacement_ambiguity.md)
[#10907](https://github.com/rust-lang/cargo/pull/10907)
- When the crates-io source is replaced, the user is required to specify which registry to use with `--registry <NAME>` when performing an API operation.
- Publishing to source-replaced crates.io is no longer permitted using the crates.io token (`registry.token`).
- In source replacement, the `replace-with` key can reference the name of an alternative registry in the `[registries]` table.
-`cargo publish` now blocks until it sees the published package in the index.
[#11062](https://github.com/rust-lang/cargo/pull/11062)
[#11210](https://github.com/rust-lang/cargo/pull/11210)
[#11216](https://github.com/rust-lang/cargo/pull/11216)
[#11255](https://github.com/rust-lang/cargo/pull/11255)
- Cargo now uses the clap v4 library for command-line argument parsing.
[#11116](https://github.com/rust-lang/cargo/pull/11116)
[#11119](https://github.com/rust-lang/cargo/pull/11119)
[#11159](https://github.com/rust-lang/cargo/pull/11159)
[#11190](https://github.com/rust-lang/cargo/pull/11190)
[#11239](https://github.com/rust-lang/cargo/pull/11239)
[#11280](https://github.com/rust-lang/cargo/pull/11280)
- Cargo now only warns on a user-defined alias shadowing an external command.
[#11170](https://github.com/rust-lang/cargo/pull/11170)
- Several documentation improvements.
[#10770](https://github.com/rust-lang/cargo/pull/10770)
[#10938](https://github.com/rust-lang/cargo/pull/10938)
[#11082](https://github.com/rust-lang/cargo/pull/11082)
[#11093](https://github.com/rust-lang/cargo/pull/11093)
[#11157](https://github.com/rust-lang/cargo/pull/11157)
[#11185](https://github.com/rust-lang/cargo/pull/11185)
[#11207](https://github.com/rust-lang/cargo/pull/11207)
[#11219](https://github.com/rust-lang/cargo/pull/11219)
[#11240](https://github.com/rust-lang/cargo/pull/11240)
[#11241](https://github.com/rust-lang/cargo/pull/11241)
[#11282](https://github.com/rust-lang/cargo/pull/11282)

### Fixed

- ❗ Config file loaded via `cargo --config <file>` now takes priority over
environment variables. This is a documented behaviour but the old
implementation accidentally got it wrong.
[#11077](https://github.com/rust-lang/cargo/pull/11077)
- ❗ Cargo collects rustflags in `target.cfg(…).rustflags` more correctly
and warns if that's not enough for convergence.
[#11114](https://github.com/rust-lang/cargo/pull/11114)
- Final artifacts not removed by linker should be removed before a compilation gets started.
[#11122](https://github.com/rust-lang/cargo/pull/11122)
- `cargo add` now reports unknown features in a more discoverable manner.
[#11098](https://github.com/rust-lang/cargo/pull/11098)
- Cargo now reports command aliasing failure with more error contexts.
[#11087](https://github.com/rust-lang/cargo/pull/11087)
- A better error message when `cargo login` prompt receives empty input.
[#11145](https://github.com/rust-lang/cargo/pull/11145)
- A better error message for fields with wrong types
where workspace inheritance is supported.
[#11113](https://github.com/rust-lang/cargo/pull/11113)
- A better error message when mixing feature syntax `dep:` with `/`.
[#11172](https://github.com/rust-lang/cargo/pull/11172)
- A better error message when publishing but `package.publish` is `false`
in the manifest.
[#11280](https://github.com/rust-lang/cargo/pull/11280)

### Nightly only

- Added new config option `publish.timeout` behind `-Zpublish-timeout`.
[docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#publish-timeout)
[#11230](https://github.com/rust-lang/cargo/pull/11230)
- Added retry support to sparse registries.
[#11069](https://github.com/rust-lang/cargo/pull/11069)
- Fixed sparse registry lockfile urls containing `registry+sparse+`.
[#11177](https://github.com/rust-lang/cargo/pull/11177)
- Add new config option `registries.crates-io.protocol`
for controlling crates.io protocol.
[#11215](https://github.com/rust-lang/cargo/pull/11215)
- Removed `sparse+` prefix for index.crates.io.
[#11247](https://github.com/rust-lang/cargo/pull/11247)
- Fixed publishing with a dependency on a sparse registry.
[#11268](https://github.com/rust-lang/cargo/pull/11268)
- Fixed confusing error messages when using `-Zsparse-registry`.
[#11283](https://github.com/rust-lang/cargo/pull/11283)
- Fixed 410 gone response handling for sparse registries.
[#11286](https://github.com/rust-lang/cargo/pull/11286)

## Cargo 1.65 (2022-11-03)
[4fd148c4...rust-1.65.0](https://github.com/rust-lang/cargo/compare/4fd148c4...rust-1.65.0)

Expand Down Expand Up @@ -75,6 +196,8 @@
- Scanning the package directory now ignores errors from broken
but excluded symlink files.
[#11008](https://github.com/rust-lang/cargo/pull/11008)
- Fixed deadlock when build scripts are waiting for input on stdin.
[#11257](https://github.com/rust-lang/cargo/pull/11257)

### Nightly

Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo"
version = "0.67.0"
version = "0.68.0"
edition = "2021"
license = "MIT OR Apache-2.0"
homepage = "https://crates.io"
Expand All @@ -21,11 +21,11 @@ bytesize = "1.0"
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" }
curl = { version = "0.4.43", features = ["http2"] }
curl-sys = "0.4.55"
curl = { version = "0.4.44", features = ["http2"] }
curl-sys = "0.4.59"
env_logger = "0.9.0"
pretty_env_logger = { version = "0.4", optional = true }
anyhow = "1.0"
anyhow = "1.0.47"
filetime = "0.2.9"
flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] }
git2 = "0.15.0"
Expand Down Expand Up @@ -101,7 +101,7 @@ features = [
cargo-test-macro = { path = "crates/cargo-test-macro" }
cargo-test-support = { path = "crates/cargo-test-support" }
same-file = "1.0.6"
snapbox = { version = "0.3.0", features = ["diff", "path"] }
snapbox = { version = "0.4.0", features = ["diff", "path"] }

[build-dependencies]
flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] }
Expand Down
3 changes: 1 addition & 2 deletions crates/cargo-test-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ anyhow = "1.0.34"
cargo-test-macro = { path = "../cargo-test-macro" }
cargo-util = { path = "../cargo-util" }
crates-io = { path = "../crates-io" }
snapbox = { version = "0.3.0", features = ["diff", "path"] }
snapbox = { version = "0.4.0", features = ["diff", "path"] }
filetime = "0.2"
flate2 = { version = "1.0", default-features = false, features = ["zlib"] }
git2 = "0.15.0"
glob = "0.3"
itertools = "0.10.0"
lazy_static = "1.0"
remove_dir_all = "0.5"
serde_json = "1.0"
tar = { version = "0.4.38", default-features = false }
termcolor = "1.1.2"
Expand Down
1 change: 1 addition & 0 deletions crates/cargo-test-support/src/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ fn substitute_macros(input: &str) -> String {
("[REMOVING]", " Removing"),
("[DOCTEST]", " Doc-tests"),
("[PACKAGING]", " Packaging"),
("[PACKAGED]", " Packaged"),
("[DOWNLOADING]", " Downloading"),
("[DOWNLOADED]", " Downloaded"),
("[UPLOADING]", " Uploading"),
Expand Down
8 changes: 6 additions & 2 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,10 @@ impl Project {
/// Example:
/// p.cargo("build --bin foo").run();
pub fn cargo(&self, cmd: &str) -> Execs {
let mut execs = self.process(&cargo_exe());
let cargo = cargo_exe();
let mut execs = self.process(&cargo);
if let Some(ref mut p) = execs.process_builder {
p.env("CARGO", cargo);
p.arg_line(cmd);
}
execs
Expand Down Expand Up @@ -1328,7 +1330,9 @@ impl ArgLine for snapbox::cmd::Command {
}

pub fn cargo_process(s: &str) -> Execs {
let mut p = process(&cargo_exe());
let cargo = cargo_exe();
let mut p = process(&cargo);
p.env("CARGO", cargo);
p.arg_line(s);
execs().with_process_builder(p)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-test-support/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl CargoPathExt for Path {
// actually performing the removal, but we don't care all that much
// for our tests.
if meta.is_dir() {
if let Err(e) = remove_dir_all::remove_dir_all(self) {
if let Err(e) = fs::remove_dir_all(self) {
panic!("failed to remove {:?}: {:?}", self, e)
}
} else if let Err(e) = fs::remove_file(self) {
Expand Down
1 change: 1 addition & 0 deletions crates/cargo-test-support/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ impl Drop for HttpServerHandle {
}

/// Request to the test http server
#[derive(Clone)]
pub struct Request {
pub url: Url,
pub method: String,
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ walkdir = "2.3.1"
core-foundation = { version = "0.9.0", features = ["mac_os_10_7_support"] }

[target.'cfg(windows)'.dependencies]
miow = "0.3.6"
miow = "0.4.0"
winapi = { version = "0.3.9", features = ["consoleapi", "minwindef"] }
4 changes: 2 additions & 2 deletions crates/cargo-util/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ pub fn create_dir_all_excluded_from_backups_atomic(p: impl AsRef<Path>) -> Resul
// it from backups, then rename it to the desired name. If we created the
// directory directly where it should be and then excluded it from backups
// we would risk a situation where cargo is interrupted right after the directory
// creation but before the exclusion the the directory would remain non-excluded from
// creation but before the exclusion the directory would remain non-excluded from
// backups because we only perform exclusion right after we created the directory
// ourselves.
//
Expand All @@ -653,7 +653,7 @@ pub fn create_dir_all_excluded_from_backups_atomic(p: impl AsRef<Path>) -> Resul
// the directory being created concurrently by another thread or process as success,
// hence the check below to follow the existing behavior. If we get an error at
// rename() and suddently the directory (which didn't exist a moment earlier) exists
// we can infer from it it's another cargo process doing work.
// we can infer from it's another cargo process doing work.
if let Err(e) = fs::rename(tempdir.path(), path) {
if !path.exists() {
return Err(anyhow::Error::from(e));
Expand Down
4 changes: 2 additions & 2 deletions crates/cargo-util/src/process_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ impl ProcessBuilder {
///
/// Ref:
///
/// - https://doc.rust-lang.org/rustdoc/command-line-arguments.html#path-load-command-line-flags-from-a-path
/// - https://doc.rust-lang.org/rustc/command-line-arguments.html#path-load-command-line-flags-from-a-path>
/// - <https://doc.rust-lang.org/rustdoc/command-line-arguments.html#path-load-command-line-flags-from-a-path>
/// - <https://doc.rust-lang.org/rustc/command-line-arguments.html#path-load-command-line-flags-from-a-path>
pub fn retry_with_argfile(&mut self, enabled: bool) -> &mut Self {
self.retry_with_argfile = enabled;
self
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Run with 'cargo -Z [FLAG] [COMMAND]'",
}
};
config_configure(config, &expanded_args, subcommand_args, global_args)?;
super::init_git_transports(config);
super::init_git(config);

execute_subcommand(config, cmd, subcommand_args)
}
Expand Down
53 changes: 53 additions & 0 deletions src/bin/cargo/commands/remove.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use cargo::core::dependency::DepKind;
use cargo::core::Workspace;
use cargo::ops::cargo_remove::remove;
use cargo::ops::cargo_remove::RemoveOptions;
use cargo::ops::resolve_ws;
use cargo::util::command_prelude::*;
use cargo::util::toml_mut::manifest::DepTable;
use cargo::util::toml_mut::manifest::LocalManifest;
use cargo::CargoResult;

pub fn cli() -> clap::Command {
clap::Command::new("remove")
Expand Down Expand Up @@ -85,6 +88,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
remove(&options)?;

if !dry_run {
// Clean up workspace dependencies
gc_workspace(&workspace, &options.dependencies)?;

// Reload the workspace since we've changed dependencies
let ws = args.workspace(config)?;
resolve_ws(&ws)?;
Expand Down Expand Up @@ -114,3 +120,50 @@ fn parse_section(args: &ArgMatches) -> DepTable {

table
}

/// Clean up workspace dependencies which no longer have a reference to them.
fn gc_workspace(workspace: &Workspace<'_>, dependencies: &[String]) -> CargoResult<()> {
let mut manifest: toml_edit::Document =
cargo_util::paths::read(workspace.root_manifest())?.parse()?;

let members = workspace
.members()
.map(|p| LocalManifest::try_new(p.manifest_path()))
.collect::<CargoResult<Vec<_>>>()?;

for dep in dependencies {
if !dep_in_workspace(dep, &members) {
remove_workspace_dep(dep, &mut manifest);
}
}

cargo_util::paths::write(workspace.root_manifest(), manifest.to_string().as_bytes())?;

Ok(())
}

/// Get whether or not a dependency is depended upon in a workspace.
fn dep_in_workspace(dep: &str, members: &[LocalManifest]) -> bool {
members.iter().any(|manifest| {
manifest.get_sections().iter().any(|(_, table)| {
table
.as_table_like()
.unwrap()
.get(dep)
.and_then(|t| t.get("workspace"))
.and_then(|v| v.as_bool())
.unwrap_or(false)
})
})
}

/// Remove a dependency from a workspace manifest.
fn remove_workspace_dep(dep: &str, ws_manifest: &mut toml_edit::Document) {
if let Some(toml_edit::Item::Table(table)) = ws_manifest
.get_mut("workspace")
.and_then(|t| t.get_mut("dependencies"))
{
table.set_implicit(true);
table.remove(dep);
}
}
Loading

0 comments on commit aa50042

Please sign in to comment.