Commit graph

16774 commits

Author SHA1 Message Date
renovate[bot] ae0894d7df
chore(deps): update rust crate supports-hyperlinks to v3 2024-03-01 02:01:55 +00:00
bors ecb8193f8d Auto merge of #13504 - epage:edition-test, r=weihanglo
test: Make `edition` explicit in packages

### What does this PR try to resolve?

This ensures we don't rely on the edition default for manifests, unblocking the door for warning on unset editions.

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

### Additional information

Alternatives considered
- Augment test output for the new warnings: figured we'd want tests closer to our intention and this seemed more work to update everything
- Make a builder API for generating manifests, allowing us to change the default in one place.  Still an interesting idea but a lot of work for this one change.

Risks
- I missed that a test was specifically for unset edition but that is unlikely of a case to come up
2024-02-29 18:23:47 +00:00
bors c21dd51b0f Auto merge of #13481 - GuillaumeGomez:extern-map-fix, r=weihanglo
Add all unit's children recursively for `doc.extern-map` option

Fixes https://github.com/rust-lang/rust/issues/120993.

It allows to fix link generation of reexport of foreign items when deps documentation is not generated. Sometimes, we need to have information about not only direct dependencies but also of dependencies of these direct dependencies and so on.
2024-02-29 02:30:13 +00:00
bors 5a5ee9aed4 Auto merge of #13499 - epage:always-edition, r=weihanglo
fix(rustc): Always pass --edition to rustc

