fix#15656
### What does this PR try to resolve?
This PR implements custom TAB completer for cargo remove <package_name>.
### How to test and review this PR?
This patch works like this:
```console
$ cat Cargo.toml
[package]
name = "sandbox"
version = "0.1.0"
edition = "2024"
[dependencies]
rand = "0.9.1"
serde_json = "1"
$ ~/cargo/target/debug/cargo remove
completing values
--build -- Remove from build-dependencies
--color -- Coloring
--config -- Override a configuration value
--dev -- Remove from dev-dependencies
--dry-run -- Don't actually write the manifest
--frozen -- Equivalent to specifying both --locked and --offline
--help -- Print help
--locked -- Assert that `Cargo.lock` will remain unchanged
--lockfile-path -- Path to Cargo.lock (unstable)
--manifest-path -- Path to Cargo.toml
--offline -- Run without accessing the network
--package -- Package to remove from
--quiet -- Do not print cargo log messages
--target -- Remove from target-dependencies
--verbose -- Use verbose output (-vv very verbose/build.rs output)
-Z -- Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
rand serde_json
```
(on zsh)
### What does this PR try to resolve?
ref https://github.com/rust-lang/cargo/issues/14834
As described in the issue, we want to move IndexPackage into
cargo-util-schemas. However, it contains InternedString fields, which we
don't want to expose as part of the public API.
This PR replaces InternedString with Cow.
And also, as @weihanglo's suggested, I implemented the From/Into trait
to simplify code.
From Cow tarit implementation: [`42f593f`
(#15559)](42f593fa72)
Replace InternedString with `into()` across the whole codebase:
[`5f90098`
(#15559)](5f900981de)
I am unsure if it worsens the readability. Feel free to comment.
### How should we test and review this PR?
It shouldn't change or break any tests.
Benchmark 1:
https://github.com/rust-lang/cargo/pull/15559#issuecomment-2913155520
Benchmark 2:
https://github.com/rust-lang/cargo/pull/15559#issuecomment-2927304675
### Additional information
None
The `is_false` function already exists in the standard library, as
`Not::not`; use that in `skip_serializing_if` rather than defining an
`is_false` function.
The `is_false` function already exists in the standard library, as
`Not::not`; use that in `skip_serializing_if` rather than defining an
`is_false` function.
In #15639, @weihanglo noted that one of the lint tests passed in CI, but
locally it would fail as it had a hyperlink added to its output. The
root cause appears to be the recent update to `anstyle-svg@0.1.8`, which
added support for hyperlinks, combined with our hyperlink support
autodetection, disabling them in CI, but allowing them locally. To
ensure we are consistently handling hyperlinks, I made them always
enabled for UI tests. This seemed like the best option given that we
already force colors for UI tests, and it allows us to test our
hyperlink output.
### What does this PR try to resolve?
As of #15625, the manifest path argument in `cargo clippy
--manifest-path foo/Cargo.toml --fix` will be ignored. All the workspace
members will be built. The cause is due to the `reload` usage in
`cargo::ops::fix`. We reload the `root_manifest` in the function, which
contains all workspace members.
Will close#15625.
### How to test and review this PR?
The first commit in the PR demonstrates the current problem, and the
second commit corrects it. Use `cargo test --test testsuite
workspaces::fix_only_check_manifest_path_member` to see the test
results.
### What does this PR try to resolve?
Telling people they are free to hit ctrl-c while waiting for packages
could mean some packages may not be published and the user wouldn't know
until they get a complaint about a missing package.
Instead, if there are remaining packages, we'll tell the user that.
Fixes#15005
### How to test and review this PR?
### What does this PR try to resolve?
The `clippy::perf` lint group is fairly useful for catching bad
practices that might hurt performance marginally.
This PR fixes most of them except `clippy::large_enum_variant`, which
doesn't feel right at this moment and need more researches. And that is
why I didn't enable the lint group.
### How to test and review this PR?
The `clippy::perf` lint group is fairly useful for catching bad
practices that might hurt performance marginally.
This PR fixes most of them except `clippy::large_enum_variant`,
which doesn't feel right at this moment and need more researches.
Anyway, overall this PR should be good.
### What does this PR try to resolve?
As of #13947, `-Zpackage-workspace` made `cargo package` require extra
arguments when it didn't need it before. When a packaging operation will
resolve dependencies, we need to know what registry packages would be
published to in order to correctly generate the overlay to generate the
right lockfile.
We skipped this if there were no dependencies, so no overlay was going
to be used, to reduce the impact of this.
This change goes a step further and only runs the check if the resolver
will run. This should mean that `-Zpackage-workspace` should now only
error when `cargo package` would have failed before.
### How to test and review this PR?
To verify this, the existing failure tests were forked, removing
`-Zpackage-workspace`, and then `--exclude-lockfile`, `--no-verify`, and
`--exclude-lockfile --no-verify` variants were added to characterize
when the check is behavior-neutral vs not needed and that the behavior
is now the same.
_Thanks for the pull request 🎉!_
_Please read the contribution guide: <https://doc.crates.io/contrib/>._
### What does this PR try to resolve?
Bash and Zsh `cargo add` completion option `--offline`
_Explain the motivation behind this change._
_A clear overview along with an in-depth explanation are helpful._
### How to test and review this PR?
_Demonstrate how you test this change and guide reviewers through your
PR._
_With a smooth review process, a pull request usually gets reviewed
quicker._
Previously, libsecret was repeatedly loaded and unloaded—at least twice
during cargo login (once for action get and once for action login). This
caused issues where calls could hang indefinitely due to glib failing to
clean up properly (some threads still running after unloading) and
generating numerous error messages:
```
cargo login --registry ownreg
Updating `ownreg` index
please paste the token for ownreg below
(process:100727): GLib-GObject-CRITICAL **: 08:59:54.568: cannot register existing type 'SecretService'
(process:100727): GLib-GObject-CRITICAL **: 08:59:54.568: cannot add private field to invalid (non-instantiatable) type '<invalid>'
(process:100727): GLib-GObject-CRITICAL **: 08:59:54.568: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
(process:100727): GLib-GObject-CRITICAL **: 08:59:54.568: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
(process:100727): GLib-GObject-CRITICAL **: 08:59:54.568: cannot register existing type 'SecretBackend'
(process:100727): GLib-GObject-CRITICAL **: 08:59:54.568: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed
(process:100727): GLib-GObject-CRITICAL **: 08:59:54.568: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed
(process:100727): GLib-CRITICAL **: 08:59:54.568: g_once_init_leave_pointer: assertion 'result != 0' failed
(process:100727): GLib-GObject-CRITICAL **: 08:59:54.568: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
```
Now, libsecret is stored in a OnceLock, ensuring it is only loaded once,
preventing unnecessary unload/reload cycles.
Fixes#15603
Previously, LibSecretCredential was created multiple times and with it
libsecret was loaded and unloaded multiple times, leading to issues
where calls could run indefinitely due to glib not properly cleaning up.
Now, LibSecretCredential is stored in a OnceLock, ensuring it is only
created once, preventing unnecessary unload/reload cycles of libsecret.
### What does this PR try to resolve?
Attempting to reduce the size of the stabilization PR so the
stabilization changes are more obvious, without pulling something out
that is meaningless.
### How to test and review this PR?
### What does this PR try to resolve?
Found this as I was preparing for stabilization.
As we create a graph of packages to ensure publish order, a self-cycle
shouldn't matter, so we can skip tracking it.
### How to test and review this PR?