13044 Commits

Author SHA1 Message Date
bors
861110c58b Auto merge of #11403 - calebfletcher:master, r=weihanglo
Add test for rustdoc-map generation when using sparse registries

Fixes #11402.

Adds an explicit check for sparse registries when generating the mappings for `-Zrustdoc-map`, so that the `sparse+` qualifier is removed before the comparison.
2022-11-29 11:59:38 +00:00
Caleb Fletcher
f54cd332e2 Add test for rustdoc map usage with sparse alternative registries 2022-11-29 19:28:03 +11:00
bors
a2ea66bea6 Auto merge of #11400 - hi-rustin:rustin-patch-fix-error, r=epage
Add error message when `cargo fix` on an empty repo

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/11380

Add error message when `cargo fix` on an empty repo.

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

- [x] unit test

```sh
set -eux

cargo +nightly new repro
cd repro
echo "fn main() { let _ = 0.clone(); }" > src/main.rs
cargo fix
```
2022-11-28 13:01:15 +00:00
bors
a004f94c48 Auto merge of #11387 - arlosi:sparse-url, r=weihanglo
Store the sparse+ prefix in the SourceId for sparse registries

#11209 added a new `SourceKind::SparseRegistry` and removed the `sparse+` prefix from the URLs stored in the `SourceId`.

The removal of the `sparse+` prefix from the URLs in the `SourceId` has led to several bugs, since registry URLs no longer round-trip through a `SourceId`. The most recent one I found was that the example configuration generated by `cargo vendor` did not include the `sparse+` prefix. Any place that calls the `.url()` method on a `SourceId` potentially has this bug.

This change puts the `sparse+` prefix back in the URL stored in the `SourceId`, but keeps the new `SourceKind::SparseRegistry`.

A test is added for doing `cargo vendor` on an alternative registry using the sparse protocol.
2022-11-27 16:00:17 +00:00
Weihang Lo
37d9b5c49a
Use struct shorthand syntax 2022-11-27 23:33:25 +08:00
hi-rustin
21b2fe98a4 Fix fix_in_existing_repo_weird_ignore broken test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-26 20:15:36 +08:00
hi-rustin
3189dc3b06 Include untracked files
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-26 20:15:36 +08:00
hi-rustin
25f7d4b09a Remove new_repo_without_add_and_commit
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-26 20:15:36 +08:00
hi-rustin
89b8a8bb10 Suppress error with --allow-dirty and add a test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-26 20:15:36 +08:00
hi-rustin
a1f2f5a53f Add error message when cargo fix on an empty repo
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-26 20:15:36 +08:00
bors
1382b44e43 Auto merge of #11425 - willcrichton:scrape-examples-documentation, r=weihanglo
Update documentation for -Zrustdoc-scrape-examples in the Cargo Book

### What does this PR try to resolve?

Description in the title. Fixes #11424.

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

Here's a screenshot of the updated documentation:

<img width="814" alt="Screen Shot 2022-11-25 at 6 24 49 PM" src="https://user-images.githubusercontent.com/663326/204065460-4e06c638-7e3d-4c00-a805-7cb4b5a3803b.png">

r? `@weihanglo`
2022-11-26 10:08:12 +00:00
Will Crichton
000725213f Update documentation for -Zrustdoc-scrape-examples in the Cargo Book 2022-11-25 18:25:31 -06:00
bors
e027c4b5d2 Auto merge of #11420 - epage:atty, r=weihanglo
fix: Move off atty to resolve soundness issue

There is a soundness issue with atty when building on Windows with a custom allocator.

This PR switches direct dependencies on atty to is-terminal.  New semver compatible versions of clap and snapbox remove atty. #11417 upgrades env_logger to remove it from there.

Fixes #11416
2022-11-25 19:44:46 +00:00
bors
79fe7573b0 Auto merge of #11401 - adam248:patch-1, r=ehuss
add newline char to `cargo install .` error message for easier reading.

I just noticed the `cargo install .` error message was not formatted very nicely.

Just added a newline char to make it cleaner.

Thanks
2022-11-25 13:34:10 +00:00
Ed Page
48895b1681 fix: Move off atty to resolve soundness issue
There is a soundness issue with atty when building on Windows with a
custom allocator.

This PR switches direct dependencies on atty to is-terminal.  New semver
compatible versions of clap and snapbox remove atty. #11417 upgrades
env_logger to remove it from there.

Fixes #11415
2022-11-25 06:28:01 -06:00
bors
ee755e77da Auto merge of #11417 - epage:logger, r=weihanglo
chore: Upgrade to env_logger

This removes one path to `atty`.

Others:
- clap: fixed in 4.0.27
- pretty-env-logger: seanmonstar/pretty-env-logger#52 needs to be resolved first
- snapbox: this will be fixed soonish but is also only a test dependency
- direct dependency

This is part of #11416
2022-11-25 07:44:05 +00:00
bors
de56c1251b Auto merge of #10343 - willcrichton:example-analyzer, r=weihanglo
Change rustdoc-scrape-examples to be a target-level configuration

