Commit graph

4322 commits

Author SHA1 Message Date
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
Nipunn Koorapati 0ab79d7aaf Deduplicate entries in cargo --list
Fixes #6088
2021-08-09 10:29:21 -07:00
Dustin J. Mitchell 1c5e68b4f3 Include aliases with other commands
The principal result is that they are now automatically included in the
`cargo --list` output.  Fixes #8486.
2021-08-07 13:52:12 +00:00
hi-rustin 27c103063c Use batch warnings and only warn about used dependency packages
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-08-07 14:10:14 +08:00
hi-rustin cc891a0bc5 Warning for no lib dependencies
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-08-07 11:51:59 +08:00
bors 33edacd1fd Auto merge of #9118 - bjorn3:profile_codegen_backend_option, r=joshtriplett
Add a profile option to select the codegen backend

This makes it possible to compile only specific crates with a certain codegen backend.

I have tested this by compiling Bevy with cg_llvm, but one of the examples using cg_clif.

By the way I noticed that many unstable profile options are not checked when using profile overrides.
2021-08-06 20:43:21 +00:00
Nipunn Koorapati dde290e6ff Refactor fake_file() away from cargo_command tests
There are already similar preexisting test helpers which
also work on windows. Port over the executable-creation
helper into the file() helper and things appear to pass.
2021-08-05 19:09:58 -07:00
bjorn3 1aa8fd5736 Fix test 2021-08-05 17:17:50 +02:00
bjorn3 88da2395bd Update test 2021-08-04 18:20:41 +02:00
Dirkjan Ochtman d783456598 Stabilize rust-version 2021-08-02 13:38:58 +02:00
Eric Huss 70a607eaa7 Remove nbsp characters. 2021-07-30 15:40:37 -07:00
Josh Triplett ab38ce0f44 Stabilize [env] sections
`[env]` sections seem to work as advertised.
2021-07-29 19:50:51 -07:00
bors cdf22d19c9 Auto merge of #9730 - hi-rustin:rustin-patch-doc-test, r=alexcrichton
doc test supports silent output

close https://github.com/rust-lang/cargo/issues/9728
2021-07-27 15:05:14 +00:00
hi-rustin 8ee5433c3a doc test supports silent output
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-27 15:49:59 +08:00
bors d21c22870e Auto merge of #9727 - ehuss:fix-version, r=alexcrichton
Fix version string.

The version string for `cargo version` was inadvertently changed in #9657 so that it does not include the leading `cargo` as in `cargo 1.53.0 (4369396ce 2021-04-27)`.
2021-07-26 20:23:21 +00:00
bors 9bc7a37533 Auto merge of #9559 - tcmal:master, r=ehuss
Allow publishing from workspace root.

Adds -p, --workspace, and --exclude to package and publish commands.

Uses ephemeral workspaces to avoid changing the existing functions too much.
There might be more `Finished dev [unoptimized + debuginfo] target` messages when packaging than there should be, I couldn't figure out what was generating them.
The tests aren't super extensive, as all the specs from arguments code should already be tested elsewhere.

Closes #7345
2021-07-26 19:58:01 +00:00
Eric Huss 30ff8424c9 Remove unnecessary format! 2021-07-26 12:56:53 -07:00
bors d403db6f17 Auto merge of #9723 - hi-rustin:rustin-patch-better-msg, r=ehuss
Better msg for wrong position

close https://github.com/rust-lang/cargo/issues/9717
2021-07-26 19:24:32 +00:00
Eric Huss fdc398e743 Fix version string. 2021-07-26 12:18:22 -07:00
bors 97007c99a5 Auto merge of #9557 - danielframpton:extra-link-args, r=ehuss
Stabilize the rustc-link-arg option

