Commit graph

4322 commits

Author SHA1 Message Date
Will Crichton e4a65b91be Fix several bugs when checking wasmtime repo:
* Docscrape unit not having dev-dependencies included
* Sources for reverse-dependencies generated to the wrong directory
* Incorrect features being selected for Docscrape units
* Panics from Docscrape-dependent packages not being available
2021-10-27 11:42:31 -07:00
Eric Huss 88117505b8 Bump to 0.59.0 2021-10-22 07:53:17 -07:00
bors 7fbbf4e8f2 Auto merge of #9953 - Aaron1011:nicer-incompat-report, r=ehuss
Make future-incompat-report output more user-friendly

When the user enables `--future-incompat-report`, we now display
a high-level summary of the problem, as well as several suggestions
for fixing the affected crates.

The command `cargo report future-incompatibilities` now takes
a `--crate` option, which can be used to display a report
(including the actual lint messages) for a single crate.
When this option is not used, we display the report for all
crates.

Sample output from the `actix` crate:

`> RUSTFLAGS="-Z future-incompat-test" ~/repos/cargo/target/debug/cargo build -Z future-incompat-report
`

```
    Finished dev [unoptimized + debuginfo] target(s) in 2.09s
warning: the following packages contain code that will be rejected by a future version of Rust: actix v0.11.1 (/home/aaron/repos/actix/actix), ahash v0.7.4, arc-swap v0.4.4, autocfg v1.0.0, crossbeam-utils v0.8.5, futures-macro v0.3.17, futures-util v0.3.17, lazy_static v1.4.0, libc v0.2.103, lock_api v0.4.5, log v0.4.8, mio v0.7.13, parking_lot_core v0.8.5, signal-hook-registry v1.2.0, smallvec v1.7.0, syn v1.0.77, tokio v1.12.0, tokio-util v0.6.8, unicode-xid v0.2.0, version_check v0.9.3
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 2`

```

`> RUSTFLAGS="-Z future-incompat-test" ~/repos/cargo/target/debug/cargo build -Z future-incompat-report --future-incompat-report -Z unstable-options`

```
    Finished dev [unoptimized + debuginfo] target(s) in 2.12s
warning: the following packages contain code that will be rejected by a future version of Rust: actix v0.11.1 (/home/aaron/repos/actix/actix), ahash v0.7.4, arc-swap v0.4.4, autocfg v1.0.0, crossbeam-utils v0.8.5, futures-macro v0.3.17, futures-util v0.3.17, lazy_static v1.4.0, libc v0.2.103, lock_api v0.4.5, log v0.4.8, mio v0.7.13, parking_lot_core v0.8.5, signal-hook-registry v1.2.0, smallvec v1.7.0, syn v1.0.77, tokio v1.12.0, tokio-util v0.6.8, unicode-xid v0.2.0, version_check v0.9.3
note:
To solve this problem, you can try the following approaches:

- Some affected dependencies have newer versions available.
You may want to consider updating them to a newer version to see if the issue has been fixed.

ahash v0.7.4 has the following newer versions available: 0.7.5
arc-swap v0.4.4 has the following newer versions available: 0.4.8, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.4.0
autocfg v1.0.0 has the following newer versions available: 1.0.1
log v0.4.8 has the following newer versions available: 0.4.11, 0.4.13, 0.4.14
signal-hook-registry v1.2.0 has the following newer versions available: 1.2.1, 1.2.2, 1.3.0, 1.4.0
syn v1.0.77 has the following newer versions available: 1.0.78, 1.0.79, 1.0.80
unicode-xid v0.2.0 has the following newer versions available: 0.2.1, 0.2.2