This PR addresses issues raised in rust-lang/cargo#9525. Specifically:
1. It enables examples to be scraped from `#[test]` functions, by passing additional flags to Rustdoc to ensure that these functions aren't ignored by rustc.
2. It moves the `arg` from `-Z rustdoc-scrape-examples={arg}` into a target-level configuration that can be added to Cargo.toml.

The added test `scrape_examples_configure_target` shows a concrete example. In short, examples will be default scraped from Example and Lib targets. Then the user can enable or disable scraping like so:

```toml
[lib]
doc-scrape-examples = false

[[test]]
name = "my_test"
doc-scrape-examples = true
```
2022-11-25 06:58:20 +00:00
bors
6a0f0cb6f1 Auto merge of #11419 - weihanglo:disable-lto-mingw, r=epage
temporarily disable test `lto::test_profile`

- CI failing
  - <https://github.com/rust-lang/cargo/actions/runs/3542820690/jobs/5948722067>
  - <https://github.com/rust-lang/cargo/actions/runs/3535399031/jobs/5933377592>
- Tracking in <https://github.com/rust-lang/rust/issues/104852>
- Discussing in <https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/windows.20gnu.20LTO.20CI.20error>
2022-11-25 01:58:58 +00:00
Weihang Lo
d5cac16d07
temporarily disable test lto::test_profile
- CI failing
  - <https://github.com/rust-lang/cargo/actions/runs/3542820690/jobs/5948722067>
  - <https://github.com/rust-lang/cargo/actions/runs/3535399031/jobs/5933377592>
- Tracking in <https://github.com/rust-lang/rust/issues/104852>
- Discussing in <https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/windows.20gnu.20LTO.20CI.20error>
2022-11-25 01:04:49 +00:00
Ed Page
5a3bf71d6a chore: Upgrade to env_logger
This removes one path to `atty`.

Others:
- clap: fixed in 4.0.27
- pretty-env-logger: seanmonstar/pretty-env-logger#52 needs to be resolved first
- snapbox: this will be fixed soonish but is also only a test dependency
- direct dependency

This is part of #11416
2022-11-24 12:01:07 -06:00
Will Crichton
183425f0bc Add test to confirm #10876 is fixed. 2022-11-23 09:35:59 -06:00
Will Crichton
ce9597c51b Use rename_all in TomlTarget serde derive 2022-11-22 16:26:56 -06:00
Will Crichton
c26ed6357f Add doc comments to explain scrape-examples feature 2022-11-22 15:19:18 -06:00
bors
ba607b23db Auto merge of #11368 - dtolnay-contrib:partial, r=Muscraft
Fix failure to parse rustc's JSON output if it is too nested
2022-11-22 20:52:39 +00:00
bors
995f5efcc2 Auto merge of #11186 - hi-rustin:rustin-patch-add-suggestion, r=epage
Add suggestions when `cargo add` multiple packages

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/11173
Add suggestions when `cargo add` multiple packages. See https://github.com/rust-lang/cargo/issues/11173#issuecomment-1265692022

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

- [x] unit test
2022-11-22 14:10:58 +00:00
hi-rustin
db3ebb6b71 Better expect messages
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-22 18:48:28 +08:00
Adam Butler
1b7e256413 fixed typo causing broken cargo install . test case 2022-11-22 14:14:29 +09:30
Adam Butler
db0d3f9de1
fixed cargo fmt error regarding unknown escape char. 2022-11-22 13:24:59 +09:30
Adam Butler
c5836e97ba
fixed broken error made by newline char in cargo install . error message 2022-11-22 13:19:05 +09:30
Adam Butler
bf9006d9c4
add newline to cargo install . error message for easier reading. 2022-11-22 12:38:33 +09:30
bors
65535890db Auto merge of #11395 - kbuyukakyuz:patch-1, r=Eh2406
Update mod.rs
2022-11-20 21:49:27 +00:00
Kerim Büyükakyüz
de254fed3c
Update mod.rs 2022-11-21 00:04:31 +03:00
bors
19f952f160 Auto merge of #11394 - hi-rustin:rustin-patch-typo, r=weihanglo
Fix typo `try use` -> `try to use`

See https://github.com/rust-lang/cargo/pull/11377#discussion_r1027261052

r? `@weihanglo`
2022-11-20 11:18:03 +00:00
hi-rustin
a3eb31fab4 Fix typo try use -> try to use
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-20 18:14:17 +08:00
bors
63fdd75bde Auto merge of #11377 - hi-rustin:rustin-patch-warning-tree, r=weihanglo
Add warning when `cargo tree -i <spec>` can not find packages

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/11315

Add warning when `cargo tree -i <spec>` can not find packages.

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

Please run the unit test.
2022-11-20 08:52:04 +00:00
hi-rustin
c5eb61823c Remove the --all-features tip
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-20 16:39:00 +08:00
bors
43689d353a Auto merge of #11194 - cassaundra:cargo-remove-gc, r=epage
Clean profile, patch, and replace in cargo remove

