11264 Commits

Author SHA1 Message Date
Joe Neeman
3e1a989611 Support package-selection arguments in cargo publish 2024-10-09 14:36:27 +07:00
bors
15fbd2f607 Auto merge of #14137 - Xaeroxe:checksum-freshness, r=weihanglo
initial version of checksum based freshness

Implementation for https://github.com/rust-lang/cargo/issues/14136 and resolves https://github.com/rust-lang/cargo/issues/6529

This PR implements the use of checksums in cargo fingerprints as an alternative to using mtimes. This is most useful on systems with poor mtime implementations.

This has a dependency on https://github.com/rust-lang/rust/pull/126930. It's expected this will increase the time it takes to declare a build to be fresh. Still this loss in performance may be preferable to the issues the ecosystem has had with the use of mtimes for determining freshness.
2024-10-08 21:08:11 +00:00
Jacob Kiesel
b9420f87cf
Add appropriate documentation 2024-10-08 16:29:44 -04:00
Jacob Kiesel
f4ca739073
implement checksum freshness fingerprints for cargo 2024-10-08 16:29:44 -04:00
bors
ac39e69a0f Auto merge of #14656 - shannmu:_cargo_publish_registry_completer, r=epage
feat: Add custom completer for completing registry name

### What does this PR try to resolve?
Tracking issue https://github.com/rust-lang/cargo/issues/14520

Add custom completer for completing `cargo publish --registry <TAB>` and `cargo add --registry <TAB>`.
2024-10-08 16:42:13 +00:00
bors
42a774bb8a Auto merge of #14657 - ehuss:deprecate-build-plan, r=epage
Document build-plan as being deprecated