- If the issue is not solved by updating the dependencies, a fix has to be
  implemented by those dependencies. You can help with that by notifying the
  maintainers of this problem (e.g. by creating a bug report) or by proposing a
  fix to the maintainers (e.g. by creating a pull request):

  - actix:0.11.1
    - Repository: https://github.com/actix/actix
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "actix:0.11.1"

  - ahash:0.7.4
    - Repository: https://github.com/tkaitchuck/ahash
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "ahash:0.7.4"

  - arc-swap:0.4.4
    - Repository: https://github.com/vorner/arc-swap
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "arc-swap:0.4.4"

  - autocfg:1.0.0
    - Repository: https://github.com/cuviper/autocfg
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "autocfg:1.0.0"

  - crossbeam-utils:0.8.5
    - Repository: https://github.com/crossbeam-rs/crossbeam
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "crossbeam-utils:0.8.5"

  - futures-macro:0.3.17
    - Repository: https://github.com/rust-lang/futures-rs
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "futures-macro:0.3.17"

  - futures-util:0.3.17
    - Repository: https://github.com/rust-lang/futures-rs
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "futures-util:0.3.17"

  - lazy_static:1.4.0
    - Repository: https://github.com/rust-lang-nursery/lazy-static.rs
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "lazy_static:1.4.0"

  - libc:0.2.103
    - Repository: https://github.com/rust-lang/libc
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "libc:0.2.103"

  - lock_api:0.4.5
    - Repository: https://github.com/Amanieu/parking_lot
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "lock_api:0.4.5"

  - log:0.4.8
    - Repository: https://github.com/rust-lang/log
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "log:0.4.8"

  - mio:0.7.13
    - Repository: https://github.com/tokio-rs/mio
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "mio:0.7.13"

  - parking_lot_core:0.8.5
    - Repository: https://github.com/Amanieu/parking_lot
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "parking_lot_core:0.8.5"

  - signal-hook-registry:1.2.0
    - Repository: https://github.com/vorner/signal-hook
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "signal-hook-registry:1.2.0"

  - smallvec:1.7.0
    - Repository: https://github.com/servo/rust-smallvec
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "smallvec:1.7.0"

  - syn:1.0.77
    - Repository: https://github.com/dtolnay/syn
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "syn:1.0.77"

  - tokio:1.12.0
    - Repository: https://github.com/tokio-rs/tokio
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "tokio:1.12.0"

  - tokio-util:0.6.8
    - Repository: https://github.com/tokio-rs/tokio
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "tokio-util:0.6.8"

  - unicode-xid:0.2.0
    - Repository: https://github.com/unicode-rs/unicode-xid
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "unicode-xid:0.2.0"

  - version_check:0.9.3
    - Repository: https://github.com/SergioBenitez/version_check
    - Detailed warning command: `cargo report future-incompatibilities --id 3 --crate "version_check:0.9.3"

- If waiting for an upstream fix is not an option, you can use the `[patch]`
  section in `Cargo.toml` to use your own version of the dependency. For more
  information, see:
  https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section

note: this report can be shown with `cargo report future-incompatibilities -Z future-incompat-report --id 3`
```

`> RUSTFLAGS="-Z future-incompat-test" ~/repos/cargo/target/debug/cargo report future-incompatibilities -Z future-incompat-report --color never | head -n 100`

```
The following warnings were discovered during the build. These warnings are an
indication that the packages contain code that will become an error in a
future release of Rust. These warnings typically cover changes to close
soundness problems, unintended or undocumented behavior, or critical problems
that cannot be fixed in a backwards-compatible fashion, and are not expected
to be in wide use.

Each warning should contain a link for more information on what the warning
means and how to resolve it.

- Some affected dependencies have newer versions available.
You may want to consider updating them to a newer version to see if the issue has been fixed.

ahash v0.7.4 has the following newer versions available: 0.7.5
arc-swap v0.4.4 has the following newer versions available: 0.4.8, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.4.0
autocfg v1.0.0 has the following newer versions available: 1.0.1
log v0.4.8 has the following newer versions available: 0.4.11, 0.4.13, 0.4.14
signal-hook-registry v1.2.0 has the following newer versions available: 1.2.1, 1.2.2, 1.3.0, 1.4.0
syn v1.0.77 has the following newer versions available: 1.0.78, 1.0.79, 1.0.80
unicode-xid v0.2.0 has the following newer versions available: 0.2.1, 0.2.2

The package `actix v0.11.1 (/home/aaron/repos/actix/actix)` currently triggers the following future incompatibility lints:
> warning: use of deprecated struct `utils::Condition`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:25:9
>    |
> 25 | impl<T> Condition<T>
>    |         ^^^^^^^^^
>    |
> note: the lint level is defined here
>   --> actix/src/lib.rs:30:10
>    |
> 30 | #![allow(deprecated)]
>    |          ^^^^^^^^^^
>
> warning: use of deprecated struct `utils::Condition`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:42:21
>    |
> 42 | impl<T> Default for Condition<T>
>    |                     ^^^^^^^^^
>
> warning: use of deprecated struct `utils::Condition`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:47:9
>    |
> 47 |         Condition {
>    |         ^^^^^^^^^
>
> warning: use of deprecated struct `utils::Condition`: Please use tokio::sync::oneshot::Sender instead.
>    --> actix/src/lib.rs:120:28
>     |
> 120 |     pub use crate::utils::{Condition, IntervalFunc, TimerFunc};
>     |                            ^^^^^^^^^
>
> warning: use of deprecated associated function `std::sync::atomic::AtomicUsize::compare_and_swap`: Use `compare_exchange` or `compare_exchange_weak` instead
>    --> actix/src/address/channel.rs:512:49
>     |
> 512 |             let actual = self.inner.num_senders.compare_and_swap(curr, next, SeqCst);
>     |                                                 ^^^^^^^^^^^^^^^^
>
> warning: use of deprecated associated function `std::sync::atomic::AtomicUsize::compare_and_swap`: Use `compare_exchange` or `compare_exchange_weak` instead
>    --> actix/src/address/channel.rs:636:49
>     |
> 636 |             let actual = self.inner.num_senders.compare_and_swap(curr, next, SeqCst);
>     |                                                 ^^^^^^^^^^^^^^^^
>
> warning: use of deprecated associated function `std::sync::atomic::AtomicUsize::compare_and_swap`: Use `compare_exchange` or `compare_exchange_weak` instead
>    --> actix/src/address/channel.rs:697:49
>     |
> 697 |             let actual = self.inner.num_senders.compare_and_swap(curr, next, SeqCst);
>     |                                                 ^^^^^^^^^^^^^^^^
>
> warning: use of deprecated field `utils::Condition::waiters`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:31:9
>    |
> 31 |         self.waiters.push(tx);
>    |         ^^^^^^^^^^^^
>
> warning: use of deprecated field `utils::Condition::waiters`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:36:23
>    |
> 36 |         for waiter in self.waiters {
>    |                       ^^^^^^^^^^^^
>
> warning: use of deprecated field `utils::Condition::waiters`: Please use tokio::sync::oneshot::Sender instead.
>   --> actix/src/utils.rs:48:13
>    |
> 48 |             waiters: Vec::new(),
>    |             ^^^^^^^^^^^^^^^^^^^
>
> warning: unused variable: `ctx`
>   --> actix/src/actor.rs:78:27
>    |
> 78 |     fn started(&mut self, ctx: &mut Self::Context) {}
>    |                           ^^^ help: if this is intentional, prefix it with an underscore: `_ctx`
>    |
> note: the lint level is defined here
>   --> actix/src/actor.rs:72:9
>    |
> 72 | #[allow(unused_variables)]
>    |         ^^^^^^^^^^^^^^^^
```
2021-10-19 02:16:48 +00:00
Eric Huss 8d5576ba81 Fix fetching git repos after a force push. 2021-10-18 14:08:33 -07:00
Aaron Hill 5c3b38086f
Adjust comments 2021-10-18 12:06:23 -05:00
Aaron Hill 958f2fc962
Display more information in report 2021-10-18 12:01:07 -05:00
Will Crichton b948fc86c0 Add test / documentation for scrape-examples cycle-avoidance, add map for doc unit -> metadata to Context 2021-10-14 16:06:26 -07:00
bors bd6a512206 Auto merge of #9916 - chansuke:issue-9895, r=ehuss
Add rustc-link-args to doctest build

