20287 Commits

Author SHA1 Message Date
Josh Triplett
e44bde554d Respect capped lints for dependencies 2025-07-12 14:55:10 -07:00
Josh Triplett
78b4afb4f3 Expand test to produce warnings for deps, which will subsequently get capped 2025-07-12 14:54:56 -07:00
Josh Triplett
9949fa8a66 Include package ID in warnings to identify affected crate 2025-07-12 14:47:27 -07:00
Josh Triplett
28b9762466 Add stable documentation for the [hints] table 2025-07-12 14:47:22 -07:00
Josh Triplett
fe86023863 Parse hints permissively to allow for future expansion
Make it only a warning, not an error, to have a hint value of the wrong
type.
2025-07-11 16:54:36 -07:00
Josh Triplett
0c5ea24f13 Add documentation for hints.mostly-unused 2025-07-11 16:54:36 -07:00
Josh Triplett
1921d097ca Add [hints] table in Cargo.toml, and a hints.mostly-unused hint
The `[hints]` table in a `Cargo.toml` manifest provides optional
information that Cargo can use for building the package, and will use
even when using the package as a dependency. All hints can be safely
ignored, and Cargo only warns about unknown hints, but does not error.
This allows packages to use hints without depending on new Cargo.

Add a `mostly-unused` hint, which allows a package to hint that most
users of the package will not use most of its items. This is useful for
improving the build performance of crates with large dependencies.