On [Internals](https://internals.rust-lang.org/t/idea-rustc-cargo-should-warn-on-unspecified-edition/20309), the idea came up for warning on unset Edition.
I am working on the cargo warning but if rustc ever wants to do so, they'd be blocked on cargo ensuring `--edition` is always set. Hence this change.
2024-02-29 01:48:34 +00:00
Ed Page 831847e5f0 fix(rustc): Always pass --edition to rustc
On [Internals](https://internals.rust-lang.org/t/idea-rustc-cargo-should-warn-on-unspecified-edition/20309),
the idea came up for warning on unset Edition.
I am working on the cargo warning but if rustc ever wants to do so,
they'd be blocked on cargo ensuring `--edition` is always set.
Hence this change.
2024-02-28 15:35:41 -06:00
bors a3ba4ee28a Auto merge of #13438 - Urgau:check-cfg-msrv-annoyance, r=ehuss
Silently ignore `cargo::rustc-check-cfg` to avoid MSRV annoyance when stabilizing `-Zcheck-cfg`

This PR, removes the warning when trying to use `cargo::rustc-check-cfg` on stable or nightly (without the nightly-only `-Zcheck-cfg` flag) to avoid MSRV annoyance when stabilizing `-Zcheck-cfg`.

See this [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/check-cfg.20backwards.20compatible.20warnings) for more information and context.

cc `@ehuss`
2024-02-28 15:14:12 +00:00
bors 8964c8ccff Auto merge of #13340 - linyihai:Z-public, r=epage
feat: Add "-Zpublic-dependency" for public-dependency feature.

### What does this PR try to resolve?
Part of https://github.com/rust-lang/cargo/issues/13308, include:
- Switching the cargo-features to a -Z
- Warning if public is used without -Z and setting it to false

These had not done yet:
- We should also warn if the data type changes but that is less likely to happen and could possibly be skipped
- Ensuring the published version of the package does not have public

### How should we test and review this PR?
All test case should be pass.

### Additional information

r? `@epage`
2024-02-27 19:22:46 +00:00
bors 98f6bf3700 Auto merge of #13492 - ehuss:stabilize-gc-collect, r=weihanglo
Stabilize global cache data tracking.

This stabilizes the global cache last-use data tracking. This does not stabilize automatic or manual gc.

Tracking issue: https://github.com/rust-lang/cargo/issues/12633

## Motivation

The intent is to start getting cargo to collect data so that when we do stabilize automatic gc, there will be a wider range of cargo versions that will be updating the data so the user is less likely to see cache misses due to an over-aggressive gc.

Additionally, this should give us more exposure and time to respond to any problems, such as filesystem issues.

## What is stabilized?

Cargo will now automatically create and update an SQLite database, located at `$CARGO_HOME/.global-cache`. This database tracks timestamps of the last time cargo touched an index, `.crate` file, extracted crate `src` directory, git clone, or git checkout. The schema for this database is [here](a7e9347926/src/cargo/core/global_cache_tracker.rs (L233-L307)).

Cargo updates this file on any command that needs to touch any of those on-disk caches.

The testsuite for this feature is located in [`global_cache_tracker.rs`](a7e9347926/tests/testsuite/global_cache_tracker.rs).

## Stabilization risks

There are some risks to stabilizing, since it commits us to staying compatible with the current design.

The concerns I can think of with stabilizing:

This commits us to using the database schema in the current design.

The code is designed to support both backwards and forwards compatible extensions, so I think it should be fairly flexible. Worst case, if we need to make changes that are fundamentally incompatible, then we can switch to a different database filename or tracking approach.

There are certain kinds of errors that are ignored if cargo fails to save the tracking data (see [`is_silent_error`](64ccff290f/src/cargo/core/global_cache_tracker.rs (L1796-L1813))).

The silent errors are only shown with --verbose. This should help deal with read-only filesystem mounts and other issues. Non-silent errors always show just a warning. I don't know if that will be sufficient to avoid problems.

I did a fair bit of testing of performance, and there is a bench suite for this code, but we don't know if there will be pathological problems in the real world. It also incurs an overhead that all builds will have to pay for.

I've done my best to ensure that this should be reliable when used on network or unusual filesystems, but I think those are still a high-risk category. SQLite should be configured to accommodate these cases, as well as the extensive locking code (which has already been enabled).

A call for public testing was announced in December at https://blog.rust-lang.org/2023/12/11/cargo-cache-cleaning.html. At this time, I don't see any issues in https://github.com/rust-lang/cargo/labels/Z-gc that should block this step.
2024-02-27 16:32:36 +00:00
bors bf5acf8e58 Auto merge of #13494 - weihanglo:bump-versions, r=epage
chore: bump baseline version requirement of sub crates
2024-02-27 01:41:44 +00:00
Weihang Lo edd2821f46
chore: bump baseline version requirement of sub crates
While we can just bump to the latest versions, this time we do a
conservative one for some crates.

* `cargo-util` --- 0.2.10 to 0.2.11 contain only comment changes.
* `cargo-platform` --- 0.1.6 to 0.1.8 contain only lint and metadata changes
2024-02-26 18:38:49 -05:00
Lin Yihai 01de3e0fe7 feat: Add "-Zpublic-dependency" for public-dependency feature 2024-02-27 05:10:17 +08:00
Eric Huss 39863e7f54 Stabilize global cache data tracking. 2024-02-26 11:37:54 -08:00
bors a7e9347926 Auto merge of #13490 - weihanglo:rustdoc-shared-libs, r=epage
fix(doctest): search native libs in build script outputs
2024-02-26 16:31:48 +00:00
bors cc6e32665e Auto merge of #13489 - linyihai:typo-two, r=weihanglo
chore: fixed a typo(two->too)

### What does this PR try to resolve?
typo: `for two long` corrected by `for too long`

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

### Additional information
2024-02-26 13:53:48 +00:00
Weihang Lo 34215b1b4a
fix: doctest searches native libs in build script outputs
HACK: `rustdoc --test` not only compiles but executes doctests.
Ideally only execution phase should have search paths appended,
so the executions can find native libs just like other tests.
However, there is no way to separate these two phase, so this
hack is added for both phases.
2024-02-25 22:55:44 -05:00
Lin Yihai 4ca0524539 chore: fixed a typo(two->too) 2024-02-26 11:39:33 +08:00
Weihang Lo 0e8a67fde3
test(doctest): doctest doesn't set shared libs to search path
This new test demonstrate the current behavior.
2024-02-25 19:29:05 -05:00
Weihang Lo 91f75ac4bb
refactor: enum to represent kinds of tools being run 2024-02-25 19:29:05 -05:00
Urgau da5900740e Silently ignore cargo::rustc-check-cfg to avoid MSRV annoyance 2024-02-24 19:52:52 +01:00
bors f415cb2088 Auto merge of #13488 - weihanglo:snapbox, r=Muscraft
test: relax help text assertion
2024-02-24 17:31:10 +00:00
Weihang Lo 81b3b5ad4f
test: relax help text assertion
When running test in rust-lang/rust via `./x test src/tool/cargo`,
there is no rustup integrated.
2024-02-24 11:50:41 -05:00
bors e975158c1b Auto merge of #13486 - weihanglo:config-cleanup, r=epage
refactor: clean up for `GlobalContext` rename
2024-02-23 21:16:26 +00:00
Weihang Lo 75dbb86591
doc: link to GlobalContext item 2024-02-23 16:03:23 -05:00
Weihang Lo d090365234
refactor: rename non-global context _gctx to _ctx 2024-02-23 15:30:44 -05:00
bors 2b302a58cb Auto merge of #13461 - epage:snapbox, r=weihanglo
test(cli): Verify terminal styling

### What does this PR try to resolve?

This uses a new feature from snapbox that let's us render terminal styling in SVG files.  This let's us see / visualize ANSI escape codes, including in github's UI (will render images, including side-by-side images for diffs).

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

Potential concerns
- assert-rs/trycmd#257: If the snapshot file doesn't exist, you need to `SNAPSHOTS=overwrite` twice
- #9012: because we narrow the enabling of colors to cargo via `CARGO_TERM_COLOR`, clap doesn't know about it and those are rendered without color
- File size: `du -ch tests` reported 13MB before and after
- Loss of information: this doesn't yet include links but we already weren't snapshotting these
- Unconditionally turning on styling and snapshotting for it for all "ui" tests
- Too many SVGs in one PR can negatively affect github's UI

### Additional information
2024-02-23 17:59:44 +00:00
bors 98079d9d19 Auto merge of #13479 - epage:cfg, r=weihanglo
fix(cli): Respect CARGO_TERM_COLOR in '--list' and '-Zhelp'

### What does this PR try to resolve?

Similar to #9012, we aren't respecting `CARGO_TERM_COLOR` for `-Zhelp` and other places.  This corrects that.

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

#9012 was about initialization order to get the value.  Here, the problem is that we don't update `Shell` with `CARGO_TERM_COLOR`.

In doing this, I was concerned about keeping track of where it is safe to call `config_configure` without running it twice.  To this end, I refactored `main` to make it clear that each call to `config_configure` is in a mutually exclusive path that exists immediately.

### Additional information

Found this with the test for `-Zhelp` in #13461.
2024-02-22 20:50:20 +00:00
bors b425030678 Auto merge of #13480 - Cerber-Ursi:workspace-error-shows-path, r=epage
Error messages when collecting workspace members now mention the workspace root location

Fixes https://github.com/rust-lang/cargo/issues/13394

### What does this PR try to resolve?

This is a small tweak in error messages for workspaces, with intention to make it easier for users who accidentally created some unwanted workspace and then was surprised by the error coming seemingly out of nowhere. The exact inspiration for the change was [this comment](https://users.rust-lang.org/t/cargo-using-wrong-directory/107126/9?u=cerber-ursi) in discussion on URLO.

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

This is a simple change in error messages, so the existing test suite should probably be enough. Requests for changing the text further are welcome, of course.
2024-02-22 19:49:12 +00:00
Cerber-Ursi 51c8e0eb51 slightly reworded message to show the main parts first
Co-authored-by: Ed Page <eopage@gmail.com>
2024-02-23 02:27:01 +07:00
Guillaume Gomez e4b0aaabfa Update tests for linking to transient dependencies items 2024-02-22 20:22:38 +01:00
Ed Page 14646e6af6 test: Make edition explicit on packages 2024-02-22 11:37:03 -06:00
Guillaume Gomez 4d6ae88f79 Add all unit's children recursively for doc.extern-map option to fix link generation of reexport of foreign items when deps documentation is not generated 2024-02-22 18:29:25 +01:00
bors e08a81333c Auto merge of #13281 - LuuuXXX:issue-10729, r=epage
fix(add): Improve error when adding registry packages while vendored

### **What does this PR try to resolve?**

When a vendored directory is established, cargo add no longer adds new packages. Instead, it tries to translate a package name into a package that already exists in the vendored directory.
[More details](https://github.com/rust-lang/cargo/issues/10729#issue-1260548746)

Since `@epage` has done most of the work, here I do the rest of the finishing work.

Improves the error from #10729

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

The implementation procedure is as follows:
https://github.com/rust-lang/cargo/issues/10729#issuecomment-1191633351

Test steps:
1. Try to get an arbitrary crate and execute `cargo vendor` command.
2. Configure the vendor directory in .cargo/config.toml.
3. Add `alter-registry` to the config.toml file.
```
[registries]
alter-registry= { index = "XXX" }
```
4. run the same `cargo add` command.
```
cargo add another-crate --registry alter-registry
```
2024-02-22 17:28:17 +00:00
Ed Page 2ec04612d2 fix(cli): Respect CARGO_TERM_COLOR in '--list' and '-Zhelp'
Found this with the test for `-Zhelp` in #13461.
2024-02-22 11:01:03 -06:00
Ed Page f525e1f383 fix(context): Configure Shell before emitting messages 2024-02-22 11:01:03 -06:00
Cerber Ursi 07eb70811f add workspace root path to error messages on members collecting 2024-02-22 22:56:26 +07:00
bors 08c173a000 Auto merge of #13478 - heisen-li:link, r=epage
[docs]:Add missing jump links

### What does this PR try to resolve?

Add missing jump links.

If the maintainer does this intentionally, close the PR at any time.
2024-02-22 15:07:43 +00:00
heisen-li b174cc2cdf Remove extra spaces 2024-02-22 16:08:17 +08:00
heisen-li dec5e13d66 Add missing jump links 2024-02-22 16:01:11 +08:00
heisen-li 346c279bd9 test 2024-02-22 15:26:45 +08:00
LuuuX 640c0774da Rename Fuzzy to Alternatives 2024-02-22 14:08:46 +08:00
LuuuX a31184b9eb Added QueryKind::Normalized, and used it in cargo-add 2024-02-22 13:36:28 +08:00
LuuuX 7dc7b1bc99 Add two tests to make sure fixup 2024-02-22 12:34:40 +08:00
Ed Page 1834244c98 refactor(cli): Allow calling config_configure without Exec 2024-02-21 21:22:52 -06:00
Ed Page 808b4f64b1 refactor(cli): Make it obvious that the cases are mutually exclusive 2024-02-21 21:22:02 -06:00
Ed Page ad85ef4151 refactor(cli): Shrink main
I'm going to add more `config_configure`s and this will make it more
obvious that these are done in early returns.
2024-02-21 21:19:45 -06:00
Ed Page b14a70fe09 test(cli): Verify terminal styling
This uses a new feature from snapbox that let's us render terminal
styling in SVG files.  This let's us see / visualize ANSI escape codes,
including in github's UI (will render images, including side-by-side
images for diffs).
2024-02-21 20:20:41 -06:00
bors cafbc12bd9 Auto merge of #13467 - ehuss:global-tracker-old-cargo, r=weihanglo
Add global_cache_tracker stability tests.

This adds some tests to ensure that the database used in the global cache tracker stays compatible across versions. These tests work by using rustup to run both the current cargo and the stable cargo, and verifying that when switching versions, everything works as expected.

These tests will be ignored on developer environments if they don't have rustup, or don't have the stable toolchain installed. It does assume that "stable" is at least 1.76. It is required for the tests to run in CI, but will be disabled in rust-lang/rust since it does not have rustup.

I'm not expecting too much trouble with these tests, but if they become too fiddly or broken, they can always be changed or removed.

The support code for running "cargo +stable" is very basic right now. If we expand to add similar tests in the future, then I think we could consider adding support functions (such as [`tc_process`](64ccff290f/tests/testsuite/old_cargos.rs (L21-L36))) to make it easier or more reliable.
2024-02-21 21:32:07 +00:00
bors d325f9b7d0 Auto merge of #13463 - epage:term_color, r=weihanglo
fix(cli): Control clap colors through config

### What does this PR try to resolve?

Part of #9012

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

To accomplish this, I pivoted in how we handle `-C`.  In #11029, I made the config lazily loaded.  Instead, we are now reloading the config for `-C` like we do for "cargo script" and `cargo install`.  If there is any regression, it will be felt by those commands as well and we can fix all together.  As this is unstable, if there is a regression, the impact is less.  This allowed us access to the full config for getting the color setting, rather than taking more limited approaches like checking only `CARGO_TERM_CONFIG`.

### Additional information
2024-02-21 19:11:06 +00:00
bors 3e69220e24 Auto merge of #13472 - linyihai:remove-unused-func, r=weihanglo
chore: remove the unused function

### What does this PR try to resolve?

Remove the unused function.  The code that uses this function has been removed, so it no longer makes sense to keep it.

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

### Additional information
2024-02-21 14:46:44 +00:00
bors 73290542e6 Auto merge of #13470 - heisen-li:fix, r=weihanglo
Fix missing brackets

### What does this PR try to resolve?

There seems to be a missing parenthesis.
2024-02-21 12:36:03 +00:00