Fix #9895
2021-10-14 03:22:12 +00:00
chansuke 2fabe52ccd Add rustc-link-args to doctest build 2021-10-14 10:24:16 +09:00
Will Crichton 8b06a0f2f7 Update rustdoc tests with -Cmetadata flag 2021-10-12 19:33:23 -07:00
Will Crichton 470556603e Add documentation and a test 2021-10-12 19:11:07 -07:00
Aaron Hill 6f18507092
Display update message in report 2021-10-12 17:02:13 -05:00
Aaron Hill 49ae189b3b
Combined newer versions into single list 2021-10-12 16:35:01 -05:00
Aaron Hill ce259228cd
Change package spec 2021-10-12 16:35:01 -05:00
Aaron Hill 20340e1e79
Rename arg and adjust tests 2021-10-12 16:35:01 -05:00
Aaron Hill d5538c3869
Make future-incompat-report output more user-friendly
When the user enables `--future-incompat-report`, we now display
a high-level summary of the problem, as well as several suggestions
for fixing the affected crates.

The command `cargo report future-incompatibilities` now takes
a `--crate` option, which can be used to display a report
(including the actual lint messages) for a single crate.
When this option is not used, we display the report for all
crates.
2021-10-12 16:35:01 -05:00
Will Crichton 8331d7d151 Remove more unused code 2021-10-12 14:22:17 -07:00
bors 2e6a4e135e Auto merge of #9967 - flip1995:rust_version_meta, r=alexcrichton
Add rust_metadata to SerializedPackage

After the rust_version field was stabilized in #9732 this adds the
rust_version as output to the `cargo metadata` command, so tools like
Clippy can read and use it as well.

We will probably need this for rust-lang/rust-clippy#7765
2021-10-12 14:40:34 +00:00
flip1995 390af27128
Add rust_metadata to SerializedPackage
After the rust_version field was stabilized in #9732 this adds the
rust_version as output to the `cargo metadata` command, so tools like
Clippy can read and use it as well.
2021-10-12 14:07:19 +02:00
Eric Huss 5a8be7ba21 Add os to verbose version string. 2021-10-11 11:22:48 -07:00
Eric Huss c5318a17e7 Add some more information to verbose version. 2021-10-08 12:54:24 -07:00
Will Crichton 5ed35a4be7 Fix test 2021-10-07 19:15:15 -07:00
bors dea587a61c Auto merge of #9938 - weihanglo:issue-9857, r=ehuss
Skip all `cargo fix` that tends to write to registry cache.

Skip all `cargo fix` that tends to write to registry cache.

This is a temporary hack for #9857. The real fix may need to touch rustc.
2021-10-07 20:06:39 +00:00
bors ec38c84ab1 Auto merge of #9943 - ehuss:stabilize-named-profiles, r=alexcrichton
Stabilize named profiles

This stabilizes the named profiles feature. As an overview of what this does, it allows specifying custom named profiles, such as:

```toml
[profile.release-lto]
inherits = "release"
lto = true
```

And enables the use of the `--profile` CLI option to choose a profile by name.

Another key change here is that cargo now only uses a single profile per command. Previously, some commands such as `cargo test` would use a mix of profiles based on which package and target were being built.