Crates can override this hint using `hint-mostly-unused = false` in
their profile for a dependency.
2025-07-11 16:54:36 -07:00
Josh Triplett
f415c112f9 Add additional tests for hints.mostly-unused (showing existing behavior)
These tests demonstrate the behavior of current Cargo, and will be
changed when adding `hints.mostly-unused` to reflect the new behavior.
2025-07-11 16:54:36 -07:00
Josh Triplett
a206766e43 Add initial version of hints tests, to show pre-[hints] Cargo behavior
These tests show what prior versions of Cargo will do with hints.
The subsequent addition of support for hints will modify these tests to
reflect the corresponding changes to Cargo.
2025-07-11 16:54:30 -07:00
Josh Triplett
8fd9309102 Remove unnecessary parentheses around closure body, to fix unused-parens warning 2025-07-11 16:54:19 -07:00
Ed Page
eabb4cd923
feat: Implementation and tests for multiple-build-scripts (#15704)
Hi Everyone!

This is PR for the implementation of the first milestone of [GSoC
Project : Build Script
Delegation](https://summerofcode.withgoogle.com/programs/2025/projects/nUt4PdAA)

This will provide actual implementation for #15630

### What does this PR try to resolve?

Now, multiple build scripts are parsed, this PR aims to implement the
functioning the feature. This PR will allow users to use multiple build
scripts, and is backward compatible with single script as well as
boolean values.

**Motivation :** This will help users to maintain separate smaller and
cleaner build scripts instead of one large build script. This is also
necessary for build script delegation.

Deferred
- Accessing each build script's `OUT_DIR`: This will be handled in a
follow up PR. For now, each build script writes to its own `OUT_DIR` and
`OUT_DIR` for the regular build targets is set to the build script with
the **lexicographically largest** name..
- User control over which build script wins in a conflict. This will be
handled in a follow up PR. If two build scripts write to the same env
variable, which gets applied to the binary? Currently, its the build
script with the **lexicographically largest** name. This makes it
deterministic. With some futzing, users can control this for now.
However, with build script delegation, users won't be able to control
this. We likely want it based off of the order the user assigns into the
build script array.
- Something about linking a C library is actually preferring
**lexicographically smallest** name. We should handle conflicts
consistently. We need to dig into what parts are doing it based on
smallest and make sure that whatever priority scheme we use for env
variables applies here as well.

### How to test and review this PR?

There is a feature gate `multiple-build-scripts` that can be passed via
`cargo-features` in `Cargo.toml`. So, you have to add
```toml
cargo-features = ["multiple-build-scripts"]
```
Preferably on the top of the `Cargo.toml` and use nightly toolchain to
use the feature
2025-07-09 22:07:55 +00:00
Naman Garg
bfb869748c
Use Vector for build script Units and UnitHash 2025-07-10 03:02:58 +05:30
Naman Garg
a24abd6fc2
Add multiple build scripts to unit deps 2025-07-10 03:02:34 +05:30
Weihang Lo
f9ee73d6b7
perf: Speed up TOML parsing by upgrading toml (#15736)
### What does this PR try to resolve?

For numbers, see https://epage.github.io/blog/2025/07/toml-09/

Further areas for improvement:
- Enable `fast_hash` (see #15649)
- Only track spans for local manifests, allowing us to skip the
`make_owned` call for most packages

### How to test and review this PR?
2025-07-09 16:18:12 +00:00
Naman Garg
72290ad03a
Replace build with check in test rerun_untracks_other_files 2025-07-09 02:38:52 +05:30
Naman Garg
e9df793c47
Add tests for multiple build scripts execution 2025-07-09 02:38:50 +05:30
Ed Page
194fe22da6 perf: Speed up TOML parsing by switching BTreeMap to IndexMap 2025-07-08 13:08:58 -05:00
Ed Page
ad8fb2f0c9 refactor(manifest): Switch from toml_edit to toml
Technically this will cause a small regression in performance from
`toml_edit@0.23` but not `toml_edit@0.22`
2025-07-08 13:01:29 -05:00
Ed Page
6e04449c27 refactor: Resolve deprecations 2025-07-08 12:02:29 -05:00
Ed Page
539a48452a perf: Update toml 2025-07-08 11:55:41 -05:00
Weihang Lo
8f80388a78
Mark cachelock tests that rely on interprocess blocking behaviour as unsupported on AIX. (#15734)
This PR marks several tests within cache_lock.rs as unsupported on the
AIX platform. The tests relies on flock() behaviour that is not
supported on AIX.
2025-07-08 15:47:06 +00:00
Uyiosa Iyekekpolor
bc43610058 mark cachelock tests that rely on interprocess blocking behaviour as unsuported on AIX 2025-07-08 10:09:25 -04:00
Weihang Lo
0322bdd37a
feat(publish): Stabilize multi-package publishing (#15636)
### What does this PR try to resolve?

A user will now be able to use flags like `--workspace` with `cargo
publish`.
`cargo package` will now also work with those flags without having to
pass `--no-verify --exclude-lockfile`.

Many release tools have come out that solve this problem. They will
still need a lot of the logic that went into that for other parts of the
release process.
However, a cargo-native solution allows for:
- Verification during dry-run
- Better strategies for waiting for the publish timeout

`cargo publish` is non-atomic at this time.
If there is a server side error, network error, or rate limit during the
publish, the workspace will be left in a partially published state.
Verification is done before any publishing so that won't affect things.
There are multiple strategies we can employ for improving this over
time, including
- atomic publish
- `--idempotent` (#13397)
- leave this to release tools to manage

This includes support for `--dry-run` verification. As release tools
didn't have a way to do this before, users may be surprised at how slow
this is because a `cargo build` is done instead of a `cargo check`. This
is being tracked in #14941.

This adds to `cargo package` the `--registry` and `--index` flags to
help with resolving dependencies when depending on a package being
packaged at that moment.
These flags are only needed when a `cargo package --workspace` operation
would have failed before due to inability to find a locally created
dependency.

Regarding the publish timeout, `cargo publish --workspace` publishes
packages in batches and we only timeout if nothing in the batch has
finished being published within the timeout, deferring the rest to the
next wait-for-publish. So for example, if you have packages `a`, `b`,
`c` then we'll wait up to 60 seconds and if only `a` and `b` were ready
in that time, we'll then wait another 60 seconds for `c`.

During testing, users ran into issues with `.crate` checksums:
- ~~#15647~~ Fixed for `cargo publish --dry-run` in #15711
  - But `cargo package` still has the problem
- #14396 (not been able to reproduce)
- #15622 (reproducible with consecutive `cargo publish` calls)

Fixes #1169
Fixes #10948

### How to test and review this PR?

By stabilizing this, Cargo's behavior becomes dependent on an overlay
registry.
When generating a lockfile or verifying a package, we overlay the
locally generated `.crate` files on top of the registry so the registry
appears as it would and everything works.
If there is a conflict with a version, the local version wins which is
important for the dry-run mode of release tools as they won't have
bumped the version yet.
Our concern for the overlay registry is dependency confusion attacks.
Considering this is not accessible for general user operations, this
should be fine.
2025-07-07 21:54:46 +00:00
Weihang Lo
463e483346
Update to Rust 2024 (#15732)
This updates all crates to Rust 2024.
2025-07-06 11:39:11 +00:00
Eric Huss
e24a9865ac Apply deprecated_safe_2024 2025-07-05 20:17:36 -07:00
Eric Huss
639143579a Bump crate versions 2025-07-05 19:57:28 -07:00
Eric Huss
2d02d5a203 Ignore rustfmt 2024 commit 2025-07-05 19:51:10 -07:00
Eric Huss
1ce8023626 Rustfmt 2024 2025-07-05 19:50:36 -07:00
Eric Huss
fb0c7c99cf Update all crates to 2024 edition 2025-07-05 19:39:17 -07:00
Eric Huss
9d710a98a1 Apply unsafe_op_in_unsafe_fn 2025-07-05 19:29:43 -07:00
Eric Huss
b637a5fe83 Apply impl_trait_overcaptures 2025-07-05 19:29:29 -07:00
Eric Huss
a0d1859575 Apply keyword_idents_2024 2025-07-05 19:29:09 -07:00
Eric Huss
24813db9da Apply missing_unsafe_on_extern 2025-07-05 19:28:38 -07:00
Eric Huss
1213fc652b Apply rust_2024_incompatible_pat 2025-07-05 19:27:01 -07:00
Weihang Lo
425af55326
Clarify package ID specifications in SBOMs are fully qualified (#15731)
### What does this PR try to resolve?

cargo-auditable 0.7.0 will use the unstable Cargo SBOM precursor files
if a user configures Cargo to generate the SBOM files. cargo-auditable
assumes that the package ID specifiers in Cargo SBOM files are fully
qualified.

We'd like to enforce this assumption in Cargo so we can keep our package
ID spec parsing simpler by not considering non-fully qualified package
ID specs. This PR updates the cargo docs to state where fully qualified
package ID specs are used, and also adds SBOMs to the existing `cargo
pkgid` test that is currently enforcing consistency between the various
usages of fully qualified package id specs.

Previously raised at [#t-cargo > sbom missing name, version, source @
💬](https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/sbom.20missing.20name.2C.20version.2C.20source/near/525443447)

### How to test and review this PR?

Change doesn't affect current behaviour.
2025-07-05 22:44:26 +00:00
Tom Fay
6713b1ad46 generalize cargo's use of fully qualified
rather than providing an exhaustive list
2025-07-05 21:58:47 +01:00
Tom Fay
c74fadc0e5 Enforce pkgid and sbom consistency
clarify fully qualified package ID usage in docs
2025-07-05 20:59:07 +01:00
Ed Page
1743cb890d
chore(deps): update cargo-semver-checks to v0.42.0 (#15730)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
|
[cargo-semver-checks](https://redirect.github.com/obi1kenobi/cargo-semver-checks)
| minor | `0.41.0` -> `0.42.0` |

---

### Release Notes

<details>
<summary>obi1kenobi/cargo-semver-checks (cargo-semver-checks)</summary>

###
[`v0.42.0`](https://redirect.github.com/obi1kenobi/cargo-semver-checks/compare/v0.41.0...v0.42.0)

[Compare
Source](https://redirect.github.com/obi1kenobi/cargo-semver-checks/compare/v0.41.0...v0.42.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - Every minute ( * * * * * ) (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/rust-lang/cargo).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNy4yIiwidXBkYXRlZEluVmVyIjoiNDEuMTcuMiIsInRhcmdldEJyYW5jaCI6Im1hc3RlciIsImxhYmVscyI6W119-->
2025-07-05 16:41:32 +00:00
renovate[bot]
9b91ef09fe
chore(deps): update cargo-semver-checks to v0.42.0 2025-07-05 16:08:44 +00:00
Weihang Lo
848e5a23c0
test: Switch config tests to use snapshots (#15729)
### What does this PR try to resolve?

This is prep for updating `toml` which will change some of these error
messages

### How to test and review this PR?
2025-07-05 15:38:48 +00:00
Ed Page
3488e267ee test: Switch config tests to use snapshots 2025-07-05 10:04:44 -05:00
Ed Page
e4162389d6
implement package feature unification (#15684)
### What does this PR try to resolve?

Implements another part of feature unification (#14774,
[rfc](1c590ce05d/text/3692-feature-unification.md)).
The `workspace` option was implemented in #15157, this adds the
`package` option.

### How to test and review this PR?

The important change is changing `WorkspaceResolve` so it can contain
multiple `ResolvedFeature`s. Along with that, it also needs to know
which specs those features are resolved for. This was used in several
other places:
- `cargo fix --edition` (from 2018 to 2021) - I think it should be ok to
disallow using `cargo fix --edition` when someone already uses this
feature.
- building std - it should be safe to assume std is not using this
feature so I just unwrap there. I'm not sure if some attempt to later
feature unification would be better.
- `cargo tree` - I just use the first feature set. This is definitely
not ideal, but I'm not entirely sure what's the correct solution here.
Printing multiple trees? Disallowing this, forcing users to select only
one package?

Based on comments in #15157 I've added tests first with `selected`
feature unification and then changed that after implementation. I'm not
sure if that's how you expect the tests to be added first, if not, I can
change the history.

I've expanded the test checking that this is ignored for `cargo install`
although it should work the same way even if it is not ignored
(`selected` and `package` are the same thing when just one package is
selected).
2025-07-02 19:44:20 +00:00
Eric Huss
eba6d5b032
chore: Upgrade dependencies (#15722)
### What does this PR try to resolve?

Replaces #15718, #15719

### How to test and review this PR?
2025-07-01 23:31:34 +00:00
David Mládek
e4a616b6fd docs: fix outdated doc comment 2025-07-02 00:01:52 +02:00
David Mládek
0be420bb78 docs: update unstable docs on feature unificatin 2025-07-02 00:01:52 +02:00
David Mládek
70f16f448b feat: add the package feature unification option 2025-07-02 00:01:52 +02:00
David Mládek
73b5b33e1d refactor(resolve): allow multiple resolved feature sets in workspace resolve 2025-07-02 00:01:52 +02:00
David Mládek
403f1e12f6 tests: add future package feature unification tests 2025-07-02 00:01:51 +02:00
Ed Page
714157308b
Report valid file name when we can't find a build target for name = "foo.rs" (#15707)
fixes #15703
2025-07-01 20:49:34 +00:00
Marijn Schouten
6eb5adcc50 bad_config: replace cargo build with cargo check 2025-07-01 19:55:58 +00:00