Commit graph

16803 commits

Author SHA1 Message Date
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
l00556901
2e5719cde1 Fix missing brackets 2024-02-21 15:27:14 +08:00
bors
194a60b295 Auto merge of #13468 - weihanglo:remove-host-libdir, r=ehuss
fix: remove unused `sysroot_host_libdir`
2024-02-21 01:53:45 +00:00
bors
3d47dd412e Auto merge of #13197 - weihanglo:target-triple-rustdocflags, r=epage
feat: support `target.<triple>.rustdocflags` officially
2024-02-21 01:24:44 +00:00
bors
be41d1e9de Auto merge of #13469 - ehuss:windows-unused-imports, r=weihanglo
Fix unused imports on Windows.

These imports were causing a warning on Windows because they are only used in a section that is conditional for Unix.
2024-02-21 00:38:12 +00:00
Eric Huss
27f84f6b68 Fix unused imports on Windows. 2024-02-20 16:28:37 -08:00
Eric Huss
a82794ec4a Fix path issues for running rustup wrapper on Windows.
Cargo likes to modify PATH, which circumvents the ability to choose the
correct "cargo" executable to run on Windows (because Windows uses PATH
for both binary and shared library searching).
2024-02-20 16:27:04 -08:00
Weihang Lo
6131e991af
test: target.triple.rustdocflags works for doctest 2024-02-20 19:15:53 -05:00
Weihang Lo
ef39572305
refactor: use arg capture for TargetConfig construction 2024-02-20 19:15:52 -05:00
Weihang Lo
aedd6d3a20
refactor: impl Default for TargetConfig 2024-02-20 19:15:50 -05:00
Weihang Lo
594cb93b0d
docs: clarify that extra flags also applies to rustdoc 2024-02-20 19:15:49 -05:00
Weihang Lo
7d6172de6a
docs(config): target.triple.rustdocflags 2024-02-20 19:15:48 -05:00
Weihang Lo
652a8413d7
feat: support target.triple.rustdocflags officially
`CARGO_TARGET_<TRIPLE>_RUSTDOCFLAGS` was accidentally accepted somehow,
so support both config and env officially,
given that removing env support would be a breaking change.
2024-02-20 19:15:42 -05:00
Weihang Lo
44c69d83d6
test: demonstrate target.triple.rustdocflags doesnt work 2024-02-20 19:02:08 -05:00
Weihang Lo
4402b5c4f8
fix: remove unused sysroot_host_libdir
Copy from <https://github.com/rust-lang/cargo/pull/10469#issuecomment-1079503079>:

> I've never been entirely clear why it does this. #4006 didn't really
> explain why it added the corresponding host_dylib_path. I can't envision
> a scenario where it matters. I think compiler plugins and proc-macros
> should load just fine, since libstd.so should already be loaded by the
> compiler. Also, rustc uses rpath these days, and on Windows libstd.so is
> placed in the bin directory which will be searched first anyways.
>
> On balance, I think it should be safe to just remove sysroot_host_libdir.
> I can't come up with a scenario where it matters, at least on
> windows/macos/linux. One issue is that this is most likely to affect
> plugins, but those are deprecated and I think only Servo was the real
> holdout. A concern is that nobody is going to test this use case before
> it hits stable.

Also,

* compiler plugins were removed https://github.com/rust-lang/rust/pull/116412
* servo has moved off from plugins: https://github.com/servo/servo/pull/30508

So should generally be fine.
2024-02-20 18:16:01 -05:00
Ed Page
67474259e9 fix(cli): Control clap colors through term.color
Fixes #9012
2024-02-20 16:42:00 -06:00
Ed Page
cf2cca9d8c refactor(shell): Allow reusing ColorChoice parsing 2024-02-20 16:42:00 -06:00
Ed Page
4c3b0ade3d refactor(shell): Group by type 2024-02-20 16:42:00 -06:00
Ed Page
e5fd597015 Revert "refactor(cli): Lazily do first-pass config loading"
This reverts commit eda1652b40.
2024-02-20 16:41:59 -06:00
Ed Page
84348548d9 refactor(cli): Switch '-C' to using 'reload_rooted_at' 2024-02-20 16:38:56 -06:00
Eric Huss
ccaa118d27 Add workaround for RUSTUP_WINDOWS_PATH_ADD_BIN.
On Windows, rustup has an issue with recursive cargo invocations. This
commit can be removed once
https://github.com/rust-lang/rustup/issues/3036 is resolved.
2024-02-20 13:24:50 -08:00
bors
3fcbf73c5c Auto merge of #13466 - ehuss:more-redundant-use, r=weihanglo
Fix more redundant imports.

The latest nightly has started warning about redundant imports. This removes those warnings.

Presumably these were casualties of merging between #13464 and #13409.
2024-02-20 20:48:17 +00:00