### Summary of new behavior

* Profiles can now have arbitrary names. New profiles require the `inherits` key.
* The `--profile` flag is now available on all build commands.
* The `CompileMode` is no longer considered for choosing the profile, only one profile will be used. Previously, building a test, benchmark, or doctest would use the test or bench profile, and all dependencies would use the dev/release profiles. This change is done to arguably make it easier to understand, and to possibly give more desired and intuitive behavior.
* The `test` profile now inherits settings from the `dev` profile (and `bench` from `release`).

### Deviations from the original RFC and implementation

* The original RFC indicated that `--all-targets` without `--profile` would retain the old behavior where it would use different profiles for different targets. However, the implementation uses a single profile, to avoid confusion and to keep things simple.
* The `dir-name` key is not exposed to the user. The implementation is retained to handle mapping of built-in profile names (test/dev→debug, bench→release). This can be exposed in the future if necessary.

### Notes about this PR

* Fixed an issue where the duplicate package override check would randomly return matches for inherited profiles like `test`.
* I left some of the old, vestigial code behind to possibly make it easier to revert this PR if necessary. If this does land, I think it can be eventually removed (code using `Feature::named_profiles` and various things using `named_profiles_enabled`).
* Added `target` to reserved list, just because.
* Adds a warning if `--release` is combined with `--profile` in `cargo rustc`, `check`, or `fix`. The `--release` flag was being ignored.

### Hazards and concerns

* This has had very little real-world testing.
* Custom profile directories may conflict with other things in the `target` directory. We have reserved profile names that currently conflict (such as `doc` or `package`). However, they can still collide with target names. This also presents a hazard if Cargo ever wants to add new things to that top directory. We decided to proceed with this because:
    * We currently have no plans to add new built-in profiles.
    * We have reserved several profile names (including anything starting with "cargo"), and the profile name syntax is deliberately limited (so cargo is still free to add `.` prefixed hidden directories).
    * A user creating a profile that collides with a target name resides in the "don't do that" territory. Also, that shouldn't be catastrophic, as the directories are still somewhat organized differently.
* Artifacts may no longer be shared in some circumstances. This can lead to substantially increased `target` directory sizes (and build times), particularly if the `test` profile is not the same as the `dev` profile. Previously, dependencies would use the `dev` profile for both. If the user wants to retain the old behavior, they can use an override like `[profile.test.package."*"]` and set the same settings as `dev`.
* This may break existing workflows. It is possible, though unlikely, that changes to the profile settings will cause changes to how things build in such a way to break behavior.
    * Another example is using something like `cargo build` to prime a cache that is used for `cargo test`, and there is a custom `test` profile, the cache will no longer be primed.
* The legacy behavior with `cargo rustc`, `cargo check`, and `cargo fix` may be confusing. We may in the future consider something like a `--mode` flag to formalize that behavior.
* The `PROFILE` environment variable in build scripts may cause confusion or cause problems since it only sets `release` or `debug`. Some people may be using that to determine if `--release` should be used for a recursive `cargo` invocation. Currently I noted in the documentation that it shouldn't be used. However, I think it could be reasonable to maybe add a separate environment variable (`PROFILE_NAME`?) that exposes the actual profile used. We felt that changing the existing value could cause too much breakage (and the mapping of debug→dev is a little awkward).

Closes #6988
2021-10-07 17:42:56 +00:00
bors 4a166de89f Auto merge of #9847 - weihanglo:issue-9840, r=Eh2406
Distinguish lockfile version req from normal dep in resolver error message

Resolves #9840

This PR adds a new variant `OptVersionReq::Locked` as #9840 described.
The new variant represents as a locked version requirement that contains
an exact locked version and the original version requirement.

Previously we use exact version req to synthesize locked version req.
Now we make those need a truly locked to be `OptVersionReq::Locked`,
including:

- `[patch]`: previous used exact version req to emulate locked version,
  and it only need to lock dep version but not source ID, so we make
  an extra method `Dependency::lock_version` for it.
- Dependencies from lock files: No need to change the call site.
2021-10-05 18:16:42 +00:00
bors d56b42c549 Auto merge of #9945 - ehuss:update-precise-metadata, r=alexcrichton
Allow `cargo update --precise` with metadata.

`cargo update --precise` would require that the version matches *exactly*, including build metadata.  Usually the build metadata is ignored (like in dependency declarations), but in this circumstance it isn't.  This can be awkward in some cases where it can be more convenient to type just the version number without the build metadata.

This changes it so that if the metadata isn't provided, then it will be ignored when matching.  Otherwise, it will be honored. This is slightly different from a version requirement like `=1.2.3+foo` which ignores the metadata completely.

