Commit graph

3358 commits

Author SHA1 Message Date
Dom Slee ea27499a2e review comments 2023-03-13 17:54:45 +11:00
Dom Slee dc449bce6d cargo clippy + fmt 2023-03-12 23:52:45 +11:00
Dom Slee a668956dd7 improve error message and add related tests 2023-03-12 23:52:06 +11:00
Sebastian Thiel c890c64080
Disable flaky tests for now (#11821)
The proper fix is in https://github.com/Byron/gitoxide/releases/tag/gix-v0.41.0
which unfortunately can't be used as it also comes with the latest `tempfile` v3.4
which causes other issues when compiling on some platforms.

Thus we first disable the flaky tests, and re-enable them with the `gix` upgrade
which should be possible once `tempfile` doesn't hinder `cargo` on some platforms
anymore.

Related to https://github.com/rust-lang/cargo/issues/11821
2023-03-10 19:45:22 +01:00
Kyle Matsuda 8353396132 add unit test for config and integration test with cargo --list 2023-03-09 16:54:01 -07:00
Weihang Lo f3778f9193
Revert "#11738" - Use test name for dir when running tests
This reverts commit 64b0e793ce, reversing
changes made to 958078633e.
2023-03-08 15:17:48 +00:00
bors c1334b059c Auto merge of #11645 - chansuke:issue-11597, r=weihanglo
Add `CARGO_PKG_README`

Fixes #11597

This environment variable shows the path to the README file of your package. From #11597:

> Cargo may rewrite the package’s `Cargo.toml` and move the README file around, relative to the manifest. I would like to `include_str!()` this README in my `lib.rs`, but am unable to do so right now, because if I specify `include_str!("../../README")` it works for development, but I can’t package my crate. Conversely if I specify `include_str!("../README")` it works when packaged, but not during development.
2023-03-07 19:21:50 +00:00
bors 66789e531a Auto merge of #11636 - aortizpimentel:fix/10834, r=weihanglo
Adding display of which target failed to compile

Closes #10834

Attached example.zip is the same as the one mentioned on the issue. You could use it to test the fix by using the new built cargo:
```./cargo build --manifest-path C:\Rust\example_cargo_error\Cargo.toml```

Before fixing:
```
error: could not compile `example` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
```

After fixing:
```
error: could not compile `example` (build script)  due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
```

[example.zip](https://github.com/rust-lang/cargo/files/10522342/example.zip)
2023-03-07 07:59:14 +00:00
Adrián Ortiz db457d950f Fixing issue https://github.com/rust-lang/cargo/issues/10834:
- Adding display of which target failed to compile
- Consistent messages for warnings/errors.
- Fixing assertions on related tests.
2023-03-07 06:45:26 +01:00
bors 87a997ab4a Auto merge of #11790 - vadorovsky:fix-cfg-target-env, r=arlosi
Fix `CARGO_CFG_` vars for configs defined both with and without value

When a rustc cfg is defined both with and without value, the environment variable should provide all the values. Before this change, it ended up being empty.

Fixes: #11789
2023-03-06 16:47:35 +00:00
jofas feef14e9d7 breaking endless loop on cyclic features in cargo-add 2023-03-06 13:04:38 +01:00
Michal Rostecki ccd991547b Fix CARGO_CFG_ vars for configs defined both with and without value
When a rustc cfg is defined both with and without value, the
environment variable should provide all the values. Before this change,
it ended up being empty.

Fixes: #11789
2023-03-06 10:30:47 +01:00
bors 234d9f6b86 Auto merge of #11791 - arlosi:sparse-stable, r=ehuss
Make `sparse` the default protocol for crates.io

Changes the default protocol for accessing crates.io to `sparse`.

The protocol can be switched back to `git` via the configuration key `registries.crates-io.protocol` = `git`

Closes #10965
2023-03-05 23:10:49 +00:00
hi-rustin 814ded6ae9 Check publish_to_alt_registry publish content 2023-03-04 09:11:37 +08:00
chansuke fb9be455cd Add tests for CARGO_PKG_README 2023-03-03 23:21:16 +09:00
Arlo Siemsen 78d4f2cb84 Make sparse the default protocol for crates.io 2023-03-02 10:50:22 -06:00
Sebastian Thiel cfffda9ae5
add -Zgitoxide=fetch feature toggle and implementation.
This allows to use `gitoxide` for all fetch operations, boosting performance
for fetching the `crates.io` index by a factor of 2.2x, while being consistent
on all platforms.

For trying it, nightly builds of `cargo` can specify `-Zgitoxide=fetch`.
It's also possible to set the `__CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2=1` environment
variable (value matters), which is when `-Zgitoxide=none` can be used
to use `git2` instead.

Limitations
-----------
Note that what follows are current shortcomings that will be addressed in future PRs.

- it's likely that authentication around the `ssh` protocol will work differently in practice
  as it uses the `ssh` program.
- clones from `file://` based crates indices will need the `git` binary to serve the locatl repository.
- the progress bar shown when fetching doesn't work like the orgiinal, but should already feel 'faster'.
2023-03-02 12:35:50 +01:00
bors c61b0f0680 Auto merge of #11770 - Eh2406:non-active-conflict, r=weihanglo
patch can conflict on not activated packages

### What does this PR try to resolve?

In the resolver there is a data structure called a `conflicting_activations`, which records all the reasons a "better" version was not picked for the package being resolved. Normally, these are packages that are currently active that for one reason or another block one of the other versions. Several optimizations assumed that this was always true, even going so far as to use `.expect`. This was a mistake because when there's a `patch` involved there can be conflicts on a version that is not selected. So the correct behavior is to fall back to skip the optimizations and try all versions when a `conflicting_activations` are not active.

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

This adds two automated tests based on the reproductions in #7463 and #11336. So the test suite now covers this case. It can also be tested by reconstructing the repositories originally reported in those issues.

### Additional information

It could be that in the long term the correct fix is to figure out how to support patch without having a conflicting activation that is not activated. But that would be a much bigger change. And for now this assumption is only used in optimizations, so this gets people unstuck.
2023-03-02 06:49:44 +00:00
Jacob Finkelman 2c712d5d46 patch can conflict on not activated packages 2023-03-01 20:56:00 -05:00
bors 0942fc72d6 Auto merge of #11630 - Muscraft:fix-unused-manifest-keys, r=ehuss
fix(toml): Provide a way to show unused manifest keys for dependencies

Dependencies have not been able to show unused manifest keys for some time, this problem partially resulted in #11329.

This problem is caused by having an `enum` when deserializing.  To get around this you can use:
```rust
#[serde(flatten)]
other: BTreeMap<String, toml::Value>,
```
This collects any unused keys into `other` that can later be used to show warnings. This idea was suggested in a thread I cannot find but is mentioned in [serde#941](https://github.com/serde-rs/serde/issues/941).
2023-03-01 22:20:41 +00:00
bors dbb2d67b0c Auto merge of #11783 - arlosi:sparse-offline, r=ehuss
Improve error for missing crate in --offline mode for sparse index

This changes sparse registries to instead return `NotFound` when a non-cached crate is requested in `--offline` mode.

The resolver can then suggest removing the `--offline` flag if resolution fails, which is a more helpful error than the one currently issued: `attempting to make an HTTP request, but --offline was specified`.

With this change, the behavior matches what is already done for git-based registries.

Closes #11276
2023-03-01 21:30:50 +00:00
Arlo Siemsen 65e449ecda Improve error for missing crate in --offline mode for sparse index
This changes sparse registries to instead return not found when a non-cached crate is requested in offline mode.

The resolver can then suggest removing the --offline flag if resolution
fails.
2023-03-01 14:45:09 -06:00
Scott Schafer a32af2fff1 fix(toml): Provide a way to show unused manifest keys for workspace inheritance 2023-03-01 13:43:57 -06:00
bors 80f1a5d0f7 Auto merge of #11688 - epage:minimal, r=Eh2406
feat(resolver): `-Zdirect-minimal-versions`

This is an alternative to `-Zminimal-versions` as discussed in #5657.

Problems with `-Zminimal-versions` includes
- Requires the root most dependencies to verify it and we then percolate that up the stack.  This requires a massive level of cooperation to accomplish and so far there have been mixed results with it to the point that cargo's unstable
 documentation discourages its use.
- Users expect `cargo check -Zminimal-versions` to force resolving to minimal but it doesn't as the default maximal resolve is compatible and requires `cargo update -Zminimal-versions`
- Different compatible versions might be selected, breaking interop between crates, changing feature unification, and breaking `-sys` crates without bad `links`

`-Zdirect-minimal-versions` instead only applies this rule to your
direct dependencies, allowing anyone in the stack to immediately adopt
it, independent of everyone else.

Special notes
- Living up to the name and the existing design, this ignores yanked
  crates.  This makes sense for `^1.1` version requirements but might
  look weird for `^1.1.1` version requirements as it could select
  `1.1.2`.
- This will error if an indirect dependency requires a newer version.
  Your version requirement will need to capture what you use **and** all
  of you dependencies.  An alternative design would have tried to merge
  the result of minimum versions for direct dependencies and maximum
  versions for indirect dependencies.  This would have been complex and
  led to weird corner cases, making it harder to predict.  I also suspect
  the value gained would be relatively low as you can't verify that
  version requirement in any other way.
  - This also means discrepancies between `dependencies` and `dev-dependencies` are errors
  - The error could be improved to call out that this was from minimal
    versions but I felt getting this out now and starting to collect
    feedback was more important.

One advantage of this approach over `-Zminimal-versions` is that it removes most of the problems that [cargo-minimal-versions](https://github.com/taiki-e/cargo-minimal-versions) tried to workaround.

As for the implementation, this might not be the most elegant solution but it works and we can always iterate and improve on it in the future.
- We keep the state as a `bool` throughout but compensate for that by explicitly creating a variable to abstract away constants
- The name changes depending on the context, from `direct_minimal_version` when dealing with the unstable flag to `first_minimal_version` when the concept of "direct" is lost to `first_version` when we split off the ordering concept into a separate variable
- Packages that respect `direct_minimal_versions` are determined by whether they are the top-level `summaries` that get past into `resolve`

### What does this PR try to resolve?

The primary use case is verifying version requirements to avoid depending on something newer than might be available in a dependent

For this to help the MSRV use case, the crate author must directly depend on all indirect dependencies where their latest release has too new of an MSRV but at least they can do so with the `^` operator, rather than `<` and breaking the ecosystem.

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

The first two commits add tests using `-Zminimal-versions`.  The commit that adds `-Zdirect-minimal-versions` updates the tests, highlighting the differences in behavior.

### Additional information

Potential areas of conversation for stablization
- Flag name
- Handling of yanked (pick first non-yanked, pick yanked, error)
- Quality of error message
- Should the package have a "memory" of this flag being set by writing it to the lockfile?

Potential future work
- Stablize this
- Remove `-Zminimal-versions`
- Update `cargo publish`s `--verify` step to use this.
  - The challenge is this won't be using the packaged `Cargo.lock` which probably should also be verified.
2023-03-01 19:26:59 +00:00
Scott Schafer 019aeedeb4 feat: Use test name for dir when running tests 2023-03-01 11:38:58 -06:00
bors 9880b408a3 Auto merge of #11767 - weihanglo:jobserver-style-fifo, r=ehuss
bump jobserver to respect `--jobserver-auth=fifo:PATH`
2023-02-28 19:39:39 +00:00
Weihang Lo b9bfda596f
chore: bump jobserver to respect --jobserver-auth=fifo:PATH'
See https://github.com/alexcrichton/jobserver-rs/pull/49
2023-02-28 16:08:12 +00:00
Eric Huss ab726e7e7f Fix test for Windows 2023-02-25 18:07:49 -08:00
Arlo Siemsen 16ad1f2945 Fix Cargo removing the sparse+ prefix from sparse URLs in .crates.toml 2023-02-25 18:07:46 -08:00
Eric Huss 736fb2f62a Fix warning with tempfile 2023-02-25 15:35:12 -08:00
bors 524231f43f Auto merge of #11643 - jofas:11260-fix, r=weihanglo
Error message for transitive artifact dependencies with targets the package doesn't directly interact with

Address #11260. Produces an error message like described by `@weihanglo` [here](https://github.com/rust-lang/cargo/issues/11260#issuecomment-1400455203):

```
error: could not find specification for target "x86_64-windows-msvc"
  Dependency `bar v0.1.0` requires to build for target "x86_64-windows-msvc".
```

Note that this is not a complete fix for #11260.
2023-02-25 07:39:08 +00:00
Eric Huss 1c4651e5f3 Fix tests with nondeterministic ordering 2023-02-24 17:28:28 -08:00
bors 65cab34dc7 Auto merge of #11650 - hi-rustin:rustin-patch-tests, r=epage
Make some blocking tests non-blocking

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-02-24 03:29:06 +00:00
bors 0625b29d84 Auto merge of #11410 - TrAyZeN:master, r=epage
Suggest cargo add when installing library crate

### What does this PR try to resolve?

When using `cargo install` instead of `cargo use` the error message is the following:
```
error: there is nothing to install in `foo v0.0.1`, because it has no binaries
`cargo install` is only for installing programs, and can't be used with libraries.
To use a library crate, add it as a dependency in a Cargo project instead.
```
It would be good to suggest to the user to use `cargo add`.

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

The `no_binaries` test from `tests/testsuite/install.rs` covers that case.
2023-02-23 18:44:31 +00:00
hi-rustin 5751e17c9b Change the download output order 2023-02-23 09:11:52 +08:00
hi-rustin 0b06a456f2 Make blocking tests non blocking 2023-02-23 09:11:52 +08:00
hi-rustin a8233d4df5 Support store public request body in the HTTP mock server 2023-02-23 09:11:52 +08:00
hi-rustin 04d592c7ad Make some blocking tests non-blocking by using API server 2023-02-23 09:11:52 +08:00
bors 0c331721d9 Auto merge of #11725 - Muscraft:reduce-build-in-tests, r=ehuss
Switch some tests from `build` to `check`

#11341 brought up issues with cargo's `testsute` size and speed. One of the suggested fixes was switching most tests to `check` instead of `build`. This PR did that.

Before size on `nightly`: 4.4GB

After size on `nightly`: 4.2GB

Regex to find `build` in `tests/testsuite`: `cargo\(".*build.*\)`
Before: 1607
After: 626

Note I did not remove all `build` I only did the easy ones that required minimal changes. I also tried not to touch systems I was unsure about. There could be other uses of `build` I missed as well.

I still need to play around with `opt-level`, `debug=0`, and a few other tweaks, but there should be more time/memory to drop.

Each test file changed is in a commit of its own, so you should look commit by commit.
2023-02-21 23:27:36 +00:00
Scott Schafer 45c9c8e905 chore: update workspaces tests to use check 2023-02-20 12:22:29 -06:00
Scott Schafer 221938a2a0 chore: update vendor tests to use check 2023-02-20 12:22:29 -06:00
Scott Schafer b974cacb50 chore: update update tests to use check 2023-02-20 12:22:29 -06:00
Scott Schafer 866daf4f22 chore: update rustflags tests to use check 2023-02-20 12:22:29 -06:00
Scott Schafer 43f9b8ea83 chore: update rust_version tests to use check 2023-02-20 12:22:29 -06:00
Scott Schafer 6282282fb0 chore: update replace tests to use check 2023-02-20 12:22:29 -06:00
Scott Schafer ab1794bda4 chore: update registry_auth tests to use check 2023-02-20 12:22:24 -06:00
Scott Schafer 98c746629b chore: update registry tests to use check 2023-02-20 12:22:24 -06:00
Scott Schafer 1b9af485c1 chore: update pub_priv tests to use check 2023-02-20 12:22:24 -06:00
Scott Schafer 41738bea7e chore: update progress tests to use check 2023-02-20 12:22:24 -06:00
Scott Schafer 8d66a0265d chore: update profile_overrides tests to use check 2023-02-20 12:21:55 -06:00
Scott Schafer a726b8d682 chore: update proc_macro tests to use check 2023-02-20 12:21:35 -06:00
Scott Schafer 341c400487 chore: update paths tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer 577594770e chore: update path tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer 730e2196b7 chore: update patch tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer 7b14e72cc6 chore: update package_features tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer de2e97403f chore: update package tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer e3d3bb6b04 chore: update offline tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer fb755a3dd1 chore: update net_config tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer 1dd8536935 chore: update metabuild tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer 8f4f77e894 chore: update message_format tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer 9a46caf1ed chore: update lockfile_compat tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer de704f5093 chore: update local_registry tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer 9d85c01994 chore: update jobserver tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer df909b938c chore: update inheritable_workspace_fields tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer e8f9ccf9af chore: update git_gc tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer cb20cbaae9 chore: update git_auth tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer 29cd1ce7f2 chore: update git tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer 4934dffa5a chore: update future_incompat_report tests to use check 2023-02-20 12:21:27 -06:00
Scott Schafer 9c14193764 chore: update fix tests to use check 2023-02-20 12:21:15 -06:00
Scott Schafer a03660d5ee chore: update features_namespaced tests to use check 2023-02-20 12:21:15 -06:00
Scott Schafer da70f75ae4 chore: update features2 tests to use check 2023-02-20 12:21:15 -06:00
Scott Schafer a5ec7e0266 chore: update features tests to use check 2023-02-20 12:21:15 -06:00
Scott Schafer ea75921f2d chore: update edition tests to use check 2023-02-20 12:21:15 -06:00
Scott Schafer 620dfb13e1 chore: update doc tests to use check 2023-02-20 12:21:15 -06:00
Scott Schafer 76bb60cec7 chore: update directory tests to use check 2023-02-20 12:21:15 -06:00
Scott Schafer 88e4714eb2 chore: update dep_info tests to use check 2023-02-20 12:21:15 -06:00
Scott Schafer 5ec0ad2c97 chore: update death tests to use check 2023-02-20 12:21:15 -06:00
Scott Schafer 7dd17a44fa chore: update corrupt_git tests to use check 2023-02-20 12:20:46 -06:00
Scott Schafer 6d429b04b9 chore: update config_include tests to use check 2023-02-20 12:20:46 -06:00
Scott Schafer 8507c1701d chore: update config tests to use check 2023-02-20 12:20:46 -06:00
Scott Schafer d89e73c171 chore: update check_cfg tests to use check 2023-02-20 12:20:26 -06:00
Scott Schafer 3845fc9b4d chore: update cfg tests to use check 2023-02-20 12:20:26 -06:00
Scott Schafer c10a4c60c5 chore: update cargo_features tests to use check 2023-02-20 12:20:26 -06:00
Scott Schafer 9c6a044b74 chore: update cargo_env_config test to use check 2023-02-20 12:20:26 -06:00
Scott Schafer e2a6ed7984 chore: update cache_messages test to use check 2023-02-20 12:20:26 -06:00
Scott Schafer e9838a50ee chore: update build_script_env test to use check 2023-02-20 12:20:13 -06:00
Scott Schafer 41cd166887 refactor: Rename test names to case for init 2023-02-20 11:25:40 -06:00
Scott Schafer 08c6bb8446 refactor: Rename test names to case for cargo_add 2023-02-20 11:25:14 -06:00
Scott Schafer 9708e6f62d refactor: Make two tests stderr not match their test name 2023-02-20 11:09:05 -06:00
Scott Schafer 1744d35e80 chore: Remove unneeded #[test] 2023-02-20 11:09:05 -06:00
TrAyZeN 98edd706ad Suggest cargo add when installing library crate 2023-02-18 17:39:11 +01:00
akida31 823ab52f19
Address review comments
* moved `is_empty` check into `check_token`
* improved error message (is quite long now but should explain the error
  well)
* removed one helper function from new test
2023-02-16 19:12:46 +01:00
akida31 3d2e107b5a
Error on invalid token for registry auth
When using registry operations with authentication there will be now an
error if the given token is not valid.
This is a technically a breaking change because a registry might give
some tokens which will be denied by these new checks.
In practice these tokens cause issues with HTTP so no registry should
generate them.
2023-02-16 16:42:30 +01:00
Scott Schafer 7fcb542f7f chore: update bad_manifest_path test to use check 2023-02-15 15:28:48 -06:00
Scott Schafer 9174c22744 chore: update build_config test to use check 2023-02-15 15:28:48 -06:00
Scott Schafer 1873c33482 chore: update alt_registry test to use check 2023-02-15 15:28:48 -06:00
Ed Page 1d153f1d64 feat(resolver): -Zdirect-minimal-versions
This is an alternative to `-Zminimal-versions` as discussed in #5657.

The problem with `-Zminimal-versions` is it requires the root most
dependencies to verify it and we then percolate that up the stack.  This
requires a massive level of cooperation to accomplish and so far there
have been mixed results with it to the point that cargo's unstable
documentation discourages its use.

`-Zdirect-minimal-versions` instead only applies this rule to your
direct dependencies, allowing anyone in the stack to immediately adopt
it, independent of everyone else.

Special notes
- Living up to the name and the existing design, this ignores yanked
  crates.  This makes sense for `^1.1` version requirements but might
  look weird for `^1.1.1` version requirements as it could select
  `1.1.2`.
- This will error if an indirect dependency requires a newer version.
  Your version requirement will need to capture what you use **and** all
  of you dependencies.  An alternative design would have tried to merge
  the result of minimum versions for direct dependencies and maximum
  versions for indirect dependencies.  This would have been complex and
  led to weird corner cases, making it harder to predict.  I also suspect
  the value gained would be relatively low as you can't verify that
  version requirement in any other way.
  - The error could be improved to call out that this was from minimal
    versions but I felt getting this out now and starting to collect
    feedback was more important.
2023-02-14 15:44:30 -06:00
Ed Page c07f06720f test(resolver): Additional direct minimal version tests 2023-02-14 15:43:38 -06:00
Ed Page 12000a9273 test(resolver): Create baseline for `-Zdirect-minimal-versions 2023-02-14 15:43:38 -06:00
Eric Huss fe8dd1b00c Run CI for macOS on nightly 2023-02-14 12:26:01 -08:00
Tobias Rapp 0fda7acf48 Set CARGO_BIN_NAME environment variable also for binary examples
Extend the existing CARGO_BIN_NAME environment variable to be set when
building binary example targets, additional to "normal" binary targets.

Closes #11689.
2023-02-13 14:25:35 +01:00
jofas 4bdface19a applying code review to make get_sysroot_target_libdir more readable + incorporated changes into corresponding test 2023-02-06 14:43:44 +01:00
jofas ef227e401d error message for target specification that couldn't be queried from rustc 2023-01-28 11:08:23 +01:00
jofas d5e43bb22c added test replicating error encountered with transitive artifact dependencies 2023-01-24 13:08:12 +01:00
jofas ded1a15a0a removed trailing whitespaces (done automatically by vim) 2023-01-24 12:40:34 +01:00
Ed Page 8fb9effcae test: Update for clap 4.1.3
The latest clap release fixed a bug with the algorithm for providing
suggestions, leading this suggestion to change.
2023-01-23 21:19:48 -06:00
Eric Huss 9247e8155f Fix unused attribute on Windows. 2023-01-22 14:02:23 -08:00
bors 6c095cce88 Auto merge of #11558 - Muscraft:stabilize-cargo-fix-message, r=epage
feat: stabilize auto fix note

A note that some warnings could be fixed by running a `cargo fix` command was added in #10989 and made to work with `clippy` in #11399. It has only been turned on for `nightly` builds so far; this PR would make it show on `stable`.

The original motivation for making this note `nightly` only, was to [allow for iteration](https://github.com/rust-lang/cargo/issues/10976#issuecomment-1289297978) on the message output. There has yet to be any feedback on the message format in the time that it has been on `nightly`. This was brought up in a recent cargo team meeting and it was thought that we should move forward with showing this on `stable`.

close #10976
2023-01-22 00:50:42 +00:00
Eric Huss ede3bdf2d3 Disable network SSH tests on windows. 2023-01-21 13:06:07 -08:00
bors 7e2a3c21e0 Auto merge of #11409 - Muscraft:default-feat-workspace-dep, r=weihanglo
fix(toml): Add `default-features` to `TomlWorkspaceDependency`

In #11329 it was noted that `default-features` is ignored when used in a dependency that inherits from a workspace i.e.
```toml
[workspace]
members = []
[workspace.dependencies]
dep = "0.1"

[package]
name = "bar"
version = "0.2.0"
authors = []
[dependencies]
dep = { workspace = true, default-features = false }
```

This problem is caused by problems with deserializing a `TomlDependency` and not emitting an unused manifest key correctly. When discussed in a recent Cargo team meeting we felt the best course of action was to allow `default-features = false` when inheriting a dependency, but it does not change actually set `default-features`. It will be used to warn when there is a difference between the definition in `[workspace.dependencies]` and `[dependencies]` i.e.
```toml
[package]
name = "bar"
version = "0.2.0"
[dependencies]
dep = { workspace = true, default-features = false }

[workspace]
members = []
[workspace.dependencies]
dep = { version = "0.1", default-features = true }
```

This does not entirely resolve the problem with unused manifest keys. A follow up PR and issue will be created to address those concerns.

close #11329
2023-01-20 18:11:39 +00:00
bors 985d561f0b Auto merge of #11224 - arlosi:sparse-stable, r=Eh2406
Stabilize sparse-registry

### What does this PR try to resolve?
Stabilize `sparse-registry`
* Does not change the default protocol for accessing crates.io

### How should we test and review this PR?
Set environment variable `REGISTRIES_CRATES_IO_PROTOCOL=sparse` or set in `config.toml`:
```
[registries.crates-io]
protocol = 'sparse'
```

cc #9069
2023-01-20 14:39:28 +00:00
Ed Page 6007f05a85 chore: Update to toml v0.6, toml_edit v0.18
`toml` replaces `toml_edit::easy`, using `toml_edit` as its parser.
2023-01-19 15:26:28 -06:00
bors 35e45fd2e4 Auto merge of #11699 - epage:warn, r=ehuss
Deny warnings in CI, not locally

### What does this PR try to resolve?

The problem with #![deny(warnings)] is it makes iteration more difficult as you might have intermediate states with warnings. Its slightly better that we defer this to cargo test --lib but that still means you can't run a subset of tests against your experiment until you've cleaned up all of your warnings. This can lead to users [working around the problem which could accidentally slip in](d92d04840c).

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

The first round for this PR includes a warning in the `cargo` crate to ensure it breaks CI.  It will then be reverted.

### Additional information

See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/.60.23!.5Bcfg_attr.28test.2C.20deny.28warnings.29.29.5D.60
2023-02-11 18:12:10 +00:00
Ed Page d52f29897a chore: Deny warnings across entire cargo repo 2023-02-10 16:17:33 -06:00
bors 74043673e6 Auto merge of #10952 - compenguy:cargo-change-dir-10098, r=epage
Add '-C' flag for changing current dir before build

This implements the suggestion in #10098 to make cargo change cwd before
completing config processing and starting the build. It is also an
alternative to `--manifest-path` that resolves the issue described
in #2930.

The behavior of this new flag makes cargo build function exactly the same when run at the root of the project as if run elsewhere outside of the project.  This is in contrast to `--manifest-path`, which, for example, results in a different series of directories being searched for `.cargo/config.toml` between the two cases.

Fixes #10098
Reduces impact of #2930 for many, possibly all impacted, by switching to this new cli argument.

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

The easiest way to reproduce the issue described in #2930 is to create an invalid `.cargo/config.toml` file in the root of a cargo project, for example `!` as the contents of the file.  Running cargo with the current working directory underneath the root of that project will quickly fail with an error, showing that the config file was processed.  This is correct and expected behavior.

Running the the same build with the current working directory set outside of the project, e.g. /tmp, and passing the `--manifest-path /path/to/project/Cargo.toml`.  The build will proceed without erroring as a result of reading the project's `.cargo/config.toml`, because config file searching is done from cwd (e.g. in `/tmp` and `/`) without including the project root, which is a surprising result in the context of the [cargo config documentation](https://doc.rust-lang.org/cargo/reference/config.html), which suggests that a `.cargo/config.toml` file checked into the root of a project's revision control will be processed during the build of that project.

Finally to demonstrate that this PR results in the expected behavior, run cargo similar to the previous run, from /tmp or similar, but instead of `--manifest-path /path/to/project/Cargo.toml`, pass `-C/path/to/project` to cargo (note the missing `Cargo.toml` at the end).  The build will provide the exact same (expected error) behavior as when running it within the project root directory.

### Additional information

~Passing a path with a trailing '/' will result in failure.  It is unclear whether this is a result of improper input sanitization, or whether the config.cwd value is being improperly handled on output.  In either case this needs to be resolved before this PR is merge-ready.~

(the above issue appears to have been a side effect of local corruption of my rustup toolchain, and unrelated to this change)

Because a `struct Config` gets created before command line arguments are processed, a config will exist with the actual cwd recorded, and it must then be replaced with the new value after command line arguments are processed but before anything tries to use the stored cwd value or any other value derived from it for anything.  This change effectively creates a difficult-to-document requirement during cargo initialization regarding the order of events.  For example, should a setting stored in a config file discovered via cwd+ancestors search be wanted before argument processing happens, this could result in unpleasant surprises in the exact use case this feature is being added to fix.

A long flag was deferred out to not block this on deciding what to name it.  A follow up issue will be created.
2023-02-10 20:41:41 +00:00
Will Page 4de2c96021 Add '-C' flag for changing current dir before build
This implements the suggestion in #10098 to make cargo change cwd before
completing config processing and starting the build. It is also an
alternative to --manifest-path that resolves the issue described
in #2930.
2023-02-10 07:42:37 -08:00
Weihang Lo 0da332c66e
fix(docscrape): must fail with bad build script
When running `cargo doc -Zrustdoc-scrape-example`, it performs
additional type checks that a plain old `cargo doc` doesn't.
That leads to some extra failure when adopting scrape-example for docs.rs.

In de34d60 we introduced `unit_can_fail_for_docscraping` in order to
make `-Zrustdoc-scrape-example` not fail whenever `cargo doc` builds.
Build script executions were accidentally included in the list of
fallible units. A plain `cargo doc` does fail when a build script
fails. `-Zrustdoc-scrape-example` should follow that.
2023-02-09 20:32:24 +00:00
Weihang Lo a481387e7b
test(docscrape): must fail with bad build script 2023-02-09 20:14:18 +00:00
Noah Hellman bf7f32abf3 util toml targets: infer file only if not a dir
Any directory entry ending with `.rs`, including directories, were
previously assumed to be files, and could end up as targets.

Now only regular files and symbolic links are inferred.
2023-02-04 12:49:33 +01:00
Weihang Lo 98a73394f1
fix: verify source before recompile
This fixes a regression introduced by #11407,
which Cargo should always verify a source before it recompiles.
2023-02-03 14:17:34 +00:00
Weihang Lo 419a56f617
test: verify source before recompile 2023-02-03 14:17:18 +00:00
bors efd37336e9 Auto merge of #11252 - lqd:deferred-debuginfo, r=ehuss
Turn off debuginfo for build dependencies v2

This PR is an alternative to #10493, fixing its most important issue: the unit graph optimization to reuse already built artifacts for dependencies shared between the build-time and runtime subgraphs is preserved (most of the time).

By deferring the default debuginfo level in `dev.build-override` until unit graph sharing, we check whether re-use would happen. If so, we use the debuginfo level to ensure reuse does happen. Otherwise, we can avoid emitting debuginfo and improve compile times (on clean, debug and check builds -- although reuse only happens on debug builds).

I've kept the message explaining how to bump the debuginfo level if an error occurs while running a build script (and backtraces were requested) that was in the previous PR.

I've ran benchmarks on 800 crates, at different parallelism levels, and published the (surprisingly good) results with visualizations, summaries, and raw data [here](https://github.com/lqd/rustc-benchmarking-data/tree/main/experiments/cargo-build-defaults).

Opening this PR as discussed in [Eric's message](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Defaults.20for.20faster.20compilation.20of.20.22for.20host.22.20units/near/304236576l) as draft since 2 tests won't pass. That fixes the `cargo-crev` case we saw as a blocker last time, but doesn't fix all such cases of reuse, like the 2 failing tests:

- [`optional_build_dep_and_required_normal_dep`](642a0e625d/tests/testsuite/build_script.rs (L4449))
- and [`proc_macro_ws`](bd5db301b0/tests/testsuite/features2.rs (L1051))

These failures make sense, since the debuginfo optimization is done during traversal, it depends on the contents of the unit graph. These tests ensure that sharing happens even on finer-grained invocations: respectively, with an optional shared dependency that is later enabled, and building shared dependencies by themselves first and later as part of a complete workspace build.

In both these situations, there is no unit that is shared in the graph during the first invocation, so we do the optimization and remove the debuginfo. When the graph changes in the following invocation, sharing is present and we have to build the shared units again with debuginfo.

These cases feel rarer than `cargo-crev`'s case, but I do wonder if there's a way to fix them, or if it's acceptable to not support them.
2023-02-01 23:17:09 +00:00
bors cf410cb337 Auto merge of #11644 - basile-henry:basile-henry/deny-cargo-home-env-table, r=ehuss
config: Deny CARGO_HOME in [env] table (fixes #11590)

Fixes #11590
2023-02-01 22:16:34 +00:00
Basile Henry 17a2bce2f1 config: Improve wording of CARGO_HOME in [env] error 2023-02-01 08:21:03 +01:00
Eric Huss 5c160dde1c Handle .cargo-ok being truncated 2023-01-31 15:03:28 -08:00
Rémy Rakic 7ccda69f70 do not display message to enable debuginfo when it's already enabled 2023-01-31 22:36:20 +00:00
Rémy Rakic 9d9b7fef2d improve debuginfo error message when build script fails 2023-01-31 22:36:20 +00:00
Rémy Rakic 2bfc813b9f update test proc_macro_ws
This non-regression test didn't pass as-is because of the new debuginfo
build deps optimization. This restores the original intent of the test.
2023-01-31 22:36:20 +00:00
Rémy Rakic 3be6c93a22 update optional_build_dep_and_required_normal_dep test expectations
This test dynamically enables a shared build/runtime dependency, and
therefore doesn't trigger the build/runtime sharing reuse optimization,
as the build dep is initially built without debuginfo for optimization
purposes.
2023-01-31 22:36:20 +00:00
Rémy Rakic facdb30c03 add assertions checking the absence of debuginfo
Add some assertions to ensure that debuginfo is not used to compile
build dependencies, in a way that differs between the old and new
defaults: some of the assert elision could match the previous defaults
with debuginfo. These new assertions break if `-C debuginfo` is present
in the commands cargo ran.
2023-01-31 22:36:20 +00:00
bors 2c30ebe1ea Auto merge of #11647 - peterallin:peterallin/11617, r=weihanglo
Make cargo install report needed features

### What does this PR try to resolve?

The problem described in issue #11617 where cargo tells the user, that no binaries are available
because of the chosen features, but does not tell which features could be enabled to fix the
situation.

Fixes #11617.

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

Try to cargo install a crate, where all binaries need some features enabled, without enabling
the features and check the error message.

The test suite already contains tests for this.
2023-01-31 20:16:34 +00:00
Rémy Rakic 7dfabdc681 add build script failure test when requesting backtraces
it displays an additional message on how to improve these backtraces, now that
debuginfo is turned off most of the time in `dev.build-override`.
2023-01-31 20:12:52 +00:00
Rémy Rakic 6848006cbe update tests for build deps debuginfo optimization 2023-01-31 20:12:52 +00:00
Rémy Rakic 79dd5117da introduce dedicated DebugInfo enum in Profiles
This enum will be used to model the current Option<u32> value in
profiles, as the explicitly set value, and also allow to model a
deferred value: one that can be ignored for optimization purposes,
and used in all other cases.

This allows to have a default debuginfo for build dependencies, that can
change:
- if a dependency is shared between the build and runtime subgraphs, the
  default value will be used, to that re-use between units will
  continue.
- otherwise, a build dependency is only used in a context where
  debuginfo is not very useful. We can optimize build times in this
  situation by not asking rustc to emit debuginfo.
2023-01-31 19:05:20 +00:00
Peter Allin 862a3224d8 Add test of the new warning about missing features 2023-01-31 19:59:49 +01:00
Arlo Siemsen f1dadb6309 Do not error for auth-required: true without -Z sparse-registry 2023-01-31 11:03:02 -06:00
Peter Allin bac6a9a49c Add examples to the warning about missing features 2023-01-31 01:28:18 +01:00
bors 99b13692dd Auto merge of #11572 - khuey:dwp, r=weihanglo
Make cargo aware of dwp files.

When using -Csplit-debuginfo=packed on Linux, rustc will produce a dwp file. Unlike the dwo files, whose paths are embedded into the binary, there's no information in the binary to help a debugger locate a dwp file. By convention, the dwp file for `<EXE>` is given the name `<EXE>.dwp` and placed next to `<EXE>`.

When cargo hardlinks the executable file rustc put in target/debug/deps into target/debug, it also needs to hardlink the dwp file along with it. Failing to do this prevents the debugger from finding the dwp file when the binary is executed from target/debug, as there's no way for the debugger to know to look in the deps subdirectory.

The split_debuginfo option is passed down into file_types to make this possible. For cargo clean manual handling is added to match the other split_debuginfo files. bin_link_for_target also passes in None because it won't care about the dwp file.
2023-01-30 12:00:19 +00:00
Peter Allin 01fd6be397 Make cargo install report needed features
Fixes #11617.
2023-01-29 08:41:35 +01:00
Basile Henry d09e132622 config: Deny CARGO_HOME in [env] table (fixes #11590) 2023-01-28 12:32:22 +01:00
Weihang Lo 036ed3a2dd
test(cfg): parse rustc --print=split-debuginfo 2023-01-27 02:45:04 +00:00
bors 2ccd95097e Auto merge of #11565 - Muscraft:rework-toml-dependency, r=weihanglo
refactor(toml): Move `TomlWorkspaceDependency` out of `TomlDependency`

**This should not be merged until after #11409**

In #11523 it was noted that you could use `{}.workspace = true` in `[patch.{}]`, but it would cause a panic. This panic was caused by an oversight on my part when implementing [workspace inheritance](https://github.com/rust-lang/rfcs/blob/master/text/2906-cargo-workspace-deduplicate.md). Before this PR any field that had the type `TomlDependency` could specify `{}.workspace = true` and `cargo` would allow it to be a `TomlWorkspaceDependency`. While it could be `TomlWorkspaceDependency` it would never be resolved since only:

> Dependencies in the `[dependencies]`, `[dev-dependencies]`, [`build-dependencies]`, and `[target."...".dependencies]` sections will support the ability to reference the `[workspace.dependencies]` definition of dependencies.[^1]

This PR makes it so that only those fields can pull from `[workspace.dependencies]`, while still sharing `TomlDependency` everywhere it is needed. It does this by making `MaybeWorkspace` generic over both `Defined` and `Workspace`, then moving `TomlWorkspaceDependency` out of `TomlDependency` and into a `MaybeWorkspace` that the correct fields can use.

[^1]: [rfc2906-new-dependency-directives](https://github.com/rust-lang/rfcs/blob/master/text/2906-cargo-workspace-deduplicate.md#new-dependency-directives)

Closes: #11523
2023-01-25 23:51:25 +00:00
Scott Schafer 712b327f32 refactor(toml): Move TomlWorkspaceDependency out of TomlDependency 2023-01-25 10:50:55 -06:00
bors 04519ad831 Auto merge of #11612 - hi-rustin:rustin-patch-cargo-add, r=epage
`cargo add` check `[dependencies]` order without considering the dotted item

### What does this PR try to resolve?

Try to close https://github.com/rust-lang/cargo/issues/11584

`cargo check` check `[dependencies]` order without considering the dotted item.

### How should we test and review this PR?
See the unit test.
2023-01-25 15:44:23 +00:00
bors 99f841c083 Auto merge of #11613 - arriven:fix/11083-rerun-if-changed-published-sources-dir, r=epage
Improve CI caching by skipping mtime checks for paths in $CARGO_HOME

Skip mtime checks for paths pointing into `$CARGO_HOME` to avoid rebuilds when only caching $CARGO_HOME/registry/{index, cache} and $CARGO_HOME/git/db and some of the dependencies have `rerun-if-changed=directory` in their `build.rs`

I considered skipping mtime checking only on `$CARGO_HOME/registry/src` but it looks like other functionality (like downloading a newer version of dependency) is unaffected by this and this way we also cover the same issue with git based dependencies (except the part where `cargo` is forced to re-fetch submodules if `$CARGO_HOME/git/checkouts` is missing) and it is more in line with the discussion in #9455

Fix #11083

Credit `@weihanglo` for the test (I did add a case of checking that dependency update still triggers a rebuild but they are the original author of the rest of the test)
2023-01-24 13:31:37 +00:00
arriven 9e01c8bbcf skip mtime checks for paths in $CARGO_HOME 2023-01-24 08:27:33 +00:00
hi-rustin ea5ade3426 cargo check check [dependencies] order without considering the dotted item
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-01-22 22:55:07 +08:00
Scott Schafer b64b605236 fix(vendor): Make vendor use Manifest's "original" Cargo.toml 2023-01-18 22:19:56 -06:00
bors 23424fde2e Auto merge of #11067 - tedinski:install_workspace_root, r=weihanglo
Ignore `workspace.default-members` when running `cargo install` on root package of a non-virtual workspace

### What does this PR try to resolve?

* Fixes #11058

Two observable behaviors are fixed:

1. When running `cargo install` with `--path` or `--git` and specifically requesting the root package of a non-virtual workspace, `cargo install` will accidentally build `workspace.default-members` instead of the requested root package.
2. Further, if that `default-members` does not include the root package, it will install binaries from those other packages (the `default-members`) and claim they were the binaries from the root package! There is no way, actually, to install the root package binaries.

These two behaviors have the same root cause:

* `cargo install` effectively does `cargo build --release` in the requested package directory, but when this is the root of a non-virtual workspace, that builds `default-members` instead of the requested package.

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

I have included a test exhibiting this behavior. It currently fails in the manner indicated in the test, and passes with the changes included in this PR.

I'm not sure the solution in the PR is the _best_ solution, but the alternative I am able to come up with involves much more extensive changes to how `cargo install` works, to produce a distinct `CompileOptions` for every package built. I tried to keep the new workspace "API" `ignore_default_members()` as narrowly-scoped in its effect as possible.

### Additional information

The only way I could think this behavior change could impact someone is if they were somehow using `cargo install --path` (or `--git`) and wanting it to actually install the binaries from all of `default-members`. However, I don't believe that's possible, since if there are multiple packages with binaries, I believe cargo requires the packages to be specified. So someone would have to be additionally relying on specifying just the root package, but then wanting the binaries from more than just the root. I think this is probably an acceptable risk for merging!
2023-01-18 15:47:10 +00:00
bors a5d47a7259 Auto merge of #11583 - ehuss:container-tests, r=epage
Add network container tests

This adds some tests which use Docker containers to provide HTTPS and SSH servers. This should help with validating that Cargo's networking and security are working correctly.  It can also potentially be used in the future for other tests that require more complex setups.

These tests are only run on Linux in CI. macOS does not have Docker there, and the Windows Docker does not support Linux containers. The tests should work on macOS if you run them locally with Docker Desktop installed. The SSH tests do not work on Windows due to issues with ssh-agent, but the HTTPS tests should work with Docker Desktop.

These tests require an opt-in environment variable to run:

* `CARGO_PUBLIC_NETWORK_TESTS=1` — This is for tests that contact the public internet.
* `CARGO_CONTAINER_TESTS=1` — This is for tests that use Docker.
2023-01-16 18:51:50 +00:00
bors 2a5ff4cb9a Auto merge of #11579 - kawaemon:show-progress-on-git-cli-fetch, r=weihanglo
Show progress of crates.io index update even `net.git-fetch-with-cli` option enabled

### What does this PR try to resolve?

This PR fixes #11574 .

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

Please run `cargo` with `net.git-fetch-with-cli` option enabled.
It should show `git fetch`'s progress output like below.
```
❯ CARGO_NET_GIT_FETCH_WITH_CLI=true ./target/debug/cargo b
    Updating crates.io index
remote: Enumerating objects: 139821, done.
remote: Counting objects: 100% (2226/2226), done.
remote: Compressing objects: 100% (769/769), done.
receiving objects:   0% (1/139821)
```
2023-01-16 16:51:02 +00:00
Weihang Lo d02e36cea1
Only output field extern_name when using -Zbindeps 2023-01-16 14:12:32 +00:00
Weihang Lo 690e6a4128
cargo-metadata: error out if same dep with differnt names
Previous, `cargo metadata` allows a dependency with different renamed
co-exist. However, its `resolve.nodes.deps` will miss that dependency,
which is wrong. After this commit, `cargo metadata starts erroring out
for that situation.
2023-01-16 14:12:32 +00:00
Weihang Lo 272193aa29
cargo-metadata: error out when encountering invalid artifact kind syntax
This refactor reuse the logic of
`core::compiler::unit_dependencies::match_artifacts_kind_with_targets`
to emit error if there is any syntax error in `ArtifactKind`.

It also put `match_artifacts_kind_with_targets` to a better place `core::compiler::artifact`.
2023-01-16 14:12:13 +00:00
Weihang Lo e5ec492b6f
cargo-metadata: support -Zbindeps info 2023-01-16 14:12:13 +00:00
Kyle Huey 847dc6ed06 Make cargo aware of dwp files.
When using -Csplit-debuginfo=packed on Linux, rustc will produce a dwp file.
Unlike the dwo files, whose paths are embedded into the binary, there's no
information in the binary to help a debugger locate a dwp file. By convention,
the dwp file for <EXE> is given the name <EXE>.dwp and placed next to <EXE>.

When cargo hardlinks the executable file rustc put in target/debug/deps into
target/debug, it also needs to hardlink the dwp file along with it. Failing to
do this prevents the debugger from finding the dwp file when the binary is
executed from target/debug, as there's no way for the debugger to know to look
in the deps subdirectory.
2023-01-14 23:11:57 -08:00
Eric Huss 4cb9ac35bf Add network container tests 2023-01-14 15:10:16 -08:00
Eric Huss 73f19a01d0 Enable source_config_env test on Windows 2023-01-14 09:48:46 -08:00
kawaemon 5bd8ef62e0
update test snapshot 2023-01-15 00:18:12 +09:00
Weihang Lo 629f763be8
Support codegen-backend and rustflags in profiles in config file 2023-01-14 11:14:40 +00:00
Weihang Lo c51c6bb6ac
chore: reflect to clap updates 2023-01-14 09:23:39 +00:00
Ted Kaminski 7dc8be5414 Ignore workspace.default-members when running cargo install on root package of a non-virtual workspace 2023-01-13 00:12:06 +00:00
bors abc6abe34d Auto merge of #11561 - epage:typos, r=ehuss
chore: Fix typos

Seeing several typo PRs, like #11560, I figured I'd run my source code spell checker on cargo to help catch a lot of these earlier, in one big batch.
2023-01-11 14:15:24 +00:00
Ed Page ed8b85f10e chore: Fix typos 2023-01-10 20:03:11 -06:00
Scott Schafer 6131222ba2 feat: stabilize auto fix note 2023-01-10 13:52:29 -06:00
Scott Schafer 49d722cfe6 fix(toml): Add default-features to TomlWorkspaceDependency 2023-01-10 11:53:45 -06:00
bors 0849a28cc2 Auto merge of #11556 - pietroalbini:cve-2022-46176, r=weihanglo
Add fix for CVE-2022-46176

r? `@ehuss`
2023-01-10 17:26:08 +00:00
Eric Huss 018403ceaf
Add test for config Value in TOML array. 2023-01-10 14:36:37 +01:00
Arlo Siemsen 7dc5506756 Stabilize sparse-registry 2023-01-05 11:04:52 -06:00
Eric Huss fab135885c Fix panic on ignored target dependency. 2023-01-04 18:44:51 -08:00
Weihang Lo 3d862d8d8b
by default saves credentials to .cargo/credentials.toml 2023-01-04 16:25:52 +00:00
Weihang Lo 90d5e6a8c9
test: revive nightly plugin tests to work 2023-01-04 13:45:25 +00:00
bors dd9900585a Auto merge of #11407 - dnbln:reasons-for-rebuilding, r=weihanglo
Reasons for rebuilding
2022-12-30 13:25:46 +00:00
bors 7fb01c68c1 Auto merge of #10771 - Eh2406:asymmetric_tokens, r=ehuss
Asymmetric tokens

Builds on and is blocked by #10592. This adds initial support for Asymmetric Tokens #10519.
2022-12-29 16:39:06 +00:00
Dinu Blanovschi 2071acd5ec Add -v to some feature tests 2022-12-28 18:44:05 +01:00
Dinu Blanovschi 0beb5fe93d Simple explanations for why cargo rebuilds crates 2022-12-28 16:27:50 +01:00
bors 5a574d39f3 Auto merge of #10690 - AtkinsChang:vendor, r=hi-rustin
Support vendoring with different revs from same git repo

### What does this PR try to resolve?

Fixes #10667

### How should we test and review this PR?
test case is included
2022-12-26 22:16:55 +00:00
bors 2381cbdb4e Auto merge of #11478 - rvolosatovs:fix/bindeps-target, r=weihanglo
fix: deduplicate dependencies by artifact target

### What does this PR try to resolve?

In cases when a compile target is specified for a bindep and the crate depending on it, cargo fails to deduplicate the crate dependencies and attempts to build the dependent crate only once with non-deterministic feature set, which breaks e.g. https://github.com/rvolosatovs/musl-bindep-feature-bug

Fix the issue by including the optional artifact compile target in the `Unit` in order to avoid wrongfully deduplicating the dependent crates

Fixes https://github.com/rust-lang/cargo/issues/11463
Fixes https://github.com/rust-lang/cargo/issues/10837
Fixes https://github.com/rust-lang/cargo/issues/10525

Note, that this issue is already accounted for by `cargo`, but in different context a similar situation can occur while building the build script, which:
1. may be built for different target than the actual package target
2. may contain dependencies with different feature sets than the same dependencies in the dependency graph of the package itself

That's why this PR is simply reusing the existing functionality for deduplication

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

Build https://github.com/rvolosatovs/musl-bindep-feature-bug

### Additional information

This is based on analysis by `@weihanglo` in https://github.com/rust-lang/cargo/issues/10837#issuecomment-1339365374
I experimented with adding the whole `UnitFor` to the internal unit struct, but that seems unnecessary.

It would probably be nicer to refactor `IsArtifact` and instead turn it into a 3-variant enum with a possible compile target, but I decided against that to minimize the diff. Perhaps it's worth a follow-up?
2022-12-23 12:19:27 +00:00
bors 2a4a9b48fb Auto merge of #11503 - willcrichton:scrape-dev-deps-diagnostic, r=weihanglo
Add warning if potentially-scrapable examples are skipped due to dev-dependencies

### What does this PR try to resolve?

Another point of feedback I've received on the scrape-examples feature is that the dev-dependency situation is quite confusing and subtle. To make users more aware of the issue, I added a warning where Cargo will alert users when examples are skipped due to a dev-dependency requirement, along with proposing a fix.

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

The test `docscrape::no_scrape_with_dev_deps` has been updated to reflect this new warning.

r? `@weihanglo`

(PS thank you for the reviews Weihang. I know I'm doing lots of little patches right now to get this feature finalized. If you want to share the reviewing burden on scrape-examples with anyone else, let me know!)
2022-12-22 23:55:20 +00:00
Jacob Finkelman b6adac1a6b count calls to credential process 2022-12-22 21:53:45 +00:00
Will Crichton 1c4065c52e Simplify code and output of skipped_examples warning 2022-12-22 12:37:11 -08:00
Roman Volosatovs 548b2528fb
test: reproduce bindep dependency collision bug
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
2022-12-22 16:16:12 +01:00
Roman Volosatovs 6d43fa64ec
refactor: simplify rust-lang#10525 test case
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
2022-12-22 14:45:25 +01:00
bstrie 386645e990
test: add test for #10525 2022-12-22 14:45:25 +01:00
Roman Volosatovs 4677a7cce5
test: reproduce transitive bindep dependency bug
This is a unit test reproducing the bindep transitive dependency bug based upon examples from
- https://github.com/rust-lang/cargo/issues/10837
- https://github.com/rust-lang/cargo/issues/11463

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
2022-12-22 14:45:21 +01:00
Atkins Chang 0200d3b3ca
Add test for vendor with different revs from same git repo
Signed-off-by: Atkins Chang <atkinschang@gmail.com>
2022-12-21 11:44:23 +08:00
Will Crichton 6b9a28eb21 Add warning if potentially-scrapable examples are skipped due to dev-dependencies 2022-12-20 14:32:31 -08:00
bors 74c7aab19a Auto merge of #11499 - willcrichton:example-analyzer, r=weihanglo
Don't scrape examples from library targets by default

### What does this PR try to resolve?

Based on some [early feedback](https://www.reddit.com/r/rust/comments/zosle6/feedback_requested_rustdocs_scraped_examples/) about the scrape-examples feature, both documentation authors and consumers did not consider examples useful if they are scraped from a library's internals, at least in the common case. Therefore this PR changes the default behavior of `-Zrustdoc-scrape-examples` to *only* scrape from example targets, although library targets can still be configured for scraping.

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

I have updated the `docscrape` tests to reflect this new policy, as well as the Unstable Options page in the Cargo book.

r? `@weihanglo`
2022-12-20 21:10:16 +00:00
Will Crichton eb829cfb35 Improve failed scrape diagnostic 2022-12-20 12:13:41 -08:00
bors 1d8cdaa01e Auto merge of #11494 - ehuss:stabilize-diagnostic-width, r=weihanglo
Stabilize terminal-width

This stabilized the passing of the `--diagnostic-width` flag to rustc and rustdoc so that they will format diagnostics to fit within the terminal size. Previously they always assume the width is 140. The diagnostics are trimmed with `...` to elide parts of extra-long lines.

In cases where the width isn't known (such as not when used on a tty, or with mintty), then cargo does not pass the flag and the default of 140 is still used.

At this time there is no way for the user to override the width (unlike with the progress bar width). That can be added in the future if there is demand. https://github.com/rust-lang/rust/issues/84673#issuecomment-1179096971 contains some thoughts on some different ideas.

Closes https://github.com/rust-lang/rust/issues/84673
2022-12-19 22:00:52 +00:00
Jacob Finkelman d464dbbb5e add tests 2022-12-19 21:16:04 +00:00
Eric Huss 1709f0aee2 Stabilize terminal-width 2022-12-19 12:17:52 -08:00
bors 3f6c685285 Auto merge of #11477 - kylematsuda:workspace_lockfile, r=weihanglo
Use workspace lockfile when running `cargo package` and `cargo publish`

### What does this PR try to resolve?

Fix #11148.

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

Please run the integration test in `tests/testsuite/publish_lockfile.rs` or try the steps from the issue.
2022-12-19 18:16:27 +00:00
Kyle Matsuda 8c4f27fd5b make test clearer 2022-12-19 10:50:55 -07:00
Will Crichton 818debbf90 Don't scrape examples from library targets by default 2022-12-18 22:15:08 -08:00
Will Crichton d588298c3f Fix examples of proc-macro crates being scraped for examples 2022-12-18 10:41:21 -08:00
Weihang Lo 0523f42cc2
Revert "temporarily disable test lto::test_profile"
This reverts commit d5cac16d07.
2022-12-17 22:51:57 +00:00
Eric Huss b1bcc9c834 Fix collision_doc_profile test error 2022-12-15 20:04:50 -08:00
Scott Schafer 33c32088fa fix: Make auto-fix note work with clippy 2022-12-15 10:54:35 -06:00
Philpax 249683b456
fix(tests): update to match add change 2022-12-15 09:34:23 +01:00