The rustc `-Zhint-mostly-unused` flag tells rustc that most of a crate
will go unused. This is useful for speeding up compilation of large
dependencies from which you only use a few items. Plumb that option
through as a profile option, to allow specifying it for specific
dependencies:
```toml
[profile.dev.package.huge-mostly-unused-dependency]
hint-mostly-unused = true
```
To enable this feature, pass `-Zprofile-hint-mostly-unused`. However,
since this option is a hint, using it without passing
`-Zprofile-hint-mostly-unused` will only warn and ignore the profile
option. Versions of Cargo prior to the introduction of this feature will
give an "unused manifest key" warning, but will otherwise function
without erroring. This allows using the hint in a crate's `Cargo.toml`
without mandating the use of a newer Cargo to build it.
Add a test verifying that the profile option gets ignored with a warning
without passing `-Zprofile-hint-mostly-unused`, and another test
verifying that it gets handled when passing
`-Zprofile-hint-mostly-unused`.
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._