This also adds a slightly better error message if you don't type in valid syntax for a version number (previously it would just emit the `no matching package` error).
2021-09-27 13:44:18 +00:00
Nipunn Koorapati b8b127a870 Support path_in_vcs as part of cargo_vcs_metadata 2021-09-26 13:37:56 -04:00
Eric Huss 8fe3bde2b5 Allow cargo update --precise with metadata. 2021-09-25 10:09:13 -07:00
Eric Huss 595384ffda Add future compatibility warning on mixture of --release with --profile.
This was historically allowed, but it silently ignores the --release flag.
2021-09-24 10:59:00 -07:00
Eric Huss 895f52714c Stabilize named profiles. 2021-09-24 10:00:42 -07:00
Weihang Lo 0565dafd87
Skip all cargo fix that tends to write to registry cache. 2021-09-23 23:31:10 +08:00
l00556901 128ed4c964 add test 2021-09-22 11:36:08 +08:00
Ed Page 2fdb7100cc Remove TOML incompatibility hacks
- `set_require_newline_after_table` was added in #2680 back in 2016
- `set_allow_duplicate_after_longer_table` was added in #6761 in 2019

Several years later, this PR is turning these warnings into errors.

The function and documentation was kept so we can add additional hacks
in the future, like if we switch TOML parsers.
2021-09-21 14:48:18 -05:00
Weihang Lo d22623466d
Show original version_req for locked dependency
When encounter resolver error with locked dependency, we now show
original version req along with the exact locked version.
2021-09-20 11:31:59 +08:00
Eric Huss d4e504ca85
Revert "When a dependency does not have a version, git or path, fails directly" 2021-09-14 13:04:03 -07:00
bors f7ca659fd3 Auto merge of #9905 - ehuss:wrong-output-error, r=alexcrichton
Improve "wrong output" error.

The error message for an improperly formatted build script output was a bit abrupt and unhelpful.  This adds some more details to the error message.
2021-09-13 18:07:19 +00:00
Noah Lev f6823a6427 Fix warnings from better precision of dead_code lint
The lint now ignores derived `Clone` and `Debug` implementations, as of
PR rust-lang/rust#85200, which landed a couple of days ago.

I sprinkled `#[allow(dead_code)]` in a few places; the fields are not
expected to be read since they are just part of a very specific test.
2021-09-13 10:25:52 -07:00
Eric Huss c4e92ac69a Improve "wrong output" error. 2021-09-11 16:34:09 -07:00
bors 2274489833 Auto merge of #9900 - ehuss:version-bump, r=alexcrichton
Bump to 0.58.0, update changelog
2021-09-10 18:24:27 +00:00
Eric Huss 0603dc0f20 Bump to 0.58.0 2021-09-10 09:47:06 -07:00
Eric Huss 49cf3de927 Fix rustc --profile=dev unstable check. 2021-09-10 09:40:37 -07:00
bors d7f413d682 Auto merge of #9893 - ehuss:windows-echo, r=alexcrichton
Enable some tests on windows.

This enables some more tests on windows that were disabled because `echo` is not always available. It's pretty easy to make a custom `echo`, so that's what this does.  I'm generally not comfortable with disabling tests just because there is an inconvenience like this.
2021-09-09 15:33:04 +00:00
Eric Huss 422d5b030c Enable some tests on windows. 2021-09-08 23:34:37 -07:00
Eric Huss 9b82a780f3 Enable strip test on macos. 2021-09-08 20:12:35 -07:00
bors 7d7c37089d Auto merge of #9859 - dtolnay-contrib:pullrequest, r=ehuss
rev = "refs/pull/𑑛/head"

GitHub exposes a named reference associated with the head of every pull request. For example, you can fetch *this* pull request:

```console
$ git fetch origin refs/pull/9859/head
$ git show FETCH_HEAD
```

Usually when I care about pulling in a patch of one of my dependencies using `[patch.crates-io]`, this is the ref that I want to depend on. None of the alternatives are good:

- `{ git = "the fork", branch = "the-pr-branch" }` &mdash; this is second closest to what I want, except that when the PR merges and the PR author deletes their fork, it'll breaks.

- `{ git = "the fork", rev = "commithash" }` &mdash; same failure mode as the previous. Also doesn't stay up to date with PR, which is sometimes what I want.

- `{ git = "the upstream", rev = "commithash" }` &mdash; doesn't work until the PR is merged or the repo owner creates a named branch or tag containing the PR commit among its ancestors, because otherwise the commit doesn't participate in Cargo's fetch.

- `{ git = "my own fork of PR author's repo", branch = "the-pr-branch" }` &mdash; doesn't stay up to date with PR.

This PR adds support for specifying a git dependency on the head of a pull request via the existing `rev` setting of git dependencies: `{ git = "the upstream", rev = "refs/pull/9859/head" }`.

Previously this would fail because the `cargo::sources::git::fetch` function touched in this pull request did not fetch the refspec that we care about. The failures look like:

```console
error: failed to get `mockall` as a dependency of package `testing v0.0.0`

Caused by:
  failed to load source for dependency `mockall`

Caused by:
  Unable to update https://github.com/asomers/mockall?rev=refs/pull/330/head

Caused by:
  revspec 'refs/pull/330/head' not found; class=Reference (4); code=NotFound (-3)
```