This adds a note to the build-plan documentation that it is deprecated. I do not think it will make any progress as it is. In the future, we should remove the feature (#7902), possibly with a code-warning ahead of time.
2024-10-08 16:07:10 +00:00
Eric Huss
bc2eba1333 Document build-plan as being deprecated 2024-10-08 08:57:17 -07:00
shannmu
245cba27db feat: Add custom completer for completing registry name 2024-10-08 23:50:00 +08:00
bors
9026f9565c Auto merge of #14653 - epage:complete, r=ehuss
fix(complete): Don't complete files for any value

### What does this PR try to resolve?
We now need to opt-in to path completions for values, which can be as simple as setting the value parser to be for `PathBuf`s.

We'll now show a lot less irrelevant completions.

### How should we test and review this PR?

### Additional information
2024-10-08 15:35:41 +00:00
bors
fbcd9bb571 Auto merge of #14464 - linyihai:issue-14194, r=weihanglo
fix: avoid inserting duplicate `dylib_path_envvar` when calling `cargo run` recursively

### What does this PR try to resolve?

If the current program started by `cargo run` recursively call into `cargo run`, the second `cargo run` will insert  `search_path`  into `dylib_path_envvar` again.

Fixes #14194

### How should we test and review this PR?

The first commit adds the test to reflect the issue. The first call to `cargo run` stores the dylib search path env var to a file. Subsequent calls verify that env var remains the same.

The second commit fixes the behavior by checking if env vars in `search_path` are a prefix of the slice of env vars in `dylib_path_envvar`.
2024-10-08 12:51:33 +00:00
Lin Yihai
54dbc2bf66 fix: Avoid inserting search_path again. 2024-10-08 16:20:21 +08:00
Ed Page
244578e9e2 fix(complete): Don't complete files for any value
We now need to opt-in to path completions for values, which can be as
simple as setting the value parser to be for `PathBuf`s.

We'll now show a lot less irrelevant completions.
2024-10-07 21:01:03 -05:00
Lucas Kent
1623c414ad improve error reporting when feature not found in activated_features 2024-10-05 17:10:54 -04:00
bors
e1179b5507 Auto merge of #14636 - epage:msrv-policy, r=weihanglo
docs(ref): Expand on MSRV

### What does this PR try to resolve?

The need for this has been growing and becomes especially important with the upcoming MSRV aware resolver
We will be making having an MSRV easier so we need to meet those maintainers where they are and help them.

In particular, this covers
- What setting an MSRV does
- What "support" in MSRV means, according to the definition we developed during the review of [RFC 3537](https://rust-lang.github.io/rfcs/3537-msrv-resolver.html)
- Background and guidance on setting an MSRV policy

### How should we test and review this PR?

### Additional information

This intentionally leaves out anything related to the MSRV-aware resolver as that will be handled as the feature is stabilized.
2024-10-04 17:04:01 +00:00
Ed Page
b48e5f1e5f docs(ref): Step users through MSRV policies 2024-10-03 16:14:11 -05:00
Ed Page
9ae75338c1 docs(ref): Set Rust version support expectations 2024-10-03 16:14:11 -05:00
Ed Page
17ecc17ea9 docs(ref): Expand on uses of Rust version 2024-10-03 16:14:11 -05:00
Ed Page
e38e966d0d docs(ref): Change from rust-version from compilation to support 2024-10-03 16:14:10 -05:00
Ed Page
1652c3bdb2 docs(ref): Split rust-version into its own chapter 2024-10-03 16:11:52 -05:00
bors
a06986cda6 Auto merge of #14638 - epage:msrv-feat, r=ehuss
docs(ref): Highleft whats left for msrv-policy

### What does this PR try to resolve?

While there is a tracking issue for these,
I didn't want to have everything under `msrv-policy` to be stabilized,
making it look like it should be moved to the Stable section of the
page, when there are independently stabilizable pieces missing.

### How should we test and review this PR?

### Additional information

This is prep for stabilizing MSRV-aware resover
2024-10-03 16:45:54 +00:00
Ed Page
cb2bcc938b docs(ref): Highleft whats left for msrv-policy
While there is a tracking issue for these,
I didn't want to have everything under `msrv-policy` to be stabilized,
making it look like it should be moved to the Stable section of the
page, when there are independently stabilizable pieces missing.
2024-10-03 10:17:46 -05:00
Ed Page
ade52cfe3f docs(ref): Have msrv-policy feature link to RFC 2024-10-03 10:13:52 -05:00
Ed Page
3a0236fb90 docs: Group dep related references 2024-10-03 08:23:46 -05:00
Ed Page
1dde071548 docs: Move Cache topic from Guide to Reference
It doesn't "guide" people through a topic but explains in a more
top-down fashion what caches exist and is not particularly a common
topic people need to know.
2024-10-03 08:23:45 -05:00
Ed Page
a3eaa4b92b docs: Move publishing from ref to guide 2024-10-03 08:23:03 -05:00
Yuri Astrakhan
f64f11d518
Update src/doc/src/reference/build-script-examples.md
Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
2024-10-02 23:59:40 -04:00
Yuri Astrakhan
3654e61843
Fix cargo:version_number - has only one :
See [openssl code](8d60e21146/openssl-sys/build/main.rs (L392)):

```rust
let openssl_version = openssl_version.unwrap();
println!("cargo:version_number={:x}", openssl_version);
if openssl_version >= 0x4_00_00_00_0 {
...
```
2024-10-02 22:48:33 -04:00
Ed Page
5c87c14f9a docs: Declare support level for each crate in our Charter / docs
This is to bring us into conformance with the [Rust crate ownership
policy](https://forge.rust-lang.org/policies/crate-ownership.html).

Items of note
- `cargo-credential-1password` is declared as Experimental as it is
  intended for the community but I was unsure if we wanted to commit to
  full support for it.  In my mind, the ideal thing to do would be to
  expatriate this to 1password.
- `home` is declared as Internal despite its wide use within the
  ecosystem.
- `cargo-credential` is declared as Intentional as its an API intended
  for the wider ecosystem and I didn't see a reason to declare it
  experimental.
- `cargo-platform`, `cargo-util-schemas`, and `crates-io` are declared
  as Intentional as they are both used internally and intended for
  others to use for logic that integrates with cargo/registries.
  I wondered about these being Experimental or Internal instead.
2024-09-26 12:43:09 -05:00
bors
d9c14e664e Auto merge of #14632 - xzfc:tar-0.4.42, r=weihanglo
chore(deps): update tar to 0.4.42

The new version of tar enables the creation of sparse tar archives by default.  The ability to read such sparse entries was added in tar 0.4.6, which has been in use starting from Cargo 0.13 and Rust 1.12. Additionally, `docker cp` doesn't support sparse tar entries in the GNU format.  For compatibility with older versions of Rust and Cargo, as well as with `docker cp`, this commit disables sparse archive creation everywhere the `tar::Builder` is used.

Closes #14594. CC: `@weihanglo,` `@alexcrichton.`
2024-10-02 04:34:21 +00:00
xzfc
0c74d2449d chore(deps): update tar to 0.4.42
The new version of tar enables the creation of sparse tar archives by
default.  The ability to read such sparse entries was added in tar
0.4.6, which has been in use starting from Cargo 0.13 and Rust 1.12.
Additionally, `docker cp` doesn't support sparse tar entries in the GNU
format.  For compatibility with older versions of Rust and Cargo, as
well as with `docker cp`, this commit disables sparse archive creation
in the corresponding cases where the `tar::Builder` is used.  See
#14594.
2024-10-02 03:27:27 +00:00
bors
fd5f1a05c1 Auto merge of #14630 - epage:implicit-removal, r=weihanglo
fix: Remove implicit feature removal

### What does this PR try to resolve?

Due to problems we ran into with #14016, we're removing implicit features from the 2024 edition to give ourselves more time to design it as we should.

### How should we test and review this PR?

### Additional information

I could have added a new flag for this or made an EditionNext but I decided to remove it in the hopes to avoid any path dependency in solving this the next time.
2024-10-01 20:06:46 +00:00
Weihang Lo
b4253e5057
fix(help): mention --config <PATH> in help text 2024-10-01 14:54:52 -04:00
Weihang Lo
6269ab4dd9
docs(config): make --config <PATH> more prominent 2024-10-01 14:31:10 -04:00
Ed Page
7be5a2146b fix: Remove implicit feature removal
Due to problems we ran into with #14016, we're removing implicit
features from the 2024 edition to give ourselves more time to design it
as we should.

I could have added a new flag for this or made an EditionNext but I
decided to remove it in the hopes to avoid any path dependency in
solving this the next time.
2024-10-01 11:48:31 -05:00
bors
2fd7321ee4 Auto merge of #14619 - epage:msrv-docs, r=weihanglo
docs(ref): Clean up language for `package.rust-version`

### What does this PR try to resolve?

Some small tweaks I noticed as I was working on putting in more MSRV policy guidance.

### How should we test and review this PR?

### Additional information
2024-09-30 21:25:54 +00:00
Weihang Lo
828c7ef16f
docs: clarify target.'cfg(...)' doesnt respect cfg from build script
This was a mistake, see https://github.com/rust-lang/cargo/issues/14306
2024-09-30 16:40:47 -04:00
Ed Page
d74f02e642 docs(ref): Group all functional comments 2024-09-30 15:25:42 -05:00
Ed Page
f51524c0b7 docs(ref): Fix mistake on how many fields a rust-version must include 2024-09-30 15:25:09 -05:00
Ed Page
fe70046edd docs(ref): Remove reference to interplay of rust-version/edition
Ideally, we have rust-version checks on more fields and we shouldn't have to specify
every variant of this.

By removing this, it gives us more breathing room to expand the text
more generally.
2024-09-30 15:24:15 -05:00
Ed Page
f42831b356 docs(ref): Remove duplicate MSRV comment about MSRV
Previousl, we've added a -note to each item in a consistent style.
2024-09-30 15:23:15 -05:00
bors
5e2878f786 Auto merge of #14608 - weihanglo:deserialize, r=epage
refactor(compiler): zero-copy deserialization when possible
2024-09-29 02:05:25 +00:00
bors
2d368ed844 Auto merge of #14583 - x-hgg-x:features-sat-resolver, r=Eh2406
test: add support for features in the sat resolver

### What does this PR try to resolve?

This PR implements the first step of https://github.com/rust-lang/cargo/pull/11938#issuecomment-1868426431.

### How should we test and review this PR?

The first commit does some refactorings, and the second commit updates the SAT resolver.

List of boolean variables in the SAT resolver:
* One variable representing the activation of each registry package.
* One variable representing the activation of each feature of a given registry package.
* In the `sat_resolve()` method, we create an additional representing the activation of the root package.

List of clauses in the SAT resolver:
* If a package feature is activated, then the package should be activated.
* No two packages with the same links set.
* No two semver compatible versions of the same package.
* For each package:
    - For each feature:
        - If the package feature is activated and it depends of another feature of the same package, then it is also activated.
        - If the package feature is activated and it depends of a dependency, then at least one of the compatible dependency package should be activated.
        - If the package feature is activated and it depends of a feature of a dependency, then the feature of a compatible dependency package should be activated only if the compatible dependency package is activated. If this is not a weak dependency feature, then at least one of the compatible dependency package should be activated.
    - For each dependency, if the package is activated and if the dependency is non-optional or has been activated, then at least one of the compatible dependency package and its required features should be activated.
* The root package has the same dependency clauses but has no features.

List of assumptions in the SAT resolver:
* The root package is activated.
* Old root packages from previous calls to `sat_resolve()` are deactivated. This is necessary since the proptest call `sat_resolve()` several times with a different root package using the same SAT resolver, and clauses relative to the root package are not removable.
2024-09-27 21:29:29 +00:00
Weihang Lo
d6b740f6f3
refactor: use Cow on artifact notification
`artifact` field is an (absolute) path to emitted artifact like
/home/projects/foo/target/debug/deps/libbar-73d672db2af2c9a8.rmeta

It is worth not copying them.
2024-09-27 17:18:47 -04:00
Weihang Lo
cdba1c7bee
refactor: use RawValue::from_string for potential perf win 2024-09-27 17:07:38 -04:00
Weihang Lo
9a6a9451ba
refactor: zero-copy deserialization when possible
Found this during PR review.

We could leverage `#[serde(borrow)]` for zero-copy deserialization for
messages from the compiler.

We can't use `&str` fields because they may contain escape sequences
in the future, which fails the deserialization.
See https://github.com/serde-rs/json/issues/742
2024-09-27 17:06:44 -04:00
bors
1fad770250 Auto merge of #14556 - Ifropc:lockfile-path-install, r=weihanglo
feat: lockfile path implies --locked on cargo install

Follow-up of https://github.com/rust-lang/cargo/issues/14421
Resolving one of the items
> cargo install should make --lockfile-path imply --locked

Simply mirrored behavior as if `--locked` was provided (on creating the workspace)
2024-09-27 16:57:50 +00:00
bors
b396f2c3aa Auto merge of #14591 - epage:autolib, r=weihanglo
feat(toml): Add `autolib`

### What does this PR try to resolve?

PR #5335 added `autobins`, etc for #5330.  Nowhere in there is
discussion of `autolib`.

Cargo script disables support for additional build-targets by disabling
discovery.
Except we don't have a way to disable discovery of `autolib`, leading to #14476.
By adding `autolib`, we can continue in that direction.

This also allows us to bypass inferring of libs on published packages,
like all other build-targets which were handled in #13849.

Fixes #14476

### How should we test and review this PR?

### Additional information

As this seems fairly low controversy, this insta-stabilizes the field.
In prior versions of Cargo, users will get an "unused manifest key"
warning.
For packages where this is set by `cargo publish`, the warning will be suppressed and things will work as normal.
For `cargo vendor`, the same except there will be some churn in the
vendored source as this field will now be set.
For local development, it should be rare to set `autolib` so the lack of
error by discovering a file when this is set shouldn't be a problem.
2024-09-27 12:25:16 +00:00
bors
a3b35a0ccc Auto merge of #14598 - yichi170:correct-error-count, r=weihanglo
fix: correct error count for `cargo check --message-format json`

Hi! This is my first time contributing to Cargo. If there is anything that I need to do, please let me know!
(I'm not sure whether the commit message is aligned with the Cargo's convention. If it doesn't, I'm willing to modify it!)

This PR resolves the issue with incorrect error count and ensures warnings are correctly displayed when using `cargo check --message-format json`.

Fixes #14472
2024-09-27 11:47:04 +00:00
yichi170
71c830ccef fix: correct error count for cargo check --message-format json 2024-09-26 23:07:51 -05:00
Ed Page
c08b437e9d docs(charter): Declare new Intentional Artifacts as 'small' changes
That means these will only need an FCP to take ownership, including
updating the charter, rather than an RFC.
2024-09-26 09:50:10 -05:00