### What does this PR try to resolve?

This PR is part of the continued work on cargo remove (#11099, see deferred work).

After a successful removal of a dependency, clean up the profile, patch, and replace sections to remove all references to it.

**Note** the GC process was expanded to clean up not just references to the dependencies just removed, but also references of all dependencies. This was because there's not an easy way to determine which dependencies correspond to the given TOML keys, without either 1) figuring that out before the removal (therefore having to predict the behavior), or 2) returning that information from the remove function (somewhat unorthodox for an op).

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

Verify that the implementation makes sense and that the tests are sufficient.
2022-11-19 02:46:46 +00:00
bors
fa85418a65 Auto merge of #11391 - Expyron:master, r=ehuss
chore: Upgrade miow

Upgrade `miow` to the latest release.

The main change from miow is the upgrade of transitive dependency `windows-sys` from 0.28 to 0.42, which removes a duplicate dependency for cargo.
2022-11-18 21:57:25 +00:00
Cassaundra Smith
299252c78d Clean profile, patch, and replace in cargo remove
After a successful removal of a dependency, clean up the profile, patch, and
replace sections to remove all references to the dependency.
2022-11-18 09:33:37 -06:00
Expyron
bb837662d8 chore: Upgrade miow 2022-11-18 14:08:46 +01:00
bors
eb5d35917b Auto merge of #11388 - arlosi:fix-waiting-tests, r=epage
Fix several tests that are waiting 60 seconds for publishing to time out

Several tests are missing the pre-publishing hack to avoid the 60 second wait-for-publish timeout.

r? `@epage`
2022-11-17 22:08:43 +00:00
Arlo Siemsen
7cd613773d Fix several tests that are waiting 60 seconds for publishing to time out 2022-11-17 15:54:24 -06:00
Arlo Siemsen
1da79baf54 Store the sparse+ prefix in the URL for sparse registries 2022-11-17 14:25:47 -06:00
bors
4d5c036a00 Auto merge of #10592 - arlosi:auth, r=ehuss
Implement RFC 3139: alternative registry authentication support

Allows registries to request Cargo to send the authentication token for all requests, rather than just publish/yank, implementing [RFC 3139](https://github.com/rust-lang/cargo/issues/10474).

### Items from the [tracking issue](https://github.com/rust-lang/cargo/issues/10474)

> Do registries need a more fine-grained switch for which API commands require authentication?

This PR uses the `auth_required` boolean as described in the RFC.

> The RFC mentions adding --token to additional commands like install and search

These flags are not added by this PR.

> Consider changing the name and form of the X- header

Changed to the `www-authenticate` header as suggested by the comments.

> Will there be any concerns with the interaction with https://github.com/rust-lang/rfcs/pull/3231

Not that I know of.

-------------

Adds a new field `"auth-required": true` to `config.json` that indicates Cargo should include the token in all requests to a registry.

For HTTP registries, Cargo first attempts an un-authenticated request, then if that fails with HTTP 401, an authenticated request is attempted. The registry server may include a `www-authenticate` header with the HTTP 401 to instruct Cargo with URL the user can visit to acquire a token (crates.io/me).

Since the API URL is not known (because it's stored in the index), the unstable credential provider feature is modified to key off the index url, and the registry name is no longer provided.

To handle the case where an alternative registry's name is not known (such as coming from a lock file, or via `--index`), Cargo can now look up the token in the configuration by matching on the index URL. This introduces a new error if two alternative registries are configured with the same index URL.

Several operations, such as `cargo install` could have had a `--token` argument added, however it appears that Cargo would like to move away from passing the token on the command line for security reasons. In this case, users would need to configure the registry via the config file (or environment variables) when using `cargo install --index ...` or similar.
2022-11-17 01:25:35 +00:00
Arlo Siemsen
9827412fee Implement RFC 3139: alternative registry authentication support 2022-11-16 14:36:19 -06:00
Will Crichton
b325a8d5d5 Fix complex_reverse_dependencies test 2022-11-16 09:18:37 -08:00
Will Crichton
39e6737de7 Change rustdoc-scrape-examples to be a target-level configuration 2022-11-16 09:18:33 -08:00
bors
b690ab48fc Auto merge of #11302 - arlosi:install-default, r=weihanglo
Fix cargo install --index when used with registry.default

Setting `registry.default` causes the `args.registry` call to return the default registry as if it were passed through `--registry`, which leaves the `--index` argument ignored in `cargo install`, since `registry` is checked first.

Fixes #11301 by checking for `index` before `registry`.

Note that if you try to pass both `--index` and `--registry`, then a command-line parser error (correctly) occurs:
```
The argument '--registry <REGISTRY>' cannot be used with '--index <INDEX>'
```
2022-11-16 12:03:34 +00:00
Arlo Siemsen
24bf873c83 Fix cargo install --index when used with registry.default 2022-11-15 11:28:29 -06:00
hi-rustin
a4f89eab03 Add warning when cargo tree -i <spec> can not find packages
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-11-15 09:41:39 +08:00