If dual purposing `rev` for this is not appealing, I would alternatively propose `{ git = "the upstream", pull-request = "9859" }` which Cargo will interpret using GitHub's ref naming convention as `refs/pull/9859/head`.
2021-09-07 17:51:57 +00:00
dswij bd005850d8 Update test output for hint on project creation [bin] -> [[bin]] 2021-09-06 15:51:33 +08:00
bors 18751dd3f2 Auto merge of #9850 - hi-rustin:rustin-patch-no-track, r=alexcrichton
print the full destination path when no track duplicates

close https://github.com/rust-lang/cargo/issues/9797
2021-09-01 14:26:00 +00:00
David Tolnay 361b11000a
Add test of git dependency on pull request 2021-09-01 00:42:06 -07:00
Eric Huss 68753e2874 Temporarily move test lockfile_constant_during_new to nightly. 2021-08-31 22:44:34 -07:00
Eric Huss 7a6377092c Make --force-warn support auto-detect. 2021-08-31 22:24:02 -07:00
Eric Huss e6a783acd4 Stabilize 2021 edition 2021-08-31 22:24:00 -07:00
bors 72aee9e815 Auto merge of #9839 - jonhoo:prefer-cargo-toml-patch, r=ehuss
Stabilize patch-in-config (and prefer config over manifest)

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

---

