dont call wrap in a no-op source_id::with*
### What does this PR try to resolve?
When running resolution in parallel (which my pubgrub tests do but cargo does not) there can be a lot of contention on the lock for constructing new `source_id`. When investigating much of this is due to `without_precise` in `encodable_package_id` in `check_duplicate_pkgs_in_lockfile`. There are many ways to solve this, the simplest seems to be to return `self` if the requested modification made no difference.
### How should we test and review this PR?
All tests still pass and it's an internal re-factor.
In addition running all crates on crates.io through cargoes resolver in parallel on 190 cores went from >20k sec cpu time to ~10k.
### Additional information
Fix warnings building tests on Windows
This fixes a few warnings when building cargo's testsuite on Windows due to some imports only being used inside some `cfg` elided tests.
Package workspaces
Adds support for packaging an entire workspace, even when there are dependencies between the crates. The generated packages should be identical to the ones produced by packaging and publishing the crates one-by-one in dependency order, but the main benefit of this PR is that the packages can be created and verified locally before anything is published.
The main mechanism is the one in #13926, where we create a temporary local registry that "overlays" the true registry. We "publish" the crates in the local registry, which enables lockfile generation and verification of the dependent crates.
This adds `--registry` and `--index` flags to `cargo package`. They act
much like the same arguments to `cargo publish`, except that of course
we are not actually publishing to the specified registry. Instead, these
arguments affect lock-file generation for intra-workspace dependencies:
when simultaneously packaging a crate and one of its dependencies, the
lock-file will be generated under the assumption that the dependency
will be published to the specified registry.
You can also publish a subset of a workspace using `-p` arguments. In this case, there will be an error unless the chosen subset contains all of the dependencies of everything in the subset.
Fixes#10948. Based on #13926.
### Compatibility issue
This PR introduces a case where `cargo package` will fail where it did not before: if you have a workspace containing two packages, `main` and `dep@0.1.0`, where `main` depends on `dep@0.1.0` and `dep@0.1.0` is already published in crates.io then attempting to package the whole workspace will fail. To be specific, it will package `dep@0.1.0` successfully and then fail when trying to package `main` because it will see the two different packages for `dep@0.1.0`. Note that `cargo publish` will already fail in this scenario.
This shouldn't interfere with crates.io running `cargo package` for each package to diff the `.crate` files
- This might interfere if someone tried to verify their "published" MSRV by running `cargo package`.
The failure could be avoided by changing the local overlay source to not error out if there's a duplicate package; see [here](https://github.com/rust-lang/cargo/pull/13926#discussion_r1606822615). However, failing early has the advantage of catching errors early.
test: migrate messages to snapbox
### What does this PR try to resolve?
Part of https://github.com/rust-lang/cargo/issues/14039.
Migrate following to snapbox:
- `tests/testsuite/messages.rs`
chore: Update dependencies
I just published all of my packages using Cargo 1.80 and wanted to see the effect of the enumerating targets during publish (#13849).
fix: remove rustc probe for `--check-cfg` support
### What does this PR try to resolve?
This is a follow-up to #13571 as now everything for `-Z check-cfg` is stabilized.
### How should we test and review this PR?
Existing test suite passes.
### Additional information
Misc test clean up
### What does this PR try to resolve?
Part of this is a follow up to #14293.
Part of this is a follow up to some of #14039's work.
### How should we test and review this PR?
### Additional information
Don't downgrade on prerelease `VersionReq` when update with --breaking.
### What does this PR try to resolve?
Do nothing with prerelease when update with `--breaking`.
Fixes https://github.com/rust-lang/cargo/issues/14178
### How should we test and review this PR?
Previous commit add a test, next commit to fix and update.
### Additional information
test: Migrate some json tests to snapbox
### What does this PR try to resolve?
This builds on assert-rs/snapbox#348 and is part of #14039.
Note: this also updates existing `.is_jsonlines()` usage to `.is_json().against_jsonlines()`.
### How should we test and review this PR?
### Additional information
Revert "fix: Ensure dep/feature activates the dependency on 2024"
### What does this PR try to resolve?
Fixes#14283 by re-opening #14016 so we don't block people testing other Edition 2024 changes.
### How should we test and review this PR?
This reverts commit 99fae9187ac0bae12a03585083169e34dc7a197d.
I initially held off on reverting in case we quickly had a clear direction to go. Since we're still doing some investigation, I decided to move forward with this.
### Additional information
Fixes#14283 by re-opening #14016 so we don't block people testing other
Edition 2024 changes.
This reverts commit 99fae9187ac0bae12a03585083169e34dc7a197d.
Takes local dependencies into account when packaging a workspace. Builds
a temporary package registry to provide local dependencies, and overlays
it on the upstream registry.
This adds `--registry` and `--index` flags to `cargo package`. They act
much like the same arguments to `cargo publish`, except that of course
we are not actually publishing to the specified registry. Instead, these
arguments affect lock-file generation for intra-workspace dependencies:
when simultaneously packaging a crate and one of its dependencies, the
lock-file will be generated under the assumption that the dependency
will be published to the specified registry.
Co-Authored-By: Tor Hovland <55164+torhovland@users.noreply.github.com>
chore: bump cargo-test-support to 0.4.0
### What does this PR try to resolve?
These PRs have contributed to major changes:
* https://github.com/rust-lang/cargo/pull/14266
* https://github.com/rust-lang/cargo/pull/14269
* https://github.com/rust-lang/cargo/pull/14270
### How should we test and review this PR?
### Additional information
Error log:
```
Checking cargo-test-support v0.3.0 -> v0.3.1 (minor change)
Checked [ 0.079s] 66 checks; 63 passed, 3 failed, 6 unnecessary
--- failure function_missing: pub fn removed or renamed ---
Description:
A publicly-visible function cannot be imported by its prior path. A `pub use` may have been removed, or the function itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/function_missing.ron
Failed in:
function cargo_test_support::install::cargo_home, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/install.rs:27
function cargo_test_support::path2url, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/lib.rs:1187
--- failure struct_missing: pub struct removed or renamed ---
Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/struct_missing.ron
Failed in:
struct cargo_test_support::RawOutput, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/lib.rs:524
--- failure trait_missing: pub trait removed or renamed ---
Description:
A publicly-visible trait cannot be imported by its prior path. A `pub use` may have been removed, or the trait itself may have been renamed or removed entirely.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.31.0/src/lints/trait_missing.ron
Failed in:
trait cargo_test_support::TestEnv, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/lib.rs:1272
trait cargo_test_support::prelude::TestEnv, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/lib.rs:1272
trait cargo_test_support::ChannelChanger, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/lib.rs:1252
trait cargo_test_support::prelude::ChannelChanger, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/lib.rs:1252
trait cargo_test_support::CargoCommand, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/lib.rs:1388
trait cargo_test_support::prelude::CargoCommand, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/lib.rs:1388
trait cargo_test_support::ArgLine, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/lib.rs:1402
trait cargo_test_support::prelude::ArgLine, previously in file /projects/cargo/target/semver-checks/git-a2b58c3dad4d554ba01ed6c45c41ff85390560f2/e5a046bb78236b6c7eddf006d3a5ac7b4a5593aa/crates/cargo-test-support/src/lib.rs:1402
Summary semver requires new major version: 3 major and 0 minor checks failed
```