This change removes the unstable option (tracked by #9426) and unconditionally accepts additional linker arguments (as implemented in #7811 and #8441). Documentation is moved from unstable to what appeared to be the correct location.

I am not aware of any significant concerns with the option and it appears consistent with some other existing stable linker options.

Please let me know if this is not the appropriate process or if there is anything that I am missing from the PR.
2021-07-26 18:54:29 +00:00
tcmal 8f1f0e40fd feat(package+publish): package arguments
adds -p, --workspace, and --exclude to package command,
and -p to publish command, as well as tests for both.

closes #7345
2021-07-26 16:31:58 +01:00
hi-rustin 5ccb5a3f92 Refine name
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-25 00:35:09 +08:00
hi-rustin 10cfa40669 Better msg for wrong position
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-24 10:44:44 +08:00
bors 9535dc3dfd Auto merge of #9681 - hi-rustin:rustin-patch-reject, r=ehuss
Warning when using features in replace

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

r? `@ehuss`
2021-07-23 18:53:25 +00:00
hi-rustin 771356d821 Warning when using features in replace
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-23 15:00:50 +08:00
Daniel Frampton e73703944e Stabilize the extra link arg option 2021-07-22 09:57:00 -07:00
bors 121f4b3b5c Auto merge of #9653 - bjorn3:update_should_use_metadata, r=alexcrichton
Update should_use_metadata function

* Correct the reason for not renaming dylibs
* Add todo for -install-name/-soname usage
* Limit wasm32 executable metadata omission to emscripten. Wasm file don't contain any filename themself.
* Don't omit metadata for executables on macOS. backtrace-rs is now able to load debuginfo for renamed .dSYM files: ed3689c2f2/src/symbolize/gimli/macho.rs (L51-L65)
* Mention another reason to include the metadata hash for libstd.
2021-07-22 14:16:04 +00:00
Weihang Lo 8c75e2ffa0
Update tests to use registry names 2021-07-22 00:50:30 +08:00
bors 4e143fd131 Auto merge of #9685 - ehuss:named-profile-updates, r=alexcrichton
Named profile updates

A few updates for named profiles to push them closer to stabilization:

- Disable the `dir-name` profile setting. `dir-name` primarily exists for translating the built-in profiles or sharing artifacts between profiles. In order to simplify the UI, we would like to not expose it to the user for the initial stabilization. The code to support it is kept in case we want to add it in the future.
- Reserve some profile names. Just to give a little flexibility in the future in case we want to use these, or that they could cause confusion. Also updated the error text a little.
- Add support for custom profiles to legacy commands. Their old behavior is still retained for backwards compatibility. That is:
    * `cargo check`
        * `--profile=test`: This forces the test mode. For example, `cargo check --lib --profile=test` will check the library as a unit test (with `--test`).
    * `cargo fix`
        * `--profile=test`: Forces test mode, same as above.
    * `cargo rustc`
        * `--profile=test`: Forces test mode, same as above.
        * `--profile=bench`: Forces bench mode.
        * `--profile=check`: Forces check mode.
    - These commands also allow mixing the above options with `--release`, which is normally not allowed.
- Fix `cargo bench` to support the `--profile` option. I think it was just forgotten.
2021-07-20 21:55:45 +00:00
bors adde602238 Auto merge of #9601 - jonhoo:fix-9600, r=ehuss
Inform build scripts of rustc compiler context

Fixes #9600.
2021-07-20 21:27:35 +00:00
bors 54bc19ee56 Auto merge of #9675 - ehuss:diagnostic-dedupe, r=alexcrichton
Deduplicate compiler diagnostics.

This adds some logic to deduplicate diagnostics emitted across rustc invocations. There are some situations where different targets can emit the same message, and that has caused confusion particularly for new users. A prominent example is running `cargo test` which will build the library twice concurrently (once as a normal library, and once as a test).

As part of this, the "N warnings emitted" message sent by rustc is intercepted, and instead cargo generates its own summary. This is to prevent potentially confusing situations where that message is either deduplicated, or wrong. It also provides a little more context to explain exactly *what* issued the warnings.  Example:

```warning: `foo` (lib) generated 1 warning```

This only impacts human-readable output, it does not change JSON behavior.

Closes #9104
2021-07-16 15:22:58 +00:00
Eric Huss f00a85a871 Re-enable future-incompatible tests. 2021-07-16 05:45:29 -07:00
Jon Gjengset 1cbce47051 Remove RUSTC_VERSION envvar 2021-07-15 17:53:21 -07:00
Eric Huss 13fef863ab Add test demonstrating deduplication of errors. 2021-07-15 17:37:21 -07:00
bors ae51ab9203 Auto merge of #9694 - ehuss:edition-fix-latest, r=alexcrichton
`cargo fix --edition`: extend warning when on latest edition

This extends the warning issued when `cargo fix --edition` is run when the user is already on the latest edition.  Before #9184, there were instructions on what to do, but those probably should not have been completely removed.  It seems likely that some users may get the steps out of order, so this hopefully tries to explain them clearly.
2021-07-15 17:54:25 +00:00
Eric Huss be0cbb57c7 cargo fix --edition: extend warning when on latest edition 2021-07-15 07:26:26 -07:00
hi-rustin 6f214ac752 Make ignored key in config be an error
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-15 14:35:10 +08:00
hi-rustin 85ba14c68d Make the dependency specification ambiguous be an error
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-15 14:29:11 +08:00
bors 66a6737a0c Auto merge of #9663 - nebkor:master, r=alexcrichton
Add format option to `cargo tree` to print the lib_name

Adds a way to have `cargo tree` display the name of the library inside a package dependency, which can differ from the name of the package. Updates the `tree::format` test to test for its proper behavior.

Closes #9659
2021-07-14 20:54:28 +00:00
bors f8ba1cbfcb Auto merge of #9639 - djmitche:issue9535, r=Eh2406
Prefer patched versions of dependencies

When selecting among several versions of a paackage, prefer versions
from `[patch]` sections over other versions, similar to how locked
versions are preferred.

Patches come in the form of a Dependency and not a PackageId, so this
preference is expressed with `prefer_patch_deps`, distinct from
`try_to_use`.

Fixes #9535
2021-07-14 19:14:22 +00:00
bors 98d5d10268 Auto merge of #9686 - hi-rustin:rustin-patch-error, r=alexcrichton
When a dependency does not have a version, git or path, fails directly

Make this warning be an error.

ref: https://github.com/rust-lang/cargo/issues/9682#issuecomment-879108193
2021-07-14 16:09:57 +00:00
bors 3658906b07 Auto merge of #9665 - gilescope:giles-better-message, r=alexcrichton
Spot the crate typo easily

ego tweak to make it easy to spot typos:

Before:
```
error: no matching package named `sc-consensus-primitivies` found
location searched: /Users/bit/p/substrate1/client/primitives/consensus/common
perhaps you meant: sc-consensus-primitives
required by package `sc-network v0.9.0 (/Users/bit/p/substrate1/client/network)`
```
After:
```
error: no matching package named `sc-consensus-primitivies` found
perhaps you meant:                sc-consensus-primitives
location searched: /Users/bit/p/substrate1/client/primitives/consensus/common
required by package `sc-network v0.9.0 (/Users/bit/p/substrate1/client/network)`
```
2021-07-14 15:39:04 +00:00
gilescope e94199cb06
Only put it on a new line if there's candidates to compare against. 2021-07-14 08:27:52 +01:00
hi-rustin 5c66070803 When a dependency does not have a version, git or path, fails directly
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-14 14:09:45 +08:00
Eric Huss 73dba767d1 Support custom profiles in legacy commands.
This makes the following changes:

- Allows `cargo check`, `cargo fix`, and `cargo rustc` to support custom
  named profiles. This retains the legacy behavior of those commands.
- Fixes `cargo bench` so that it supports custom named profiles.
2021-07-13 15:22:09 -07:00
Eric Huss 51dc5db4e2 Reserve some names for named profiles.
Just to give a little flexibility in the future in case we want to use
these, or that they could cause confusion. Also updated the error text a
little.
2021-07-13 11:59:15 -07:00
Eric Huss 090eb4277f Disable the dir-name profile setting.
dir-name primarily exists for translating the built-in profiles. In
order to simplify the UI, we would like to not expose it to the user for
the initial stabilization. The code to support it is kept in case we
want to add it in the future.
2021-07-13 11:38:11 -07:00
Joe Ardent af355f0ea5 Use crate_name() on the library target, update tests. 2021-07-12 13:25:49 -07:00
Jon Gjengset d0c751bc8f Test when RUSTC_WORKSPACE_WRAPPER is not set 2021-07-12 09:34:39 -07:00
bors f2496ee6ee Auto merge of #9677 - ehuss:serialize-fix, r=alexcrichton
Serialize `cargo fix`

This changes `cargo fix` so that it only fixes one crate at a time. Previously, it would allow concurrent fixing across packages. This caused a problem if a workspace uses things like `#[path]` or `include!()` of a shared file between packages. A real-world example of this is serde, which has [this](9c39115f82/serde_derive_internals/lib.rs (L43-L45)) which reuses the some source files between the `serde` and `serde_derive` packages. Modifying those files concurrently causes corruption and the fix will fail.

Closes #6528
2021-07-12 16:16:36 +00:00
bors 01ddc251e5 Auto merge of #9657 - ehuss:clearer-nightly-requirements, r=alexcrichton
Update nightly failure notification.

This makes several changes to try to clarify errors with nightly requirements.

- Don't tell the user to edit `Cargo.toml` if it is not a local package. Things like registry packages are not under their control.
- Include the version number in the error message.
- Try to make better suggestions on what to do.
- Remove the redirects for stabilized features in unstable.md, and instead include a small stub that tells the user when it was stabilized and where to find more information. This should help with people using older releases which provide links to this page, to help them know which version they will need.

Closes #9610
2021-07-12 14:55:37 +00:00
bors 2517af47e1 Auto merge of #9654 - ehuss:windows-env-upper-check, r=alexcrichton
Update Windows env uppercase key check.

This is the followup for #9646. Rust now correctly spawns processes with preserved casing on nightly on Windows, so the exceptions here are no longer needed.
2021-07-12 14:26:23 +00:00
bors a51667c60d Auto merge of #9662 - ehuss:unignore-fix_edition_2021, r=alexcrichton
Unignore fix_edition_2021.

The issue has been fixed by https://github.com/rust-lang/rust/pull/86572.
2021-07-12 13:39:49 +00:00
hi-rustin add4ffc200 Reject when using features in replace
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-12 14:56:24 +08:00
Eric Huss c8e4f8e483 Serialize cargo fix 2021-07-10 18:47:52 -07:00
gilescope dc0e53b7c1
Reworking message to not care about an intial offset 2021-07-10 15:07:29 +01:00
Eric Huss 493e8b7dd1 Deduplicate compiler diagnostics. 2021-07-09 16:20:46 -07:00
Dustin J. Mitchell bd4a353e98 Prefer patched versions of dependencies
When selecting among several versions of a paackage, prefer versions
from `[patch]` sections over other versions, similar to how locked
versions are preferred.

Patches come in the form of a Dependency and not a PackageId, so this
preference is expressed with `prefer_patch_deps`, distinct from
`try_to_use`.
2021-07-09 18:23:21 +00:00
hi-rustin a846226f71 Remove unrelated cases
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-09 13:15:13 +08:00
Joe Ardent bc472c762b Change format character to 'lib'. 2021-07-08 15:59:07 -07:00
hi-rustin 8d2103f212 Warning when using features in patch
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-08 15:25:13 +08:00
Joe Ardent 6fb5a1de54 Add test for lib_name format character. 2021-07-07 00:05:08 -07:00
Eric Huss 93658ee1be Unignore fix_edition_2021. 2021-07-06 19:28:13 -07:00
Joshua Nelson 9c7cc545d7 Combine rustc and cargo's diagnostic summaries
This works by introspecting rustc's error output, using the JSON format
to determine whether it's a warning or error, then skipping it
altogether if it's a summary of the diagnostics printed.

Before:

```
src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated
src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong`
src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object
error: aborting due to 2 previous errors; 1 warning emitted
error: could not compile `wrong`

```

After:

```
$ cargo check --message-format short
src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated
src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong`
src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object
error: could not compile `wrong` due to 2 previous errors; 1 warning emitted
```
2021-07-06 19:46:27 -04:00
Jon Gjengset d6b4a06274 Also set RUSTC_WORKSPACE_WRAPPER for build.rs 2021-07-06 09:46:02 -07:00
Eric Huss 2c99f654c9 Update nightly failure notification. 2021-07-05 16:08:36 -07:00
Eric Huss 652c5d9d1f Update Windows env uppercase key check. 2021-07-05 10:10:51 -07:00
bjorn3 8c24820a3d Update test 2021-07-05 18:28:21 +02:00
Eric Huss 5559e028a8 Adjust the edition2021 resolver diff report. 2021-07-02 13:01:58 -07:00
bors 0a38a2138d Auto merge of #9647 - ehuss:fingerprint-linker, r=alexcrichton
Include the linker in the fingerprint.

This adds the linker from the `[target]` config table to the fingerprint. Previously, changing the value would not trigger a rebuild.
2021-07-02 15:10:51 +00:00
bors 6e31c1338d Auto merge of #9646 - ehuss:windows-case-disable, r=alexcrichton
Temporarily disable windows env test.

This temporarily disables the `target_in_environment_contains_lower_case` test on Windows until https://github.com/rust-lang/rust/pull/85270 gets into nightly.  That PR changes it so that env vars are case-preserved on Windows.  My intent is that after that is in nightly, we can remove the windows-specific code in `Config`, and this test should work the same on all platforms.

Closes #9630
2021-07-02 14:47:02 +00:00
bors b74705419e Auto merge of #9645 - ehuss:git-package-wt_deleted, r=alexcrichton
Handle git deleted files with dirty worktree.

When listing git files for things like `cargo package`, it was including unstaged deleted files. This is because the file is still in the index, so it was included in the list.  `cargo package --allow-dirty` would then fail with a confusing "file not found" error.

This fixes it by keeping a set of deleted files, and skipping those. This allows `cargo package --allow-dirty` to work.

Closes #9580
2021-07-02 14:22:23 +00:00
Eric Huss 28c3bef71a Include the linker in the fingerprint. 2021-07-01 20:33:48 -07:00
Eric Huss c10864a3c4 Temporarily disable windows env test. 2021-07-01 19:41:13 -07:00
Eric Huss 97a135049a Handle git deleted files with dirty worktree. 2021-07-01 18:10:35 -07:00
Eric Huss dd8fa9183d Adjust error message with offline and frozen. 2021-07-01 16:59:19 -07:00
bors 4952979031 Auto merge of #9531 - 5225225:cargo-doc-open-fix, r=ehuss
Fix `BorrowMutError` when calling `cargo doc --open`

~~I'm not sure why the existing test suite didn't catch this, it definitely calls `cargo doc --open`.~~

I had

```toml
[doc.extern-map]
std = "local"
```

in my `.cargo/config.toml`. Will write a test case that sets that and then tries to run `cargo doc --open`.

Closes #9530
2021-07-01 01:14:50 +00:00
Eric Huss aab51362d7 Temporarily ignore 2021 edition fix. 2021-06-30 09:36:22 -07:00
Jon Gjengset fa7c5b196f Use a more standard linker flag 2021-06-29 12:26:50 -07:00
Jon Gjengset fb0d41fcc5 Adopt CARGO_ENCODED_RUSTFLAGS 2021-06-29 12:08:50 -07:00
Eric Huss e7df0d136c Temporarily disable future_incompat tests. 2021-06-29 11:56:03 -07:00
5225225 950c415583 Fully match stderr, return if not nightly, shorten file 2021-06-28 19:01:16 +01:00
Jon Gjengset c16b9d4c55 Remove CARGO_VERSION* env vars
Cargo and Rustc are co-versioned at the moment anyway.
2021-06-25 11:01:23 -07:00
Jon Gjengset 49d33c4ec4 Expose cargo and rustc version envvars 2021-06-24 09:56:14 -07:00
Jon Gjengset 1e407453c2 Remove CARGO_ prefix for new build script envvars 2021-06-24 09:56:00 -07:00
bors 4c27c96645 Auto merge of #9612 - Bryysen:master, r=alexcrichton
Error when packaging with git dependencies without version

If `cargo package` is run on a package that specifies a git dependency
without a version, cargo will error. This should help with clarifying
that git dependencies will be stripped when packaging, and that the
dependency has to be fetched from a registry.
Closes #9442
2021-06-23 21:38:32 +00:00
Daniel Eades 706c8242e3 use 'writeln' instead of appending newline character 2021-06-23 12:20:18 +01:00
Bryysen 4e1910d9d3 Error when packaging with git dependencies without version
If `cargo package` is run on a package that specifies a git dependency
without a version, cargo will error. This should help with clarifying
that git dependencies will be stripped when packaging, and that the
dependency has to be fetched from a registry.
2021-06-23 02:01:29 +02:00
bors 9233aa06c8 Auto merge of #9607 - hi-rustin:rustin-patch-cargo-toml, r=ehuss
Detect incorrectly named cargo.toml

close https://github.com/rust-lang/cargo/issues/9541
2021-06-22 21:32:55 +00:00
bors a2589dda38 Auto merge of #9574 - ehuss:weak-namespaced, r=alexcrichton
Unify weak and namespaced features.

This unifies weak and namespaced features in order to simplify the syntax and semantics.  Previously there were four different ways to specify the feature of a dependency:

* `package-name/feature-name` — Enables feature `package-name` on self and enables `feature-name` on the dependency. (Today's behavior.)
* `package-name?/feature-name` — Only enables `feature-name` on the given package if it that package is enabled and will also activates a feature named `package-name` (which must be defined implicitly or explicitly).
* `dep:package-name/feature-name` — Enables dependency `package-name`, and enables `feature-name` on that dependency. This does NOT enable a feature named "package-name".
* `dep:package-name?/feature-name` — Only enables `feature-name` on the given package if it that package is enabled.  This does NOT enable a feature named "package-name".

This changes it so there are only two:

* `package-name/feature-name` — Today's behavior.
* `package-name?/feature-name` — Only enables `feature-name` on the given package if it that package is enabled.  This does NOT enable a feature named "package-name" (the same behavior as `dep:package-name?/feature-name` above).

This is a fairly subtle change, and in most cases probably won't be noticed.  However, it simplifies things which helps with writing documentation and explaining how it works.
2021-06-22 21:02:31 +00:00
bors 32238b4747 Auto merge of #9563 - ehuss:link-cdylib-warning, r=alexcrichton
Change `rustc-cdylib-link-arg` error to a warning.

In #9523, an error was added if `cargo:rustc-cdylib-link-arg` was issued in a build script without actually having a cdylib target. This uncovered that there was an unintentional change in #8441 to cause those link args to be applied to transitive dependencies.

This changes it so that the error is now a warning, with a note that this may become an error in the future. It also changes it so that the unstable `rustc-link-arg*` instructions only apply to the package that emitted them.
2021-06-22 19:27:25 +00:00
hi-rustin b3a1d0ceba Only testing on linux 2021-06-22 15:36:32 +08:00
hi-rustin cb1a3f05f0 Detect incorrectly named cargo.toml for build 2021-06-22 15:31:28 +08:00
hi-rustin a2f903275a Detect incorrectly named cargo.toml for install --path 2021-06-22 15:31:28 +08:00
hi-rustin d9daaf7a84 Detect incorrectly named cargo.toml for install --git 2021-06-22 15:31:21 +08:00
Eric Huss afe7314ede Don't trigger an update when looking for suggestions. 2021-06-21 09:55:29 -07:00
Eric Huss a93bfcbdff Print reports using shell to handle old Windows colors properly. 2021-06-21 09:50:42 -07:00
Eric Huss 71cb59b6ef Future-incompat report: Add suggestions of newer versions. 2021-06-21 09:49:43 -07:00
Eric Huss 1f7141f892 Add future-incompat as an alias for future-incompatibilities. 2021-06-21 09:49:43 -07:00
Eric Huss c2b02b3926 Updates to future-incompatible reporting. 2021-06-21 09:49:41 -07:00
bors 9548b78ac9 Auto merge of #9579 - wickerwaka:env-config-override, r=ehuss
Don't allow config env to modify vars set by cargo

This changes how the `[env]` variables are applied. They will no longer replace any variables that are being set by cargo itself, whether or not the `force` flag is set. The `force` flag still determines whether existing variables from the environment can be overridden or not.

Addresses unresolved issue in #9539
2021-06-21 15:09:41 +00:00