This stabilizes the `patch-in-config` feature ([unstable entry](https://doc.rust-lang.org/cargo/reference/unstable.html#patch-in-config)) following the discussion in https://github.com/rust-lang/cargo/issues/9269#issuecomment-904913263.

As requested, this PR _also_ changes the precedence behavior such that a `[patch]` for the same dependency in both `.cargo/config.toml` and `Cargo.toml` prefers the patch from the configuration file over the one from the manifest, which matches the behavior of other overlapping configuration options. The corresponding test has also been updated to reflect this change in behavior.
2021-09-01 04:55:13 +00:00
bors 54c341d3d0 Auto merge of #9808 - QiangHeisenberg:examples, r=ehuss
Adding the cargo doc --examples subcommand

Adding the cargo doc --examples subcommand

#4508
2021-09-01 04:28:18 +00:00
bors dd474f8d58 Auto merge of #9796 - hi-rustin:rustin-patch-clippy, r=ehuss
Make library created with `cargo new` clippy happy

close https://github.com/rust-lang/cargo/issues/9759
2021-09-01 04:04:11 +00:00
David Tolnay 05f6604660
Swap out some outdated repo urls in documentation 2021-08-31 13:33:02 -07:00
hi-rustin 774ccc39a5 Make windows CI happy
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-08-31 16:54:16 +08:00
hi-rustin 5da9bed1e5 print the full destination path when no track duplicates
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-08-31 15:30:48 +08:00
bors c22756541a Auto merge of #9846 - ehuss:fix-only-edition-lints, r=alexcrichton
Change `cargo fix --edition` to only fix edition lints.

This changes it so that `cargo fix --edition` will only fix edition lints.  The reason for this is that sometimes non-edition lints get in the way, and make suggestions that can cause failures.  An example is a user that only ever runs `cargo test` or `cargo check --profile=test` locally, and doesn't realize there are problems with running without `cfg(test)` such as unused warnings.

This works by using `--cap-lints=allow` along with `--force-warn` which takes precedence over `cap-lints`.

This only works on nightly since `--force-warn` is still unstable.  I will update this as part of #9800.

Closes #5738
2021-08-30 14:17:26 +00:00
bors 46fa867ff7 Auto merge of #9848 - nipunn1313:desc, r=alexcrichton
Show desc of well known subcommands (fmt, clippy) in cargo --list

Fixes #8680

An approach to #8680 that shows these in `cargo --list` without showing them directly in the `cargo --help`.

```
➜  cargo git:(desc) target/debug/cargo --list | grep clippy
    clippy               Checks a package to catch common mistakes and improve your Rust code.
```

Here's what mine looks like visually now:
![image](https://user-images.githubusercontent.com/1300387/131178775-2255ef0d-1993-47dd-bc73-9015394b967c.png)
2021-08-27 19:40:28 +00:00
Nipunn Koorapati 1edd8630c9 Show desc of well known subcommands (fmt, clippy) in cargo --list 2021-08-27 12:28:30 -07:00
Eric Huss 46450d6e3a Change cargo fix --edition to only fix edition lints. 2021-08-27 11:28:03 -07:00
bors f559c109cc Auto merge of #9843 - ehuss:fix-test-cargo-env, r=alexcrichton
Fix test not to rely on `cargo` in PATH.

This fixes a test that was trying to execute `cargo` from PATH.  This test doesn't work on rust-lang/rust where the rustup installation is removed, and thus there is no `cargo` in PATH.
2021-08-26 22:54:55 +00:00
Eric Huss e0bd1877d0 Fix test not to rely on cargo in PATH. 2021-08-26 14:06:32 -07:00
bors 77a0379342 Auto merge of #9827 - weihanglo:issue-6199, r=Eh2406
Improve resolver message to include dependency requirements

Resolves #6199.

Thanks for previous efforts: #5452, #6374, #6665, which are great but somehow outdated, so I tweak them and create this PR. This will also be obsolete if we ship pubgrub-rs with cargo in the future 😃 But before that happens, IMO these changes are still helpful.

---

This PR changes the resolver error message from

216f915c46/tests/testsuite/build.rs (L1104-L1106)

to

0afd40b4de/tests/testsuite/build.rs (L1104-L1106)

Also provide different message for different source kinds, such like:

0afd40b4de/tests/testsuite/build.rs (L2810-L2812)

## TODO?

From https://github.com/rust-lang/cargo/pull/5452#issuecomment-402832200, there shall be at least one task left behind:

> 3. Special case pind by a lock file and not a `"=1.1.2"` in a dependency. Also add a "note: try cargo update" to the end.

In this PR, `validate_links` also faces this issue that a dependency requirement is locked into a precise version `=0.1.0`.

a5f8bc94f5/tests/testsuite/build_script.rs (L1002-L1004)

I am uncertain about how to resolve this. Besides  the function`validate_links`, is this problem really a thing that may happen? If not, since `validate_links` only handles old validation logic, it may be ok to drop the commit a5f8bc94f5 and leave it as is.
2021-08-25 17:36:11 +00:00
Jon Gjengset 1e0d564ff0 Stabilize patch-in-config 2021-08-24 12:55:04 -07:00
Jon Gjengset d47c52e7c4 Prefer config [patch] over manifest [patch] 2021-08-24 12:54:49 -07:00
l00556901 1bbd505a72 add fmt 2021-08-24 17:49:21 +08:00
l00556901 2929efdf88 add --examples subcommand 2021-08-24 17:44:58 +08:00
bors 9b81660b79 Auto merge of #9834 - ehuss:fix-build-std-proc-macro-only, r=alexcrichton
Fix panic with build-std of a proc-macro.

If you try to run `cargo build -Zbuild-std` in a proc-macro project, cargo would panic in [`check_collisions`](835d5576e1/src/cargo/core/compiler/context/mod.rs (L427)). This is because it iterates over every Unit in the build graph checking the `outputs` for filenames.  However, [`outputs`](835d5576e1/src/cargo/core/compiler/context/compilation_files.rs (L109-L110)) was missing the outputs for standard library units. That is because `outputs` is computed by walking the graph starting from the roots.

The bug here is that `attach_std_deps` was adding the standard library units to graph, even though they aren't reachable from the roots, thus creating orphans.

The solution is to avoid adding the standard library units if they are not needed (as is the case when building just a proc-macro).

Fixes #9828
2021-08-23 20:04:47 +00:00
bors f066c50d65 Auto merge of #9821 - steffahn:a_an, r=Eh2406
Fix typos “a”→“an”

See rust-lang/rust#88230
2021-08-23 19:39:22 +00:00
Eric Huss 00e925f61f Fix panic with build-std of a proc-macro. 2021-08-23 12:06:32 -07:00
bors 3f68ff4fe3 Auto merge of #9818 - hi-rustin:rustin-patch-fix, r=alexcrichton
unset the FIX_ENV when executing the real rustc

close https://github.com/rust-lang/cargo/issues/9706
2021-08-23 17:03:28 +00:00
Weihang Lo a5f8bc94f5
Improve resolver message for validate_links 2021-08-24 00:39:38 +08:00
Weihang Lo 0afd40b4de
Update tests to display dep-req info for dep-chain 2021-08-24 00:39:38 +08:00
bors 8b5771f05e Auto merge of #9792 - weihanglo:issue-9782, r=ehuss
Emit warning for migrating to unstable edition in stable channel

Resolves #9782

Also alter the original error message slightly.
2021-08-23 16:07:05 +00:00
bors 491deb6de8 Auto merge of #9771 - hi-rustin:rustin-patch-dep, r=ehuss
Warning for no lib dependencies

close https://github.com/rust-lang/cargo/issues/6702
2021-08-23 15:36:56 +00:00
Eric Huss ec23482df8 Temporarily disable extern-html-root-url test.
A change in https://github.com/rust-lang/rust/pull/82776 broke this test,
so disabling for now until it is figured out how things are going to work.
2021-08-22 09:24:46 -07:00
Frank Steffahn ff881ee262 Fix more typos, “an”→“a” and “an”→“and” 2021-08-22 17:57:35 +02:00
hi-rustin 4c11002b9d Better fmt for file body
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-08-21 23:54:59 +08:00
hi-rustin 4225c46297 unset the FIX_ENV when executing the real rustc
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-08-21 23:48:49 +08:00
bors 216f915c46 Auto merge of #9814 - ehuss:move-tmp, r=alexcrichton
Move `tmp` test directory.

The `tmp` directory added in #9375 was placed within the profile directory (such as `target/debug/tmp` or `target/release/tmp`).  This causes problems for any cargo target (binary, test, etc.) with the name `tmp` as there is a name collision.  This PR attempts to address that by moving the `tmp` directory to the root of the target directory (`target/tmp`), and reserving the profile name "tmp".

Fixes #9783
2021-08-20 22:23:14 +00:00
Eric Huss cfcb0786dd Fix test incorrectly validating CARGO_PKG_LICENSE_FILE. 2021-08-20 12:16:25 -07:00
Eric Huss 4e7fe836d5 Move tmp test directory. 2021-08-20 12:12:42 -07:00
Aaron Hill 88679e07f2
Implement [future-incompat-report] config section
Currently, I've just implemented the `always` and `never` frequencies
from the RFC, which don't require tracking any additional state.
2021-08-19 15:59:36 -05:00
bors b64c96bfa0 Auto merge of #9793 - nipunn1313:install_parallel2, r=alexcrichton
Determine packages to install prior to installing

Old logic (pseudocode)
```
for krate in to_install {
    pkg = determine_pkg(krate);
    install_pkg(pkg);
}
```
New logic
```
let pkgs = to_install.into_iter(|krate| determine_pkg(krate));
pkgs.into_iter(|pkg| install_pkg(pkg));
```

This has the short term benefit of dumping most error messages out earlier in the process (eg a typo in the second package name).

Longer term, it might help with #9741 - as only the second loop would be parallelized. First loop shouldn't be parallelized because it would lead to redundant registry/git updates.
2021-08-19 19:13:11 +00:00
Nipunn Koorapati f9c2d04592 Factor into struct InstallablePackage 2021-08-19 09:57:53 -07:00
bors 259ea8c055 Auto merge of #9803 - ehuss:fix-edition-resolve-differences-dev-deps, r=alexcrichton
Show feature resolver differences for dev-dependencies.

During the crater run for 2021, there was a package that failed to update in a confusing way. The issue is that a feature was removed in the new resolver, but only for a dev-dependency. The report displayed with `cargo fix --edition` did not say anything about that, so it took me a bit to figure it out.  This changes it so that the report also includes changes to features of dev-dependencies.  I honestly don't remember my thought process behind the original code.

For example, the offending package now says:

```
When building the following dependencies, the given features will no longer be used:

  log v0.4.8 removed features: std
  syn v0.15.44 (as host dependency) removed features: extra-traits, visit

The following differences only apply when building with dev-dependencies:

  phf_shared v0.7.24 (as host dependency) removed features: unicase
```

And the error that happens after updating to 2021 is:

```
error[E0277]: the trait bound `UniCase<&str>: phf_shared::PhfHash` is not satisfied
  --> /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/mime_guess-1.8.7/build.rs:37:21
   |
37 |         forward_map.entry(UniCase(key), &format!("{:?}", val));
   |                     ^^^^^ the trait `phf_shared::PhfHash` is not implemented for `UniCase<&str>`
```

Hopefully developers will be able to see the note about the feature `unicase` being removed from `phf_shared`, and the error message about `UniCase` not implementing `PhfHash`, and connect the two together.  Previously, the upgrade report didn't mention anything about `phf_shared`, and thus no clues on what went wrong.
2021-08-18 14:09:06 +00:00
Eric Huss 5939e212e0 Show feature resolver differences for dev-dependencies. 2021-08-17 16:41:53 -07:00
Eric Huss 5f274b018f Show information about abnormal fix errors. 2021-08-17 08:49:47 -07:00
hi-rustin 7d4b5dfdb1 Make library created with cargo new clippy happy
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-08-17 19:44:10 +08:00
bors 531958b662 Auto merge of #9791 - nipunn1313:cargo_crash_alias_loop, r=alexcrichton
Teach cargo to failfast on recursive/corecursive aliases

Eg.
[alias]
test-1 = test-2
test-2 = test-3
test-3 = test-1

Previously it would stack overflow
Pulled out non controversial bits from from #9768
2021-08-16 15:01:11 +00:00
bors e8a78cc5a8 Auto merge of #9789 - ehuss:fix-value-after-table-profile, r=alexcrichton
Fix value-after-table error with profiles.

If the `strip`, `dir-name`, or `inherits` fields were included along with a profile override, then `cargo publish` would fail with a `ValueAfterTable` error because the fields were listed in the wrong order in the struct definition.

Fixes #9787
2021-08-16 14:09:42 +00:00
hi-rustin 0b543baaff Refine warnings and better code
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-08-16 10:04:18 +08:00
Nipunn Koorapati 28e1289eb1 Teach cargo to failfast on recursive/corecursive aliases
Eg.
[alias]
test-1 = test-2
test-2 = test-3
test-3 = test-1

Previously it would stack overflow

It pulls out non controversial bits from from #9768
2021-08-15 11:27:03 -07:00
Weihang Lo e5d6586cf8
Test for warning of migrating to unstable edition 2021-08-15 17:16:39 +08:00
Nipunn Koorapati 5a56cf2e5b Refactor echo cargo subcommand test helper into cargo-test-support 2021-08-14 22:37:54 -07:00
Eric Huss b34b76738a Fix plugin registrar change. 2021-08-14 15:31:06 -07:00
Eric Huss f0909c7a6c Fix value-after-table error with profiles. 2021-08-14 14:45:25 -07:00
Tejas Sanap 9e2790f828 Ability to specify the output name for a bin target different from the crate name 2021-08-11 10:36:16 -07:00
hi-rustin 61780a90d9 Separate warning and with root_id
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-08-10 22:49:00 +08:00