Commit graph

2778 commits

Author SHA1 Message Date
bors b1636fc1e0 Auto merge of #10497 - Muscraft:rfc2906-part1, r=epage
Part 1 of RFC2906 - Packages can inherit fields from their root workspace

Tracking issue: #8415
RFC: rust-lang/rfcs#2906

All changes were heavily inspired by #8664 and #9684

A big thanks to both `@yaymukund` and `@ParkMyCar.` I pulled a lot of inspiration from their branches.

I would also like to thank `@alexcrichton` for all the feedback on the first attempt. It has brought this into a much better state.

All changes have been made according to the RFC as well as `@alexcrichton's` [comment](https://github.com/rust-lang/cargo/pull/8664#issuecomment-704878103).

This is part 1 of many, as described by [this comment](https://github.com/rust-lang/cargo/pull/9684#issuecomment-943567692), [this comment](https://github.com/rust-lang/cargo/pull/9684#pullrequestreview-779070283) and redefined  [by this one](https://github.com/rust-lang/cargo/pull/10497#issuecomment-1076301312).

This PR focuses on inheriting in root package, including:
- Add `MaybeWorkspace<T>` to allow for `{ workspace = true }`
- Add a new variant to `TomlDependency` to allow inheriting dependencies from a workspace
- Add `InheritableFields` so that we have somewhere to get a value from when we `resolve` a `MaybeWorkspace<T>`
  - `license_file` and `readme` are in `InheritableFields` in this part but are not `MaybeWorkspace` for reasons [described here](https://github.com/rust-lang/cargo/pull/10497#issuecomment-1076470424)
- Add a method to `resolve` a `MaybeWorkspace<T>` into a `T` that can fail if we have nowhere to pull from or the workspace does not define that field
- Disallow inheriting from a different `Cargo.toml`
  - This means that you can only inherit from inside the same `Cargo.toml`, i.e. it has both a `[workspace]` and a `[package]`
  - Forcing this requirement allows us to test the implementations of `MaybeWorkspace<T>` and the new `TomlDependency` variant without having to add searching for a workspace root and the complexity with it

Remaining implementation work for the RFC
- Support inheriting in any workspace member
- Correctly inherit fields that are relative paths
  - Including adding support for inheriting `license_file`,  `readme`, and path-dependencies
-  Path dependencies infer version directive
- Lock workspace dependencies and warn when unused
- Optimizations, as needed
- Evaluate any new fields for being inheritable (e.g. `rust-version`)
- Evaluate making users of `{ workspace = true }` define the workspace they pull from in `[package]`

Areas of concern:
- `TomlDependency` Deserialization is a mess, and I could not figure out how to do it in a cleaner way without significant headaches. I ended up having to do the same thing as last time [which was an issue](https://github.com/rust-lang/cargo/pull/9684#discussion_r728444103).
- Resolving on a `MaybeWorkspace` feels extremely verbose currently:
  ```rust
  project.homepage.clone().map(|mw| mw.resolve(&features, "homepage", || get_ws(inheritable)?.homepage())).transpose()?,
  ```
  This way allows for lazy resolution of inheritable fields and finding a workspace (in part 2) so you do not pay a penalty for not using this feature. The other bit of good news is `&features` will go away as it is just feature checking currently.

- This feature requires some level of duplication of code as well as remaking the original `TomlManifest` which adds extra length to the changes.
- This feature also takes a linear process and makes it potentially non-linear which adds lots of complexity (which will get worse in Part 2)

Please let me know if you have any feedback or suggestions!
2022-03-25 08:19:16 +00:00
bors 13662250ab Auto merge of #10470 - arlosi:http, r=Eh2406
HTTP registry implementation

Implement HTTP registry support described in [RFC 2789](https://github.com/rust-lang/rfcs/pull/2789).

Adds a new unstable flag `-Z http-registry` which allows cargo to interact with remote registries served over http rather than git. These registries can be identified by urls starting with `sparse+http://` or `sparse+https://`.

When fetching index metadata over http, cargo only downloads the metadata for needed crates, which can save significant time and bandwidth over git.

The format of the http index is identical to a checkout of a git-based index.

This change is based on `@jonhoo's` PR #8890.

cc `@Eh2406`

Remaining items:
- [x] Performance measurements
- [x] Make unstable only
- [x] Investigate unification of download system. Probably best done in separate change.
- [x] Unify registry tests (code duplication in `http_registry.rs`)
- [x] Use existing on-disk cache, rather than adding a new one.
2022-03-24 22:28:19 +00:00
scott e6992d4310 -- renamed deduplicate_workspace to inheritable_workspace_fields
-- removed `[]` from error messages in favor of back-ticks
2022-03-23 16:47:06 -05:00
scott c4cd152c36 -- updated both resolve to only take a get_ws
-- `resolve` not takes `get_ws: impl FnOnce() -> CargoResult<T>`
-- removed `MaybeWorkspace` from `readme` and `license-file`
-- changed error messages and test names
2022-03-23 13:40:16 -05:00
Jon Gjengset 79cc65fa5a Add tests for ignoring symlinks 2022-03-22 16:21:39 -07:00
scott ccb321a633 -- Part 1 of RFC2906 2022-03-21 21:27:49 -05:00
David Tolnay 4e45f58852
Unstable --keep-going flag 2022-03-21 18:36:40 -07:00
bors 5e09899f33 Auto merge of #10394 - dtolnay-contrib:displayerror, r=ehuss
Consistently use crate::display_error on errors during drain

As suggested in https://github.com/rust-lang/cargo/pull/10383#discussion_r808178038 and https://github.com/rust-lang/cargo/pull/10383#discussion_r808182199.
2022-03-21 18:48:36 +00:00
Arlo Siemsen 412b633914 HTTP registry implementation 2022-03-20 18:02:09 -07:00
Loïc BRANSTETT 02cd9442c7 Add support for rustc --check-cfg well known names and values 2022-03-18 22:14:39 +01:00
David Tolnay 809bcfe91d
Print only Message::Finish errors all the time 2022-03-16 00:18:52 -07:00
bors 2ac382d8e2 Auto merge of #10433 - Byron:fix-#10431, r=ehuss
Fix panic when artifact target is used for `[target.'cfg(<target>)'.dependencies`

With an artifact dependency like this in package `a`…

```toml
[dependencies.a]
path = "b"
artifact = "bin"
target = "$TARGET"
```

…and when using `$TARGET` like this in another package `b`…

```toml
[target.'cfg(target_arch = "$ARCHOF_$TARGET")'.dependencies]
c = { path = "../c" }
```

…it panics with `thread 'main' panicked at 'activated_features for invalid package: features did not find PackageId <dbg-info>`, but we would expect this to work normally.

### Tasks

- [x] reproduce issue in new test
   - [x] figure out why the test is fixed but the real-world example isn't
- [x] find a fix

Fixes #10431 and  #10452.
2022-03-16 02:40:40 +00:00
Sebastian Thiel 0b53b1b6d4
Undo a prior change to fix #10452 2022-03-14 11:01:28 +08:00
Sebastian Thiel 92cce52182
reproduce: wrong features in a build script for a shared dependency (#10452) 2022-03-14 10:55:30 +08:00
Sebastian Thiel 4e847a2c11
Remove prior hack and replace it with a proper solution
This is the diff from
https://github.com/rust-lang/cargo/pull/10433#issuecomment-1064577586
applied to the codebase with the previous hack removed.

Thanks a million to @ehuss who has the insight to find fixes like this.
2022-03-14 10:24:55 +08:00
bors b816d82ee9 Auto merge of #10448 - aeikum:fix_vendor_sync, r=weihanglo
vendor: Don't allow multiple values for --sync

The --sync argument to cargo vendor currently takes a list, which makes it easy for it to eat the final path argument:

````
cargo vendor --manifest-path foo/Cargo.toml -s bar/Cargo.toml ./test_vendor/
error: failed to read ./test_vendor/

Caused by:
  No such file or directory (os error 2)
````

Per discussion on #10441, this behavior is undesirable and hopefully used infrequently enough that we can change the UI for it. This patch will now only allow one value per --sync argument.

I didn't regenerate other doc files as it's not clear to me how/when that should be done.
2022-03-12 00:24:43 +00:00
Weihang Lo 20d96f3d94
Tests for setting multitarget in config 2022-03-12 01:53:59 +08:00
Andrew Eikum d41f5ccd7e vendor: Don't allow multiple values for --sync 2022-03-11 10:41:12 -06:00
bors 56ccd1f1c7 Auto merge of #10316 - hi-rustin:rustin-patch-proc_macro, r=weihanglo
Warning on conflicting keys

Signed-off-by: hi-rustin <rustin.liu@gmail.com>

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/10299 and close https://github.com/rust-lang/cargo/issues/10317

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

- Warning on conflicting proc_macro and crate_types keys.
- Warning on conflicting dev-dependencies, build-dependencies, and default-features keys.
2022-03-10 00:41:25 +00:00
bors a77ed9ba87 Auto merge of #10064 - arlosi:poll, r=Eh2406
Registry functions return Poll to enable parallel fetching of index data

Adds `Poll` as a return type for several registry functions to enable parallel fetching of crate metadata with a future http-based registry.

Work is scheduled by calling the `query` and related functions, then waited on with `block_until_ready`.

This PR is based on the draft PR started by eh2406 here [#8985](https://github.com/rust-lang/cargo/pull/8985).

r? `@Eh2406`
cc `@alexcrichton`
cc `@jonhoo`
2022-03-09 19:30:19 +00:00
hi-rustin 8b895cc80b Use warn_on_deprecated
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-10 00:08:28 +08:00
hi-rustin b295e2fd67 Warning on conflicting dev_dependencies keys of platform
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-09 23:16:38 +08:00
hi-rustin ad375afa7a Warning on conflicting build_dependencies keys of platform
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-09 23:16:38 +08:00
hi-rustin 460ea25377 Warning on conflicting default_features keys
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-09 23:16:38 +08:00
hi-rustin ed93c94bd1 Warning on conflicting build_dependencies keys
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-09 23:16:38 +08:00
hi-rustin 154f372b6b Warning on conflicting dev-dependencies keys
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-09 23:16:38 +08:00
hi-rustin a317aff9b8 Warning on conflicting crate_types keys
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-09 23:16:38 +08:00
hi-rustin 375ccd2f4a Warning on conflicting proc_macro
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-09 23:16:38 +08:00
Lucas Kent fab44ff971 Remove warn(clippy::*) 2022-03-09 10:33:39 +11:00
hi-rustin 58906aac9d Don't treat host/target duplicates as duplicates
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-03-09 00:51:51 +08:00
Jacob Finkelman 88f3bb9a67 add a test for login on stdin 2022-03-04 23:05:48 +00:00
Jacob Finkelman 4164c46a1b add a test 2022-03-03 18:49:52 +00:00
Sebastian Thiel 0bede7331f
A cry for help with a fix for the issue that looks like a hack.
In order not to give up and create a basis for discussion while ending
my 3h oddisey on finding a fix for today, I present something that
seems to work even though I hope there are better ways to solve this.
2022-03-01 15:18:14 +08:00
Sebastian Thiel 9ede09a1c8
trigger another failure by using [target.'cfg(…)'.dependencies] syntax 2022-03-01 11:09:49 +08:00
Sebastian Thiel 9199453548
A fix for the previous simplified reproduction 2022-03-01 11:04:41 +08:00
Sebastian Thiel 441b031a6d
further simplify the reproduction code
This is a hacky way of making changes while leaving everything else,
despite it being deactivated for now, in the hopes to not forget
to put additional difficulties back in once this particular issue
is fixed.
2022-03-01 10:20:31 +08:00
Sebastian Thiel 8c8f606e3e
reproduce issue; this time with build dependencies
They differ as these will be built for the host, so
`FeaturesFor` will not set a target specifically.
2022-03-01 09:39:39 +08:00
Arlo Siemsen f12f0256ca Remove the update method on registry functions. Instead of explicitly
updating, registries now update as needed. To force a registry to
ensure the latest copy of crate metadata is available, a new method
called `invalidate_cache` is added. This method will cause the registry
to update the next time `block_until_ready` is called.
2022-02-28 14:36:08 -06:00
bors 489b66f2e4 Auto merge of #10434 - weihanglo:stop-gating-stable-features, r=alexcrichton
Stop gating stable features
2022-02-28 20:17:13 +00:00
bors 3d6970d50e Auto merge of #10395 - jonhoo:fix-10206, r=alexcrichton
Enable propagating host rustflags to build scripts

### What does this PR try to resolve?

This PR primarily fixes #10206, but in doing so it also slightly modifies the interface for the unstable `target-applies-to-host` feature (#9453), and adds the unstable `target-applies-to-host-kind` flag to mirror `target-applies-to-host` for build scripts and other host artifacts.

The commit messages have more in-depth discussion.

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

The test case from #10206 now works rather than producing an error. It has also been added a regression test case. A few additional test cases have also been added to handle the expected behavior around rustflags for build scripts with and without `target-applies-to-host-kind` enabled.

### Additional information

1. This changes the interface for `target-applies-to-host` so that it does not need to be specified twice to be used. And it can still be set through configuration files using the `[unstable]` table. However, we may(?) want to pick a stable format for in-file configuration of this setting unless we intend for it to only ever be a command-line flag.
2. It may be that `target-applies-to-host-kind` is never behavior we want users to turn on, and that it should therefore simply be removed and hard-coded as being `false`.
3. It's not entirely clear how `target-applies-to-host-kind` should interact with `-Zmultitarget`. If, for example, `requested_kinds = [HostTarget, SomeOtherTarget]` and `kind.is_host()`, should `RUSTFLAGS` take effect or not? For the time being I've just hard-coded the behavior for single targets, and the answer would be "no".
2022-02-28 19:29:07 +00:00
bors 9d754ed085 Auto merge of #10425 - epage:search, r=alexcrichton
feat(search): Highlight search term

This supersedes #10116.  For the requested colored-output tests, this followed the pattern of the `fix` tests which just detects whether colored output is used or not.  The `cache_messages` actually verify the output is colored but that is because it can just compare to a rustc call's output.  Getting the colored output correct by hand in a test (with all of the resets) is a bit messy and would be brittle.

This was done in an exercise in exploring ways to generalize colored output support in preparation for `cargo-add` doing some colored output as well.

I converted all output calls to use this approach, even if coloring wasn't used, for consistency.  I considered coloring the overflow message but decided to hold off on that for now (either a warning-yellow or a hint-gray).

Fixes #9918
2022-02-28 17:15:55 +00:00
Weihang Lo 555209ce06
Stop gating feature "named-profiles" 2022-02-28 23:23:26 +08:00
Sebastian Thiel 1190f5fea2
Look at FeaturesFor:: to decide if a dependency participates in feature resolution
Fixes #10431.
2022-02-28 11:30:19 +08:00
Sebastian Thiel ac6427f755
reproduce #10431 2022-02-28 11:17:09 +08:00
bors f75d4eae77 Auto merge of #10428 - Urgau:check-cfg-features-rustdoc, r=ehuss
Add -Z check-cfg-features support for rustdoc

This PR is a follow to https://github.com/rust-lang/cargo/pull/10408 where support for compile-time checking of features was implemented for `rustc`.

At the time `rustdoc` support wasn't yet merged, but now that it has been [merged](https://github.com/rust-lang/rust/pull/94154), this pull-request add support for it in the `doc` and `test --doc` (doctest) mode.

r? `@alexcrichton`
2022-02-27 19:20:56 +00:00
bors 1e554909eb Auto merge of #10388 - weihanglo:issue-10356, r=ehuss
Override target crate-type for `cargo rustc --crate-type`
2022-02-27 18:33:14 +00:00
bors 188298f08f Auto merge of #10167 - hi-rustin:rustin-patch-test, r=ehuss
Use 1.51.0 in old cargos test

Remove TODO.
If the default toolchain is the same as "stable", just skip the `avoids_split_debuginfo_collision` test.
2022-02-27 17:48:39 +00:00
Josh Stone ec1bdd20a2 Fix term.verbose without quiet, and vice versa
The match pattern only looked for `Some(false)`, missing `None`.
2022-02-26 14:17:00 -08:00
Loïc BRANSTETT e828e85ee7 Add -Z check-cfg-features support for rustdoc 2022-02-26 14:10:17 +01:00
hi-rustin 9d93415d8c Check 1.60 behavior
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-02-26 19:35:13 +08:00
hi-rustin 626bf2c250 Skip avoids_split_debuginfo_collision on stable
Signed-off-by: hi-rustin <rustin.liu@gmail.com>

Address comments

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-02-26 15:38:32 +08:00
hi-rustin 047edec357 Use 1.51.0 in old cargos test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-02-26 15:25:27 +08:00
Ed Page 1eb8913468 feat(search): Highlight search term
This supersedes #10116

Fixes #9918
2022-02-25 20:20:57 -06:00
Weihang Lo 497051a743
New test for cargo rustc --crate-type with dependency 2022-02-26 09:44:48 +08:00
Weihang Lo 229c48a0b9
Avoid assertion against default value in crate-type tests
`--crate-type` usually defaults to `lib`, so the original assertion is
somehow unuseful. Change to `cdylib` to make the test more robust.
2022-02-26 09:44:48 +08:00
Ed Page 4080ed40a0 test(search): Ensure we maintain quiet behavior 2022-02-25 19:13:40 -06:00
bors c9a8199e92 Auto merge of #10372 - weihanglo:issue-9325, r=ehuss
Test: ensure dep-infos do not collide when cdylib and bin coexist
2022-02-25 18:08:41 +00:00
Jon Gjengset 56db82957f Avoid #[cfg] duplicated main in tests
It makes the logic really hard to follow.
2022-02-24 15:17:33 -08:00
Jon Gjengset 54674d365b Improve precision of host build.rustflags tests 2022-02-24 14:56:46 -08:00
Jon Gjengset f23894d93f Make rustflags logic more linear 2022-02-23 16:36:14 -08:00
Jon Gjengset 745329c3b1 Remove env_var from test names that don't use env 2022-02-23 16:35:41 -08:00
bors d6cdde584a Auto merge of #10411 - ehuss:fix-rustflags-gate, r=alexcrichton
Add common profile validation.

This fixes an oversight where `rustflags` is not nightly-gated in a profile override (like `[profile.dev.package.foo]`).

The problem is that the validation was only being done for the top-level profile.
The solution here is to consolidate common profile validation that should be done for both the top level and the overrides. In the process I also fixed validation of `codegen-backend` which also is shared. This will hopefully help prevent other oversights in the future.
2022-02-22 19:55:51 +00:00
bors dcb288805a Auto merge of #10408 - Urgau:check-cfg-features, r=alexcrichton
Add -Z check-cfg-features to enable compile-time checking of features

This pull-request implements the "[Cargo support](https://rust-lang.github.io/rfcs/3013-conditional-compilation-checking.html#cargo-support)" section of [RFC 3013: Checking conditional compilation at compile time](https://rust-lang.github.io/rfcs/3013-conditional-compilation-checking.html#checking-conditional-compilation-at-compile-time).

The support is added in the form of an new unstable flags: `-Z check-cfg-features` that pass all possible features of a package to
`rustc` unstable `--check-cfg` command line as `--check-cfg=values(feature, ...)`. This enables compile time checking of `feature` values in `#[cfg]`, `cfg!` and `#[cfg_attr]`.

This new flag currently only affects `rustc` but `rustdoc` support will be added as soon as [it's support](https://github.com/rust-lang/rust/pull/94154) is merged.

Note than the intent is that this command line options become the default when stabilizing as suggested in the RFC:
> [..] it seems uncontroversial for Cargo to enable checking for feature = "..." values immediately [..]
2022-02-22 19:12:30 +00:00
Eric Huss 99bfbbcb60 Add common profile validation. 2022-02-22 11:04:24 -08:00
Loïc BRANSTETT 4ac4f3d9ab Add test for -Z check-cfg-features with namespaced features 2022-02-22 18:43:12 +01:00
Loïc BRANSTETT a864c81549 Disable -Z check-cfg-features tests on windows due to weird normalization issues
See https://github.com/rust-lang/cargo/runs/5290789288?check_suite_focus=true
Where the expected is: --check-cfg 'values(feature, "f_a", "f_b")'
But we got: --check-cfg "values(feature, /"f_a/", /"f_b/")"
2022-02-22 18:33:03 +01:00
Loïc BRANSTETT 03fbb2eda8 Add -Z check-cfg-features to enable compile-time checking of features 2022-02-22 16:47:52 +01:00
bors 5aad9b302a Auto merge of #9992 - Byron:rfc-3028, r=ehuss
Implement "artifact dependencies" (RFC-3028)

Tracking issue: #9096

#### Tasks

* [x] -Z unstable option called `bindeps`
*  **(config)** allow parsing of newly introduced 'artifact' fields
   * [x] into `TomlManifest`
   * [x] into `Manifest`
      - [x] ~~abort~~ warn if artifacts are used on stable
*  **resolver** : assure artifact dependencies are part of the resolution process and unified into the dependency tree
* 🔬**compiler**: make it understand 'artifact' dependencies and pass new environment variables to the crate being build
  * [x] `lib=false` should not be considered a rust library for the dependent, in unit and possibly resolve graph
  * [x] assure profile settings are applied correctly
  * [x] target overrides work
      * [x] `target = "target"` in build deps
      * [x] other targets on build deps
      * [x] other targets on non-build deps
      * [x] 'no-cross doc tests' seems like a constraint we should apply as well maybe
  * [x] more confidence with `resolver = "2"`
  * [x] assure artifact placement is correct (bin and various forms of lib)
*  **serialization**: rewriting manifests (i.e. for publishing) does not discard artifact information
   * [x] publishing keeps `artifact` and `lib` values
* **Other cargo subcommands**
   * [x] `cargo metadata`
        * leave unchanged
   * [x] artifacts work with `cargo check`
   * [x] artifacts work with rustdoc, such that it doesn't document them unless `lib=true`
   * [x] `cargo tree` maybe?
   * [x] `cargo clean` should clean artifacts - even though it's more complex, ultimately it deletes the `target` directory.
   * [x] artifacts work with `cargo test` (and dev-dependencies)
       * [x] doctests
       * [x] try `reproducible` repository as well.
* 🧪 **tests** for more subtle RFC constraints
   - [x] build scripts cannot access artifact environment variables at compile time, only at runtime)
   - [x] assure 'examples' which also support crate-type fields like [[lib]] won't become artifacts themselves.
   - [x] assure `--out-dir` does not leak artifacts - tested manually, it seemed to niche to add a test.
   - [x] try `target="foo"` in artifact and assure it sees a decent error message
   - [x] Assure RFC 3176 _doesn't_ work
* 🧹cleanup and finalization
    - [x] assure no `TODO(ST)` markers are left in code
    - [x] assure no tests are ignored
    - [x] use `resolver = "1"` once to assert everything also works with the previous resolver, but leave it on "2".

#### Implementation and review notes

- artifacts and unstable options are only checked when transforming them from `TomlManifest` to `Manifest`, discarding artifact information if the unstable flag is not set. Nowhere else in code will the CLI options be checked again.
- `If no binaries are specified, all the binaries in the package will be built and made available.` - this should only refer to `[[bin]]` targets, not examples for instance.
- artifact binaries won't be uplifted, hence won't be present outside of their output directory
- ️We don't know how [package links](00e925f61f/src/cargo/core/compiler/unit_dependencies.rs (L380)) will affect artifacts for build dependencies. Should probably be thought through.
- ️The location of artifacts is only tested roughly to avoid having to deal with different output names on the four platforms that seem to matter (gnu, macos, windows msvc, windows gnu).
- `cargo tree` doesn't handle artifacts specifically, and it might be interesting to make clear if an artifact is only an artifact, or both artifact and dependency.
- Most error and warning messages can probably be more cargo-matic.

#### Questions

* Does `cargo` without the feature enabled have to complain about the "artifact" field in a dependency, like it does right now?  It doesn't look like machinery for that exists in `do_read_manifest()`.
   - ✔️It warns now
*  Should parsing of artifact values, like "bin" be case sensitive?
   - ✔️ It's case sensitive now, which should help with serde roundtripping.

#### Review Progress

* [x] address Josh's review notes one by one
   * [x] introduce `IsArtifact` (see [this answer](https://github.com/rust-lang/cargo/pull/9992#discussion_r774928102)) (76cd48a2d62d74e043a1a482199c5bb920f50311)
   * [x] prefer uplifting artifact deps that were written into the `deps` directory, but prefer to do that in [this PR instead](https://github.com/rust-lang/cargo/pull/9992)
   * [x] add extra-tests as described in Josh's comment: " features get unified between a Rust library and a binary, and one that confirms features don't get unified between a Rust library and a binary for a different target?"
   * [x] Make target-based artifact splitting work by porting parts of RFC-3176
       * [x] test-support/cross-compile
       * [x] namespace separation
* [x] re-create RFC-3176 what's not in RFC-3028, namely multidep support and all related tests
* [x] Address Eh2406 's review comments
* [x] Address Eric's comments
   * [x] Unstable features need to be documented in unstable.md.
   * [x] sort out [`target_data`](https://github.com/rust-lang/cargo/pull/9992#discussion_r787316229)
   * [x] figure out [cargo metadata](https://github.com/rust-lang/cargo/pull/9992#discussion_r787320923)
   * [x] See if target-data can work without an [index format update](https://github.com/rust-lang/cargo/pull/9992#issuecomment-1021697124).
   * [x] truncate comments at 80-90 lines and remove unused methods, remove -Z unstable-options, use `cfg!(target_env = "msvc")`
   * [x] add missing doc comments to newly added methods and funtions
   * [x] simplify method parameters and inline some functions
   * [x] add test and extend test to show additional issues
* [x] assure current set of tests works consistently, also on windows

Sponsored by [Profian](https://www.profian.com)
2022-02-22 03:56:46 +00:00
Sebastian Thiel 7248f4b70d
add support for artifact dependencies (#9096)
Tracking issue: https://github.com/rust-lang/cargo/issues/9096
Original PR: https://github.com/rust-lang/cargo/pull/9992

Add 'bindeps' -Z flag for later use

A test to validate artifact dependencies aren't currently parsed.

Parse 'artifact' and 'lib' fields.

Note that this isn't behind a feature toggle so 'unused' messages will
disappear.

Transfer artifact dependencies from toml- into manifest-dependencies

There are a few premises governing the operation.

- if unstable features are not set, warn when 'artifact' or 'lib' is
  encountered.
- bail if 'lib' is encountered alone, but warn that this WOULD happen
  with nightly.
- artifact parsing checks for all invariants, but some aren't tested.

Assure serialization of 'artifact' and 'lib' fields produces suitable values during publishing

This should be the only place were these fields matter and where a cargo
manifest is actually produced. These are only for internal use, no user
is typically going to see or edit them.

Place all artifact dependency tests inta their own module

This facilitates deduplication later and possibly redistribution into
other modules if there is a better fit.

Represent artifacts that are rust libraries as another ArtifactKind

This is more consistent and probably simpler for later use.
No need to reflect the TOML data structure.

Add tests to assure only 'lib = true' artifact deps are documented

RFC-3028 doesn't talk about documentation, but for lib=true it's clear
what the desired behaviour should be.
If an artifact isn't a library though, then for now, it's transparent,
maybe.

Many more tests, more documentation, mild `Artifact` refactor

The latter seems to be a better fit for what being an artifact
really means within cargo, as it literally turns being a library
on or off, and thus only optionally becoming a normal library.

refactor to prepare for artifact related checks

Don't show a no-lib warning for artifact dependencies (with lib = false)

Tests for more artifact dependency invariants

These are merely a proof of concept to show that we are not in
a position to actually figure out everything about artifacts
right after resolution.

However, the error message looks more like a fatal error and less
like something that can happen with a more elaborate error message
with causes.

This might show that these kind of checks might be better done later
right before trying to use the information for create compile units.

Validate that artifact deps with lib=true still trigger no-lib warnings

This triggers the same warning as before, for now without any
customization to indicate it's an artifact dependency.

Use warnings instead of errors
------------------------------

This avoids the kind of harsh end of compilation in favor of something
that can be recovered from. Since warnings are annoying, users will
probably avoid re-declaring artifact dependencies.

Hook in artifact dependencies into build script runs

Even though we would still have to see what happens if they have a lib
as well. Is it built twice?

Also
----

- fly-by refactor: fix typo; use ? in method returning option
- Propagate artifact information into Units; put artifacts into place

  This means artifacts now have their own place in the 'artifact'
  directory and uplifts won't happen for them.

- refactor and fix cippy suggestion
- fix build after rebasing onto master

Create directories when executing the job, and not when preparing it.

also: Get CI to work on windows the easy way, for now.

Set directories for artifact dependencies in build script runtimes

Test remaining kinds of build-script runtime environment variables

Also
----
- Fix windows tests, the quick way.
- Try to fix windows assertions, and generalize them
- Fix second test for windows, hopefully

test for available library dependency in build scripts with lib = true

probably generally exclude all artifact dependencies with lib=false.

Pass renamed dep names along with unit deps to allow proper artifact env names

Test for selective bin:<name> syntax, as well as binaries with dashes

Test to assure dependency names are transformed correctly

assure advertised binaries and directories are actually present

This wouldn't be the case if dependencies are not setup correctly,
for instance.

Also
----
 - make it easier to see actual values even on failure

   This should help figure out why on CI something fails that works
   locally no matter what.
   Turns out this is a race condition, with my machine being on the good
   side of it so it doesn't show in testing. Fortunately it still can be
   reproduced and easily tested for.

 - refactor test; the race condition is still present though

 - Force CI to pass here by avoiding checks triggering race.

 - Fix windows build, maybe?

More tolerant is_file() checks to account for delay on CI

This _should_ help CI to test for the presence which is better than
not testing at all.

This appears to be needed as the output file isn't ready/present in time
for some reason.

The root cause of this issue is unknown, but it's definitely a race
as it rarely happens locally. When it happened, the file was always
present after the run.
Now we will learn if it is truly not present, ever, or if it's maybe
something very else.

Validate libs also don't see artifact dependencies as libraries with lib=false

Also
----

 - Add prelimiary test for validating build-time artifacts
 - Try to fix CI on gnu windows

   Which apparently generates paths similar to linux, but with .exe suffix.
   The current linux patterns should match that.

 - refactor

   Help sharing code across modules

allow rustc to use artifact dep environment variables, but…

…it needs some adjustments to actually setup the unit dependency graph
with artifacts as well.
Right now it will only setup dependencies for artifacts that are libs,
but not the artifacts themselves, completely ignoring them when they
are not libs.

Make artifact dependencies available in main loop

This is the commit message #2:
------------------------------

rough cut of support for artifact dependencies at build time…

…which unfortunately already shows that the binary it is supposed to
include is reproducibly not ready in time even though the path is
correct and it's present right after the run.

Could it be related to rmeta?

This is the commit message #3:
------------------------------

Fix test expectations as failure is typical than the warning we had before…

…and add some tolerance to existing test to avoid occasional failures.

This doesn't change the issue that it also doens't work at all for
libraries, which is nicely reproducable and hopefully helps to fix
this issue.

This is the commit message #4:
------------------------------

Probably the fix for the dependency issue in the scheduler

This means that bin() targets are now properly added to the job graph
to cause proper syncing, whereas previously apparently it would
still schedule binaries, but somehow consider them rmeta and thus
start their dependents too early, leading to races.

This is the commit message #5:
------------------------------

Don't accidentally include non-gnu windows tests in gnu windows.

Support cargo doc and cargo check

The major changes here are…

- always compile artifacts in build mode, as we literally want the
  build output, always, which the dependent might rely on being present.
- share code between the rather similar looking paths for rustdoc and
  rustc.

Make artifact messages appear more in line with cargo by using backticks

Also: Add first test for static lib support in build scripts

build-scripts with support for cdylib and staticlib

 - Fix windows msvc build

   No need to speculate why the staticlib has hashes in the name even
   though nothing else.

staticlib and cdylib support for libraries

test staticlib and cdylibs for rustdoc as well.

Also catch a seemingly untested special case/warning about the lack
of linkable items, which probably shouldn't be an issue for artifacts
as they are not linkable in the traditional sense.

more useful test for 'cargo check'

`cargo check` isn't used very consistently in tests, so when we use it
we should be sure to actually try to use an artifact based feature
to gain some coverage.

verify that multiple versions are allowed for artifact deps as well.

also: remove redundant test

This is the commit message #2:
------------------------------

Properly choose which dependencies take part in artifact handling

Previously it would include them very generously without considering
the compatible dependency types.

This is the commit message #3:
------------------------------

a more complex test which includes dev-dependencies

It also shows that doc-tests don't yet work as rustdoc is run outside of
the system into which we integrate right now.

It should be possible to write our environment variable configuration
in terms of this 'finished compilation' though, hopefully with
most code reused.

This is the commit message #4:
------------------------------

A first stab at storing artifact environment variables for packages…

…however, it seems like the key for this isn't necessarily correct
under all circumstances. Maybe it should be something more specific,
don't know.

This is the commit message #5:
------------------------------

Adjust key for identifying units to Metadata

This one is actually unique and feels much better.

This is the commit message #6:
------------------------------

Attempt to make use of artifact environment information…

…but fail as the metadata won't match as the doctest unit is, of course,
its separate unit. Now I wonder if its possible to find the artifact
units in question that have the metadata.

Properly use metadata to use artifact environment variables in doctests

This is the commit message #2:
------------------------------

Add test for resolver = "2" and build dependencies

Interestingly the 'host-features' flag must be set (as is seemingly
documented in the flags documentation as well), even though I am not
quite sure if this is the 100% correct solution. Should it rather
have an entry with this flag being false in its map? Probably not…
but I am not quite certain.

This is the commit message #3:
------------------------------

set most if not all tests to use resolver = "2"

This allows to keep it working with the most recent version while
allowing to quickly test with "1" as well (which thus far was working
fine).

All tests I could imagine (excluding target and profiles) are working now

Crossplatform tests now run on architecture aarm64 as well.

More stringent negative testing

Fix incorrect handling of dependency directory computation

Previously it would just 'hack' the deps-dir to become something very
different for artifacts.

This could easily be fixed by putting the logic for artifact output
directories into the right spot.

A test for cargo-tree to indicate artifacts aren't handled specifically

Assure build-scripts can't access artifacts at build time

Actual doc-tests with access to artifact env vars

All relevant parsing of `target = [..]`

Next step is to actually take it into consideration.

A failing test for adjusting the target for build script artifacts using --target

Check for unknown artifact target triple in a place that exists for a year

The first test showing that `target="target"` deps seemingly work

For now only tested for build scripts, but it won't be much different
for non-build dependencies.

build scripts accept custom targets unconditionally

Support target setting for non-build dependencies

This is the commit message #2:
------------------------------

Add doc-test cross compile related test

Even though there is no artifact code specific to doc testing, it's
worth to try testing it with different target settings to validate
it still works despite doc tests having some special caseing around
target settings.

This is the commit message #3:
------------------------------

A test to validate profiles work as expected for build-deps and non-build deps

No change is required to make this work and artifact dependencies 'just work'
based on the typical rules of their non-artifact counterarts.

This is the commit message #4:
------------------------------

Adjust `cargo metadata` to deal with artifact dependencies

This commit was squashed and there is probably more that changed.

This is the commit message #5:
------------------------------

Show bin-only artifacts in "resolve" of metadata as well.

This is the commit message #6:
------------------------------

minor refactoring during research for RFC-3176

This will soon need to return multiple extern-name/dep-name pairs.

This is the commit message #7:
------------------------------

See if opt-level 3 works on win-msvc in basic profile test for artifacts

This is the same value as is used in the other test of the same name,
which certainly runs on windows.

This is the commit message #8:
------------------------------

refactor

Assure the type for targets reflect that they cannot be the host target,
which removes a few unreachable!() expressions.

Put `root_unit_compile_kind` into `UnitFor`

Previously that wasn't done because of the unused `all_values()`
method which has now been deleted as its not being used anyomre.

This allows for the root unit compile kind to be passed as originally
intended, instead of working around the previous lack of extendability
of UnitFor due to ::all_values().

This is also the basis for better/correct feature handling once
feature resolution can be depending on the artifact target as well,
resulting in another extension to UnitFor for that matter.

Also
----

 - Fix ordering

   Previously the re-created target_mode was used due to the reordering
   in code, and who knows what kind of effects that might have
   (despite the test suite being OK with it).

   Let's put it back in place.

 - Deactivate test with filename collision on MSVC until RFC-3176 lands

Avoid clashes with binaries called 'artifact' by putting 'artifact/' into './deps/'

This commit addresses review comment https://github.com/rust-lang/cargo/pull/9992#discussion_r772939834

Don't rely on operator precedence for boolean operations

Now it should be clear that no matter what the first term is,
if the unit is an artifact, we should enqueue it.

Replace boolean and `/*artifact*/ <bool>` with `IsArtifact::(Yes/No)`

fix `doc::doc_lib_false()` test

It broke due to major breakage in the way dependencies are calculated.

Now we differentiate between deps computation for docs and for building.

Avoid testing for doctest cross-compilation message

It seems to be present on my machine, but isn't on linux and it's
probably better to leave it out entirely and focus on the portions
of consecutive output that we want to see at least.

A test to validate features are unified across libraries and those in artifact deps in the same target

Allow aarch64 MacOS to crosscompile to an easily executable alternative target

That way more tests can run locally.

Support for feature resolution per target

The implementation is taken directly from RFC-3176 and notably lacks
the 'multidep' part.

Doing this definitely has the benefit of making entirely clear
'what is what' and helps to greatly reduce the scope of RFC-3176
when it's rebuilt based on the latest RF-3028, what we are implementing
right now.

Also
----
- A test which prooves that artifact deps with different target don't have a feature namespace yet

- Add a test to validate features are namespaced by target

  Previously it didn't work because it relies on resolver = "2".

- 'cargo metadata' test to see how artifact-deps are presented

- Missed an opportunity for using the newly introduced `PackageFeaturesKey`

- Use a HashMap to store name->value relations for artifact environment variables

  This is semantically closer to what's intended.

  also: Remove a by now misleading comment

Prevent resolver crash if `target = "target"` is encountered in non-build dependencies

A warning was emitted before, now we also apply a fix.

Previously the test didn't fail as it accidentally used the old
resolver, which now has been removed.

Abort in parsing stage if nightly flag is not set and 'artifact' is used

There is no good reason to delay errors to a later stage when code
tries to use artifacts via environment variables which are not present.

Change wording of warning message into what's expected for an error message

remove unnecessary `Result` in `collect()` call

Improve logic to warn if dependencie are ignored due to missing libraries

The improvement here is to trigger correctly if any dependency of a
crate is potentially a library, without having an actual library target
as part of the package specification.

Due to artifact dependencies it's also possible to have a dependency
to the same crate of the same version, hence the package name
isn't necessarily a unique name anymore. Now the name of the actual
dependency in the toml file is used to alleviate this.

Various small changes for readability and consistency

A failing test to validate artifacts work in published crates as well

Originally this should have been a test to see target acquisition works
but this more pressing issue surfaced instead.

Make artifacts known to the registry data (backwards compatible)

Now artifacts are serialized into the registry on publish (at least
if this code is actually used in the real crates-io registry) which
allows the resolve stage to contain artifact information.

This seems to be in line with the idea to provide cargo with all
information it needs to do package resolution without downloading
the actual manifest.

Pick up all artifact targets into target info once resolve data is available

Even though this works in the test at hand, it clearly shows there
is a cyclic dependency between the resolve and the target data.

In theory, one would have to repeat resolution until it settles
while avoiding cycles.

Maybe there is a better way.

Add `bindeps`/artifact dependencies to `unstsable.md` with examples

Fix tests

Various small improvements

Greatly simplify artifact environment propagation to commands

Remove all adjustments to cargo-metadata, but leave tests

The tests are to record the status quo with the current code
when artifact dependencies are present and assure the information
is not entirely non-sensical.

Revert "Make artifacts known to the registry data (backwards compatible)"

This reverts commit adc5f8ad04840af9fd06c964cfcdffb8c30769b0.

Ideally we are able to make it work without altering the registry
storage format. This could work if information from the package
set is added to the resolve information.

Enrich resolves information with additional information from downloaded manifests

Resolve information comes from the registry, and it's only as rich as
needed to know which packages take part in the build.

Artifacts, however, don't influence dependency resolution, hence it
shouldn't be part of it.

For artifact information being present nonetheless when it matters,
we port it back to the resolve graph where it will be needed later.

Collect 'forced-target' information from non-workspace members as well

This is needed as these targets aren't present in the registry and
thus can't be picked up by traversing non-workspce members.

The mechanism used to pick up artifact targets can also be used
to pick up these targets.

Remove unnecessary adjustment of doc test

refactor `State::deps()` to have filter; re-enable accidentally disabled test

The initial rebasing started out with a separted `deps_filtered()`
method to retain the original capabilities while minimizing the chance
for surprises. It turned out that the all changes combined in this PR
make heavy use of filtering capabilities to the point where
`deps(<without filter>)` was unused. This suggested that it's required
to keep it as is without a way to inline portions of it.

For the original change that triggered this rebase, see

bd45ac81ba

The fix originally made was reapplied by allowing to re-use the
required filter, but without inlining it.

Always error on invalid artifact setup, with or without enabled bindeps feature

Clarify how critical resolver code around artifact is working

Remove workaround in favor of deferring a proper implementation

See https://github.com/rust-lang/cargo/pull/9992#issuecomment-1033394197
for reference and the TODO in the ignored test for more information.

truncate comments at 80-90c; cleanup

- remove unused method
- remove '-Z unstable-options'
- improve error message
- improve the way MSVC special cases are targetted in tests
- improve how executables are found on non MSVC

Avoid depending on output of rustc

There is cyclic dependency between rustc and cargo which makes it
impossible to adjust cargo's expectations on rustc without leaving
broken commits in rustc and cargo.

Add missing documentation

fix incorrect removal of non-artifact libs

This is also the first step towards cleaning up the filtering logic
which is still making some logic harder to understand than needs be.

The goal is to get it to be closer to what's currently on master.

Another test was added to have more safety regarding the overall
library inclusion logic.

inline `build_artifact_requirements_to_units()`

Simplify filtering

This adds a default filter to `state.deps(…)` making it similar to
what's currently in master, while creating another version of it
to allow setting a custom filter. This is needed as the default filter
won't allow build dependencies, which we need in this particular case.

`calc_artifact_deps(…)` now hard-codes the default filter which is
needed due to the use of `any` here:
c0e6abe384/src/cargo/core/compiler/unit_dependencies.rs (L1119)
.

Simplify filtering.
2022-02-22 08:08:42 +08:00
Jon Gjengset 49f90f5055 Retain legacy behavior with tath != false 2022-02-21 10:20:32 -08:00
bors 46c9b51957 Auto merge of #10346 - yerke:yerke/no-run-test-executable-path, r=ehuss
Print executable name on cargo test --no-run #2

Closes #9957

This is a continuation of https://github.com/rust-lang/cargo/pull/9959.
2022-02-20 15:47:58 +00:00
Jon Gjengset 4f41727106 Enable propagating rustflags to build scripts
This patch implements more complete logic for applying rustflags to
build scripts and other host artifacts. In the default configuration, it
only makes build scripts (and plugins and whatnot) pick up on
`rustflags` from `[host]`, which fixes #10206 but otherwise preserves
existing behavior in all its inconsistent glory. The same is the case if
`target-applies-to-host` is explicitly set to `false`.

When `target-applies-to-host` is explicitly set to `true`, rustflags
will start to be applied in the same way that `linker` and `runner` are
today -- namely they'll be applied from `[target.<host triple>]` and
from `RUSTFLAGS`/`build.rustflags` if `--target <host triple>` is given.
2022-02-18 10:50:08 -08:00
Jon Gjengset fb47df72e1 Add regression test for #10206 2022-02-18 08:48:17 -08:00
David Tolnay b2b3bdeede
Consistently use crate::display_error on errors during drain 2022-02-17 13:59:06 -08:00
Jon Gjengset 040f0d10a6 Simplify unused build scripts in tests
The tests in question all tail to even build the build script, so the
contents of `main` don't matter, and make the tests seem more complex
than they really are.
2022-02-17 10:33:23 -08:00
Jon Gjengset 90a61d183f Run target-applies-to-host tests on stable 2022-02-17 10:31:10 -08:00
Weihang Lo 552b52a894
Test for cargo new/init autodetct and ignore file rules 2022-02-11 18:54:27 +08:00
Weihang Lo e2142487d4
Test: ensure dep-infos do not collide when cdylib and bin coexist
A new test `build::no_dep_info_collision_when_cdylib_and_bin_coexist`
is added to prevent regression.

Note that on Windows MSVC cargo does not use metadata, so a collision
still happens when cdylib and bin targets coexist.
2022-02-08 22:51:18 +08:00
bors 3bc0e6d83f Auto merge of #10245 - joshtriplett:stabilize-timings, r=joshtriplett
Stabilize `-Ztimings` as `--timings`

The `-Ztimings` option has existed for years, and many people use it to
profile and optimize their builds. It's one of the common reasons people
use nightly cargo.

The machine-readable JSON output may warrant further careful inspection
before we commit to a stable format. However, for the human-readable
output we don't need to make any commitment about the exact output.

Add a `--timings` option, as the stable equivalent to `-Ztimings`.
(Passing `html` or `json` requires `-Zunstable-options`, but the default `--timings` does not.)

Document the new option, and update the testsuite.
2022-02-05 04:45:49 +00:00
bors be4bb61d04 Auto merge of #10341 - hi-rustin:rustin-patch-doc-deps, r=ehuss
Compute non custom build and non transitive deps for doc

### What does this PR try to resolve?

close https://github.com/rust-lang/cargo/issues/10318 and close https://github.com/rust-lang/cargo/issues/9198
### How should we test and review this PR?

Compute non custom build and non transitive deps for doc.
Add test for it.
2022-02-03 17:53:13 +00:00
Yerkebulan Tulibergenov 0b74ea2f76 display bench exec info differently 2022-02-02 08:17:09 -08:00
bors 25fcb135d0 Auto merge of #10349 - epage:install, r=ehuss
fix(install): Keep v1 file formatting the same

Inspired by #10345, I looked for other cases where
`toml_edit::easy::to_string` is used (which outputs inline tables) to
see if we should switch to `to_string_pretty`.  The crates v1 file was
the only case I found.

As a side effect, we can no longer elide the empty `dev-dependencies`
table in published manifests.  This was the behavior before `toml_edit`,
so not much of a loss.
2022-02-01 01:32:48 +00:00
bors a59d202ed7 Auto merge of #10348 - epage:vendor, r=alexcrichton
fix(vendor): Use tables for sample config

Fixes #10345
2022-01-31 19:16:05 +00:00
Yerkebulan Tulibergenov ed579b66e2 add short path name for executables 2022-01-31 10:37:02 -08:00
bors ea259a07f5 Auto merge of #10337 - WaffleLapkin:merge_futures_with_all_features, r=alexcrichton
Do not ignore `--features` when `--all-features` is present

This allows to specify dependency features when using `--all-features`, for example:
```shell
$ cargo run --example example --all-features --features="tracing/log"
```
You can test this in this repository: https://github.com/WaffleLapkin/cargo_all_some_features, it contains an example with ``required-features = [..., "tracing/log"]`` that is impossible to run with `--all-features` without this patch.

An attempt to fix #10333
2022-01-31 17:52:10 +00:00
Ed Page 0f75237617 test: Fix compatibilty with new toml_edit
`toml_edit` fixed a bug in 0.13.4 that this test was relying on that is
meant to help with rust-lang/cargo#10349.  This basically restores us
back to the pre-toml_edit behavior for published manifests.
2022-01-31 10:57:38 -06:00
Ed Page 24defcbc14 fix(install): Keep v1 file formatting the same
Inspired by #10345, I looked for other cases where
`toml_edit::easy::to_string` is used (which outputs inline tables) to
see if we should switch to `to_string_pretty`.  The crates v1 file was
the only case I found.

As a side effect, we can no longer elide the empty `dev-dependencies`
table in published manifests.  This was the behavior before `toml_edit`,
so not much of a loss.
2022-01-31 10:42:05 -06:00
Ed Page fb9d11b8fc fix(vendor): Use tables for sample config
Fixes #10345
2022-01-31 09:57:56 -06:00
Yerkebulan Tulibergenov a6c1459f37 fix tests 2022-01-30 23:59:54 -08:00
Yerkebulan Tulibergenov eca63cfd4e Merge branch 'master' into yerke/no-run-test-executable-path 2022-01-30 23:13:35 -08:00
Josh Triplett e23f5f41d1 Move timing reports to target/cargo-timings
This avoids dropping them wherever Cargo happens to run from, and
instead places them under the target directory.

This has the advantage, and disadvantage, that `cargo clean` will remove
them.
2022-01-30 21:43:52 -08:00
Josh Triplett c06691897a Stabilize -Ztimings as --timings
The `-Ztimings` option has existed for years, and many people use it to
profile and optimize their builds. It's one of the common reasons people
use nightly cargo.

The machine-readable JSON output may warrant further careful inspection
before we commit to a stable format. However, for the human-readable
output we don't need to make any commitment about the exact output.

Add a `--timings` option, as the stable equivalent to `-Ztimings`.
Stabilize the `html` output format, and require `-Zunstable-options` for
the `json` output format.

Document the new option, and update the testsuite.
2022-01-30 21:43:48 -08:00
Josh Triplett 86bb4a0c2b Remove -Ztimings=info
The text-based timing information emits many additional lines, creating
quite a bit of verbosity. Remove in favor of the HTML report, as
suggested at
https://github.com/rust-lang/cargo/pull/10245#issuecomment-1003741052 .

If we re-add text-based timing information in the future, it could come
in the form of a text-based report, or as a duration printed on the same
line as the crate it measures rather than a separate line.
2022-01-30 21:42:33 -08:00
bors b2496f0590 Auto merge of #10274 - aviramha:extra-link-args, r=ehuss
extra-link-arg-etc: support all link types (credit @davidhewitt)

This commit adds support for the remaining link types to `-Zextra-link-arg-etc`:
`
rustc-link-arg-tests
rustc-link-arg-benches
rustc-link-arg-examples
`
This would be useful in PyO3, where users writing Python extension modules (which do link against libpython) want to run cargo tests for extension module. As executables, these tests need to link against libpython.

This is a follow up of https://github.com/rust-lang/cargo/pull/9416 by `@davidhewitt`
2022-01-30 16:29:27 +00:00
Maybe Waffle b7e5186701 Add test for --all-features --features dep/feat 2022-01-30 13:33:08 +03:00
hi-rustin 81c2cd5a95 Compute non custom build and non transitive deps for doc
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-01-30 00:06:27 +08:00
Maybe Waffle 3d74ad8e3c Do not ignore --features when --all-features is present
This allows to specify dependency features when using `--all-features`,
for example:
```shell
$ cargo run --package a --example example --all-features --features="tracing/log"
```
2022-01-28 02:49:42 +03:00
Aviram Hassan 541c908ef6
extra-link-arg-etc: support all link types (credit @davidhewitt) 2022-01-27 21:57:57 +02:00
bors 51379053ef Auto merge of #10335 - weihanglo:issue-10283, r=alexcrichton
Normalize --path when install bin outside current workspace
2022-01-27 15:55:17 +00:00
Weihang Lo 11c50416c2
Assert optional args with square brackets [arg...] 2022-01-27 19:28:51 +08:00
Weihang Lo 76301ebab9
Test: install bin with --path outside current workspace 2022-01-27 18:31:02 +08:00
Weihang Lo d323ad672c
Test: install with path outside current workspace
Make up this test case to reflect the current incorrect behavior.
2022-01-27 18:31:01 +08:00
bors 018acfdddd Auto merge of #10176 - jonhoo:config-cli-simple, r=ehuss
Check --config for dotted keys only

This addresses the remaining unresolved issue for `config-cli` (#7722).
2022-01-25 17:53:34 +00:00
Eric Huss fdeb38b903 Fix documenting with undocumented dependencies. 2022-01-24 17:10:05 -08:00
Jon Gjengset 51917b450d Enforce no decorators in --config values 2022-01-24 12:05:12 -08:00
Jon Gjengset f962ec1f44 Merge remote-tracking branch 'upstream/master' into config-cli-simple 2022-01-20 12:31:35 -08:00
bors 58790d3b5e Auto merge of #10305 - weihanglo:issue-10268, r=alexcrichton
do not compile test for bins flagged as `test = false`

### What does this PR try to resolve?

Fixes #10268

#6683 introduced a behavior that compiles all bin targets, but for bins with `test = false` they shouldn't be compiled with `--test` as testbins.

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

In the first commit of this PR, I refines the test `test_filtered_excludes_compiling_examples` to reflect the current wrong behavior (test passed). The following two commits correct the behavior and the test accordingly. The last few commits encapsulate scattered target selection logic into functions on `CompileFilter`.
2022-01-20 15:07:43 +00:00
bors bb96b3a3e8 Auto merge of #10086 - epage:toml, r=ehuss
Port cargo from toml-rs to toml_edit

Benefits:
- A TOML 1.0 compliant parser
- Unblock future work
  - Have `cargo init` add the current crate to the workspace, rather
    than error
  - #5586: Upstream `cargo-add`

TODO
- [x] Analyze performance and address regressions
- [x] Identify and resolve incompatibiies
- [x] Resolve remaining test failures, see
      https://github.com/ordian/toml_edit/labels/cargo
- [x] ~~Switch the code from https://github.com/rust-lang/cargo/pull/10176 to only parse once~~ (this PR is being merged first)
2022-01-20 03:56:18 +00:00
Eric Holk 1683cd5eec Refactor create_empty_config to create_default_config 2022-01-19 08:45:03 -08:00
Eric Holk 40c51392dd Fix new::git_default_branch with different default
The test new::git_default_branch would fail if the current user had
already configured a different default branch.

This patch changes the test to first write a .gitconfig file with the
default branch set to master. This puts us in a state where we still
have the old default, and then the subsequent change to the config file
will make sure that config changes are still respected.
2022-01-18 14:51:21 -08:00
Weihang Lo bee3534f27
test: do not compile test for bins flagged as test = false 2022-01-19 03:36:53 +08:00
Weihang Lo f07dcd13a0
test: compile all bins when TESTNAME arg exists
This behavior is not correct should be fixed.
Update this test only for pointing out the current behavior.
2022-01-19 02:47:30 +08:00
bors 95bb3c92bf Auto merge of #10243 - hi-rustin:rustin-patch-collision, r=ehuss
Error when setting crate type of both dylib and cdylib in library

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

Error when setting crate type of both dylib and cdylib in library. Cargo can't support that at this time, since they both output the same filename.
2022-01-18 17:39:35 +00:00
hi-rustin 3738002e43 Error when setting crate type of both dylib and cdylib in library
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-01-16 17:38:43 +08:00
Eric Huss a25d3864d9 Bump to 0.61.0 2022-01-14 10:57:54 -08:00
maxwase 2623af0c43 Use is_symlink() method 2022-01-14 00:36:24 +03:00
Ed Page 320c279f43 Port cargo from toml-rs to toml_edit
Benefits:
- A TOML 1.0 compliant parser
- Unblock future work
  - Have `cargo init` add the current crate to the workspace, rather
    than error
  - #5586: Upstream `cargo-add`
2022-01-13 09:27:27 -06:00
bors e77c0719fd Auto merge of #10269 - ehuss:stabilized-new-features, r=alexcrichton
Stabilize namespaced and weak dependency features.

This stabilizes the namespaced and weak dependency features.  Support is now enabled on crates.io, so this should be ready to go.

As a part of this change, the new feature resolver is now enabled all of the time. This is fairly risky, since there are likely edge cases that haven't been exercised.
NOTE: Projects using `resolver="1"` *should* continue to have the same behavior, the old resolver behavior is emulated.

Closes #8813
Closes #8832
2022-01-12 15:15:09 +00:00
Seb E e5ff81b0e7 Fix use of .. in dep-info-basedir config 2022-01-12 10:37:32 +01:00
bors 06b9d31743 Auto merge of #10265 - epage:clap-port, r=joshtriplett
Port cargo to clap3

### What does this PR try to resolve?

This moves cargo to the latest major version of clap.

This supersedes #10259  and #10262

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

For testing, I mostly relied on existing tests.  I did manually validate that `cargo run <non-escaped command args>` behaved the same between both
```console
$ cargo run release --help
    Finished dev [unoptimized + debuginfo] target(s) in 0.22s
     Running `target/debug/cargo-release release --help`
cargo-release 0.18.8
...

$ cargo run --manifest-path ../cargo/Cargo.toml -- run release --help
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `/home/epage/src/personal/cargo/target/debug/cargo run release --help`
    Finished dev [unoptimized + debuginfo] target(s) in 1.31s
     Running `target/debug/cargo-release release --help`
cargo-release 0.18.8
...
```

For reviewing, I split out each deprecation resolution into a separate commit so its easy to focus on more mechanical changes (most of the deprecation fixes) from interesting ones (the port, the `Arg::multiple` deprecation)

### Additional information

- One parser change found by `cargo_config::includes` is that clap 2
  would ignore any values after a `=` for flags.
  `cargo config --show-origin` is a flag but the test passed `--show-origin=yes` which
  happens to give the desired result for that test but is the same as
  `--show-origin=no` or `--show-origin=alien-invasion`.
- `ArgMatches` now panics when accessing an undefined argument but clap
  takes advantage of that for sharing code across commands that have
  different subsets of arguments defined.  I've extended clap so we can
  "look before you leap" and put the checks at the argument calls to
  start off with so its very clear what is tenuously shared.  This
  allows us to go in either direction in the future, either addressing
  how we are sharing between commands or by moving this down into the
  extension methods and pretending this clap feature doesn't exist
- On that topic, a test found clap-rs/clap#3263.  For now, there is a
  hack in clap.  Depending on how we fix that in clap for clap 4.0, we
  might need to re-address things in cargo.
- `value_of_os` now requires setting `allow_invalid_utf8`, otherwise it
  asserts.  To help catch this, I updated the argument definitions
  associated with lookups reported by:
  - `rg 'values?_os' src/`
  - `rg 'values?_of_os' src/`
- clap now reports `2` for usage errors, so we had to bypass clap's
  `exit` call to keep the same exit code.
- `cargo vendor --sync` did not use `multi_opt` and so it has both
  multiple occurrences **and** multiple values.  If we want to deprecate
  this, we'll need `unstable-grouped` to be stablized (or pin our clap
  version) and ensure each group has only 1 value.
2022-01-11 23:47:29 +00:00
bors 0655dd25a0 Auto merge of #10217 - zhamlin:feat/profile-rustflags, r=ehuss
feat: support rustflags per profile

Fix for issue https://github.com/rust-lang/cargo/issues/7878
2022-01-10 16:56:16 +00:00
Zach Hamlin 68fd67319d feat: support rustflags per profile 2022-01-09 11:35:15 -06:00
Eric Huss 43a063c80a Stabilize namespaced and weak dependency features. 2022-01-06 15:56:56 -08:00
Ed Page f17ecafc24 Upgrade to Clap 3
- One parser change found by `cargo_config::includes` is that clap 2
  would ignore any values after a `=` for flags.
  `cargo config --show-origin` is a flag but the test passed `--show-origin=yes` which
  happens to give the desired result for that test but is the same as
  `--show-origin=no` or `--show-origin=alien-invasion`.
- The parser now panics when accessing an undefined attribute but clap
  takes advantage of that for sharing code across commands that have
  different subsets of arguments defined.  I've extended clap so we can
  "look before you leap" and put the checks at the argument calls to
  start off with so its very clear what is tenuously shared.  This
  allows us to go in either direction in the future, either addressing
  how we are sharing between commands or by moving this down into the
  extension methods and pretending this clap feature doesn't exist
- On that topic, a test found clap-rs/clap#3263.  For now, there is a
  hack in clap.  Depending on how we fix that in clap for clap 4.0, we
  might need to re-address things in cargo.
- `value_of_os` now requires setting `allow_invalid_utf8`, otherwise it
  asserts.  To help catch this, I updated the argument definitions
  associated with lookups reported by:
  - `rg 'values?_os' src/`
  - `rg 'values?_of_os' src/`
- clap now reports `2` for usage errors, so we had to bypass clap's
  `exit` call to keep the same exit code.

BREAKING CHANGE: API now uses clap3
2022-01-05 19:54:54 -06:00
bors 2478331215 Auto merge of #10214 - weihanglo:revert-10188-issue-9528, r=alexcrichton
Be resilient to most IO error and filesystem loop while walking dirs

Let `PathSource::walk` be resilient to most IO errors and filesystem loop.

This PR also

- Add a test validating the resilience against filesystem loop to prevent regression.
- Emit warning when filesystem loop found while walking the filesystem. This is the only way I can think of now to solve #9528

Fixes #10213.
2022-01-05 22:10:29 +00:00
Josh Triplett 65ddbbdfb3 Remove the option to disable pipelining
Cargo has had pipelining enabled by default for a long time, without
issue. Remove support for `build.pipelining = false`. (Continue parsing
the option from the config file, but ignore it.)
2022-01-05 10:25:23 -08:00
Weihang Lo d92dceaeba
Test IO error resilience while walking directories
Remove `build_script::build_script_scan_eacces`  test case because cargo
ignores it and returns its path during a `cargo build`. The caller still
has a chance to hit the IO error if they does access it.
2022-01-05 14:29:59 +08:00
bors 3897749d21 Auto merge of #10088 - joshtriplett:stabilize-strip, r=ehuss
Stabilize the `strip` profile option, now that rustc has stable `-C strip`

https://github.com/rust-lang/rust/pull/90058/ stabilized `-Z strip` as `-C strip`. Stabilize the corresponding Cargo option.

Update the documentation to move it from the unstable reference to the profiles documentation.

Update the tests to account for stabilization.
2022-01-04 17:11:34 +00:00
Josh Triplett 75e544d545 Stabilize the strip profile option, now that rustc has stable -C strip
https://github.com/rust-lang/rust/pull/90058/ stabilized `-Z strip` as
`-C strip`. Stabilize the corresponding Cargo option.

Update the documentation to move it from the unstable reference to the
profiles documentation.

Update the tests to account for stabilization, but make them no-ops on
stable/beta for now until rustc 1.58 releases.
2021-12-23 23:40:13 -08:00
Midas Lambrichts 42528799e2 Make levenshtein distance case insensitive.
When typing in a single character shortcut as a capital, it always
returns `b` as the suggestion as every one-letter abbreviation
is a lev distance 1 away from the capitalized one.
By making the levenshtein distance case insensitive, the case-mismatched
one-letter abbriviation (e.g. `C` to `c`) will be suggested, rather
than `b`
2021-12-21 12:56:28 +01:00
Weihang Lo 6f912788ed
Test cargo build being resilient to filesystem loop 2021-12-21 02:46:05 +08:00
bors b05697de66 Auto merge of #10188 - weihanglo:issue-9528, r=alexcrichton
Detect filesystem loop during walking the projects

Resolves #9528

~~This PR also adds a new dependency `same-file` but since it's already a
dependency of `cargo-util`, so nothing added actually.~~

Use `walkdir` to detect filesystem loop and gain performance boost!
2021-12-16 15:48:52 +00:00
hi-rustin 07843ed8fb add open_no_doc_crate test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-12-16 22:29:32 +08:00
Eric Huss 6e568690a6 Don't document libs with doc=false 2021-12-15 15:13:54 -08:00
Jon Gjengset 1372afc6bd Fix up config_include test 2021-12-14 19:39:03 -08:00
Weihang Lo 6fa0f01d87
Test filesystem loop during traversal
Use unordered since order of warning differs on each platform.
2021-12-15 09:42:14 +08:00
Jon Gjengset 934d2d63f5 Use toml_edit to check dotted key for --config 2021-12-14 14:25:32 -08:00
Jon Gjengset 18871b3394 Merge remote-tracking branch 'upstream/master' into config-cli-simple 2021-12-14 12:16:59 -08:00
bors a359ce1607 Auto merge of #10152 - steven-joruk:quiet-config, r=ehuss
Support `term.quiet` configuration

Fixes #10128

This follows the existing support for `--verbose` and `term.verbose`.

I've renamed the related tests to be a bit clearer now there are more cases, and the existing quiet tests now prove that they hide the cargo log.

I'm unsure whether I'm supposed to regenerate the documentation as part of this?
2021-12-14 18:40:22 +00:00
bors c689f55b8c Auto merge of #10193 - sstangl:help-alias-10138, r=alexcrichton
Display alias target on 'cargo help <alias>`

```
Previously, `cargo help <alias>` resolved the alias and displayed the
help for the targeted subcommand. For example, if `br` were aliased to
`build --release`, `cargo help br` would display the manpage for
cargo-build.

With this patch, it will print "'br' is aliased to 'build --release'".
```

Addresses issue #10138.

This is my first patch to Cargo. I attempted to follow the style of the surrounding code. Please let me know if any changes are required: happy to make them. In particular, I wasn't sure if any tests exist for this path.
2021-12-14 17:50:46 +00:00
bors c87b986a5c Auto merge of #10145 - QiangHeisenberg:deprecated, r=alexcrichton
delete --host command and message

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

The warning for this command has been around for a long time, and it seems safe to delete it now.
According to Alex's words in the issue, I think he supports deletion. I'm sorry if I misunderstood it and feel free to close it.
2021-12-14 17:07:04 +00:00
bors 0bbfc5e536 Auto merge of #10191 - weihanglo:issue-9881, r=alexcrichton
Improve I/O error message for fingerprint of build script

It is a bit rough but I don't think there is a network I/O error
in `pkg_fingerprint`. Checking only `io::Error` type should be fine.

Resolves #9881
2021-12-13 21:09:58 +00:00
bors 1ee19f3403 Auto merge of #10177 - ehuss:list-alias, r=alexcrichton
Explicitly mark aliases in `cargo list`.

This I think makes it a little clearer that these are aliases, and matches the form used for built-in aliases.
2021-12-13 20:26:34 +00:00
bors a4cdd757e5 Auto merge of #10171 - ehuss:no-executable-doc, r=alexcrichton
Don't emit "executable" JSON field for non-executables.

The "executable" field of JSON artifact messages was accidentally filled (with the path to `index.html`) when documenting a binary target. This fixes it so that it is null.

Closes #10149
2021-12-13 19:48:00 +00:00
bors c7db2995d0 Auto merge of #10161 - weihanglo:issue-7473, r=alexcrichton
Do not suggest source config if nothing to vendor

fixes #7473

Also remove the empty vendor dir if we've just created it but didn't vendor anything.
2021-12-13 18:26:26 +00:00
bors 3aaa8f975d Auto merge of #10172 - ehuss:doc-lib-before-bin, r=alexcrichton
Document lib before bin.

This changes it so that documenting a library is required to finish before documenting a binary. The issue is that the binary may have intra-doc links to the library. If they are documented concurrently, then the links will sometimes fail (since it is a race).   Or, if doing `cargo doc --bins`, then the library docs wouldn't exist at all.

Note that in the tests this introduces some more name collisions if you just run `cargo doc --bins` and there is a colliding library/binary name. There is some risk that someone might be trying to run the commands separately to get around the collision error, but I think it is unlikely.
2021-12-13 15:38:31 +00:00
Sean Stangl 4c66d18361 fix panic if an alias is defined to "" 2021-12-12 13:30:31 -07:00
Sean Stangl 6df4b1ef71 Update behavior to pass-through simple aliases
This changes the behavior so that simple aliases that directly alias a
subcommand (with no arguments) pass-through to that subcommand, while
complex aliases (with arguments) show the alias.

So for example, `cargo help b` will show the manpage for `cargo-build`,
while `cargo help my-alias`, aliased to `build --release`, will show
"`my-alias` is aliased to `build --release`".
2021-12-12 10:18:19 -07:00
Sean Stangl e77b254923 Update help::help_alias() to assert the new behavior 2021-12-11 15:31:48 -07:00
Weihang Lo 760ff62f36
Improve I/O error message for fingerprint of build script
It is a bit rough but I don't think there is a network I/O error
in `pkg_fingerprint`. Checking only `io::Error` type should be fine.
2021-12-11 08:31:24 +08:00
Steven Joruk 7ac6f53743 Code review fixes 2021-12-08 22:18:47 +00:00
Eric Huss 910569aac3 Explicitly mark aliases in cargo list. 2021-12-06 14:02:21 -08:00
Jon Gjengset 80fbfed287 Check --config for dotted keys only
This addresses the remaining unresolved issue for `config-cli` (#7722).
2021-12-06 13:25:53 -08:00
bors 263b1690c2 Auto merge of #10165 - Aaron1011:stabilize-future-incompat, r=ehuss
Stabilize future-incompat-report

Depends on https://github.com/rust-lang/rust/pull/91535
2021-12-06 18:47:39 +00:00
Eric Huss 6a79008cad Don't emit "executable" JSON field for non-executables. 2021-12-05 18:39:30 -08:00
Eric Huss a09fbf2ef8 Document lib before bin. 2021-12-05 15:14:54 -08:00
bors cf474a5de7 Auto merge of #10133 - joshtriplett:release-short, r=ehuss
Support abbreviating `--release` as `-r`

Of the options people regularly pass to cargo, `--release` seems by far
the most common. Yet even on the command line, we expect people to type
out `--release`.

Add a short version `-r`, and add some tests in the testsuite that
confirm it works.
2021-12-05 19:44:23 +00:00
Aaron Hill 997bf3fffc
Stabilize future-incompat-report
Depends on https://github.com/rust-lang/rust/pull/91535
2021-12-05 14:14:32 -05:00
Weihang Lo 8a8d39a459
Do not suggest source config if nothing to vendor 2021-12-05 00:10:09 +08:00
Steven Joruk ed9ec388fd Support term.quiet configuration
This matches how users can specify `--verbose` on the command line, or
`term.verbose` in the configuration.
2021-12-03 06:25:02 +00:00
l00556901 cf621fdc94 modify test 2021-12-02 19:55:56 +08:00
l00556901 64c69dffc5 fix some bugs 2021-12-01 11:21:06 +08:00
l00556901 56b8ae7c44 delete --host command and message 2021-12-01 10:29:46 +08:00
bors 294967c53f Auto merge of #10137 - ehuss:lto-pdb-collision-test, r=alexcrichton
Fix some tests with output collisions.

This fixes some tests which run afoul of creating colliding outputs (tracked in #6313). In particular, these tests are creating duplicate pdb files on Windows because they have a binary and a library (dylib) with the same name. This is causing significant issues on rust-lang's CI (https://github.com/rust-lang/rust/issues/81890) where the MSVC linker is failing with a mysterious LNK1201 error. Presumably two LINK.exe processes are trying to write to the same PDB file at the same time, which causes it to fail.

Ideally this shouldn't happen, but I don't really have any ideas on how to resolve it, as the name of the PDB has some importance.

I have not been able to reproduce the LNK1201 error. My hope is that this change will help alleviate the issue, though.

I updated the `doc_all_member_dependency_same_name` test to illustrate that it is hitting a collision, which is a fundamental part of that test (and something we should probably figure out how to resolve in the future).
2021-11-29 19:04:22 +00:00
Eric Huss 2507d53bb6 Fix some tests with output collisions. 2021-11-29 11:04:08 -08:00
bors c5fddb0f56 Auto merge of #10130 - weihanglo:issue-8690, r=alexcrichton
Improve unused patch message when source URLs mismatched

Resolves #8690

`Resolve.unused_patches` does not contains info about which source
URLs they are going to patch. As a result, we cannot provide a precise
message but only list all possible URLs of the packages with the same
name in the resolved graph.

There is a little flaw that if multiple patches are patching the same
package, the source URL of the used one would be shown as a possible
URL in the warning.
2021-11-29 16:29:46 +00:00
Josh Triplett 2f53ca2df1 Support abbreviating --release as -r
Of the options people regularly pass to cargo, `--release` seems by far
the most common. Yet even on the command line, we expect people to type
out `--release`.

Add a short version `-r`, and add some tests in the testsuite that
confirm it works.
2021-11-28 20:25:57 -08:00
Eric Huss ca3356a25c Add a note about doctest xcompile. 2021-11-28 17:32:11 -08:00
Weihang Lo 91791c4fb1
Improve unused patch message when source URLs mismatched
`Resolve.unused_patches` does not contains info about which source
URLs they are going to patch. As a result, we cannot provide a precise
message but only list all possible URLs of the packages with the same
name in the resolved graph.

There is a little flaw that if multiple patches are patching the same
package, the source URL of the used one would be shown as a possible
URL in the warning.
2021-11-28 09:20:06 +08:00
bors b85ad15963 Auto merge of #10093 - hi-rustin:rustin-patch-rustc, r=ehuss
Add crate type flag to rustc command

part of https://github.com/rust-lang/cargo/issues/10083

- Add crate type flag to rustc command
- Add tests
- Update docs
2021-11-26 15:30:19 +00:00
Esteban Kuber 0dfe70f7e1 Change test to not trigger emoji error
This change is needed to land rust-lang/rust#88781, as it changes the
handling of emojis in source code to treat them as identifiers.
2021-11-24 17:07:40 +00:00
hi-rustin 660ce6bba4 Add tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-11-23 22:58:18 +08:00
bors e1fb17631e Auto merge of #10110 - hi-rustin:rustin-patch-build-test, r=alexcrichton
re-enable lto_build test on 32-bit MSVC

re-enable lto_build test on 32-bit MSVC. Because https://github.com/rust-lang/rust/pull/27224 landed.
2021-11-22 16:53:06 +00:00
bors a2c6ec7522 Auto merge of #10103 - ehuss:tree-cycle, r=alexcrichton
Fix a couple issues with cyclic features and dev-dependencies

This fixes two issues with cyclic features and dev-dependencies:

* `cargo tree` would enter an infinite loop for cyclic features.
* The resolver would return a confusing error if a cyclic dev-dependency attempted to enable a feature on its parent that resulted in a cycle.  This fixes it to resolve correctly.

Fixes #10101
2021-11-22 16:18:31 +00:00
hi-rustin a22a68e937 re-enabled lto_build test on 32-bit MSVC
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-11-22 22:12:48 +08:00
bors df8cda0a12 Auto merge of #10107 - hi-rustin:rustin-patch-install, r=ehuss
Add --message-format for install command

close https://github.com/rust-lang/cargo/issues/10104
2021-11-21 16:13:58 +00:00
hi-rustin 6351472a80 Add --message-format for install
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-11-21 12:16:50 +08:00
hi-rustin a0dffe0f43 Make clippy happy
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-11-21 11:40:31 +08:00
bors 7a947ae523 Auto merge of #10043 - jyn514:hard-error, r=ehuss
Give a hard error if `-Zrustdoc-scrape-examples` is missing a flag

It's the same as if the option wasn't passed, and it makes it difficult to
figure out why rustdoc isn't generating examples.

Fixes https://github.com/rust-lang/cargo/issues/10042 (cc `@willcrichton)`
2021-11-20 18:23:22 +00:00
Eric Huss 2eee644c68 Fix resolve error with cyclic dev-dependency features.
There is a convoluted situation where a cyclic dev-dependency attempts
to enable a feature on its parent. It would result in a confusing error
saying a package didn't have a feature.

This check was intended only for CLI features, not features passed
through the dependency graph.
2021-11-19 18:10:10 -08:00
Eric Huss d7ab4a6598 cargo tree: Fix stack overflow on cyclic features. 2021-11-19 18:07:31 -08:00
bors ad50d0d266 Auto merge of #10082 - basile-henry:basile/alias-shadow-external-warning, r=ehuss
Warn when alias shadows external subcommand

As per #10049, we start by emitting a warning when an alias shadows an
existing external subcommand. After a transition period (duration not
specified), we will make this a hard error.

Should the warning mention that this will become a hard error?
2021-11-17 18:36:37 +00:00
bors adf601d41c Auto merge of #10072 - russweas:master, r=alexcrichton
Implement escaping to allow clean -p to delete all files when directory contains glob characters

Closes #10068.

Runs `glob::Pattern::escape` on path input to `rm_rf_glob()`. This fixes a bug in which `cargo clean -p` fails to delete a number of files from `target/` if the path to target contains glob characters.
2021-11-17 16:00:17 +00:00
bors d2d4b06e55 Auto merge of #10092 - ChrisDenton:tmp-match-err, r=alexcrichton
Match any error when failing to find executables

For Windows targets, Rust now uses [a custom resolver](https://github.com/rust-lang/rust/pull/87704) to find `process::Command` programs. This has caused some error messages to change.

To allow the PR to be merged, some tests have been adjusted to match any error.

cc `@ehuss`
2021-11-17 15:16:29 +00:00
Chris Denton 93bcd97fc1
Match any error when failing to find executables
For Windows targets, Rust now uses a custom resolver to find `process::Command` programs. This has caused some error messages to change.

To allow it to be merged, some tests have been adjusted to match any error.
2021-11-17 11:09:52 +00:00
Weihang Lo 2698bc6a42
Test for target auto-discovery error enhancement 2021-11-17 18:14:27 +08:00
Basile Henry 0b4e2ca330 Add test for alias shadowing external subcommand
This is currently still permitted, so we only test that the warning is properly issued
2021-11-17 09:23:06 +01:00
Basile Henry cba8503e3a Add details in warning for alias shadowing external subcommands 2021-11-17 09:22:08 +01:00
Russ Weas effc72042b Implement glob escaping for clean -p
Implement glob escaping for clean -p

Add pattern escape for glob matching cargo clean files

Implement correct solution for #10068

Removed superfluous formatting changes

Update rm_rf_glob()'s error handling

Remove dir_glob reference for non-glob function

Added test

Satisfy clippy

Add MSVC support for test
2021-11-16 16:55:23 -06:00
Basile Henry 3a5bb75467
Update tests/testsuite/cargo_alias_config.rs 2021-11-14 20:22:13 +00:00
Basile Henry 2ead2d9e3d
Update tests/testsuite/cargo_alias_config.rs 2021-11-14 20:22:05 +00:00
Basile Henry 9f768bbcd8 Update test for warning for alias shadowing an external subcommand 2021-11-14 20:38:40 +01:00
Joshua Nelson 8713cd7e69 Give a hard error if -Zrustdoc-scrape-examples is missing a flag
It's the same as if the flag wasn't passed, and it makes it difficult to
figure out why rustdoc isn't generating examples.
2021-11-05 09:07:15 -05:00
bors e3f2953bcb Auto merge of #10037 - willcrichton:example-analyzer, r=alexcrichton
Fix --scrape-examples-target-crate using package name (with dashes) instead of crate name (with underscores)

This PR fixes #10035.
2021-11-04 19:30:42 +00:00
Will Crichton 7ee3ffc7e6 Fix --scrape-examples-target-crate using package name (with dashes) instead of crate name (with underscores), closes #10035 2021-11-04 11:23:40 -07:00
bors 4cc3f4f193 Auto merge of #10017 - willcrichton:example-analyzer, r=alexcrichton
Change --scrape-examples flag to -Z rustdoc-scrape-examples

I'm working on getting the scrape examples feature working on docs.rs. However, docs.rs uses `cargo rustdoc` instead of `cargo doc`, and right now the `--scrape-examples` flag is only allowed for `cargo doc`. So this PR changes it to a `-Z` flag that can be passed to either command.
2021-10-29 14:07:40 +00:00
Will Crichton 9fb78cf698 Change --scrape-examples flag to -Z rustdoc-scrape-examples 2021-10-29 00:15:19 -07:00
bors 0a98b1de5c Auto merge of #9525 - willcrichton:example-analyzer, r=alexcrichton
Scrape code examples from examples/ directory for Rustdoc

Adds support for the functionality described in rust-lang/rfcs#3123

Matching changes to rustdoc are here: https://github.com/rust-lang/rust/pull/85833
2021-10-28 16:58:42 +00:00
Will Crichton 0a2382b6db Formatting 2021-10-28 00:38:16 -07:00
Will Crichton 11209570c9 Change scraping to apply to all workspace packages instead of just
root units. Only attach Docscrape unit dependencies to workspace Doc
units. Add test for scraping examples with complex reverse dependencies.
2021-10-28 00:35:34 -07:00