]> git.proxmox.com Git - cargo.git/log
cargo.git
2 years agoRegistry functions return task::Poll to enable parallel fetching of index data.
Arlo Siemsen [Mon, 8 Nov 2021 21:56:44 +0000 (13:56 -0800)]
Registry functions return task::Poll to enable parallel fetching of index data.

2 years agoAuto merge of #10395 - jonhoo:fix-10206, r=alexcrichton
bors [Mon, 28 Feb 2022 19:29:07 +0000 (19:29 +0000)]
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".

2 years agoAuto merge of #10425 - epage:search, r=alexcrichton
bors [Mon, 28 Feb 2022 17:15:55 +0000 (17:15 +0000)]
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

2 years agoAuto merge of #10428 - Urgau:check-cfg-features-rustdoc, r=ehuss
bors [Sun, 27 Feb 2022 19:20:56 +0000 (19:20 +0000)]
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`

2 years agoAuto merge of #10388 - weihanglo:issue-10356, r=ehuss
bors [Sun, 27 Feb 2022 18:33:14 +0000 (18:33 +0000)]
Auto merge of #10388 - weihanglo:issue-10356, r=ehuss

Override target crate-type for `cargo rustc --crate-type`

2 years agoAuto merge of #10167 - hi-rustin:rustin-patch-test, r=ehuss
bors [Sun, 27 Feb 2022 17:48:39 +0000 (17:48 +0000)]
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.

2 years agoAuto merge of #10429 - cuviper:config-verbosity, r=ehuss
bors [Sun, 27 Feb 2022 00:25:16 +0000 (00:25 +0000)]
Auto merge of #10429 - cuviper:config-verbosity, r=ehuss

Fix term.verbose without quiet, and vice versa

The match pattern only looked for `Some(false)`, missing `None`.

2 years agoFix term.verbose without quiet, and vice versa
Josh Stone [Sat, 26 Feb 2022 22:17:00 +0000 (14:17 -0800)]
Fix term.verbose without quiet, and vice versa

The match pattern only looked for `Some(false)`, missing `None`.

2 years agoAdd -Z check-cfg-features support for rustdoc
Loïc BRANSTETT [Fri, 25 Feb 2022 14:59:39 +0000 (15:59 +0100)]
Add -Z check-cfg-features support for rustdoc

2 years agoCheck 1.60 behavior
hi-rustin [Sat, 26 Feb 2022 11:24:48 +0000 (19:24 +0800)]
Check 1.60 behavior

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoSkip avoids_split_debuginfo_collision on stable
hi-rustin [Wed, 12 Jan 2022 09:09:13 +0000 (17:09 +0800)]
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>
2 years agoUse 1.51.0 in old cargos test
hi-rustin [Sun, 5 Dec 2021 03:36:56 +0000 (11:36 +0800)]
Use 1.51.0 in old cargos test

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoAuto merge of #10426 - hi-rustin:rustin-patch-clippy, r=weihanglo
bors [Sat, 26 Feb 2022 06:01:59 +0000 (06:01 +0000)]
Auto merge of #10426 - hi-rustin:rustin-patch-clippy, r=weihanglo

Make clippy happy

Remove useless borrows.

2 years agoMake clippy happy
hi-rustin [Sat, 26 Feb 2022 04:55:27 +0000 (12:55 +0800)]
Make clippy happy

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agofeat(search): Highlight search term
Ed Page [Sat, 26 Feb 2022 02:07:17 +0000 (20:07 -0600)]
feat(search): Highlight search term

This supersedes #10116

Fixes #9918

2 years agoOverride target crate-type for `cargo rustc --crate-type`
Weihang Lo [Sun, 13 Feb 2022 09:51:10 +0000 (17:51 +0800)]
Override target crate-type for `cargo rustc --crate-type`

Instead of writing override rules all over the compilation logic, this
commit simply override the unit created by `generate_targets`.
As a result, `cargo rustc --crate-type` behaves exactly as expected.

2 years agoNew test for `cargo rustc --crate-type` with dependency
Weihang Lo [Sun, 13 Feb 2022 09:42:12 +0000 (17:42 +0800)]
New test for `cargo rustc --crate-type` with dependency

2 years agoAvoid assertion against default value in crate-type tests
Weihang Lo [Sun, 13 Feb 2022 09:33:30 +0000 (17:33 +0800)]
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.

2 years agorefactor(search): Use noop version of new write_stdout
Ed Page [Sat, 26 Feb 2022 01:37:42 +0000 (19:37 -0600)]
refactor(search): Use noop version of new write_stdout

2 years agofeat(shell): General output support
Ed Page [Sat, 26 Feb 2022 01:22:17 +0000 (19:22 -0600)]
feat(shell): General output support

This provides a more general approach for writing output.  This will
respect the users choice for output support but the user must check the
verbosity if its relevant to their output.

2 years agotest(search): Ensure we maintain quiet behavior
Ed Page [Sat, 26 Feb 2022 01:10:48 +0000 (19:10 -0600)]
test(search): Ensure we maintain quiet behavior

2 years agoAuto merge of #10372 - weihanglo:issue-9325, r=ehuss
bors [Fri, 25 Feb 2022 18:08:41 +0000 (18:08 +0000)]
Auto merge of #10372 - weihanglo:issue-9325, r=ehuss

Test: ensure dep-infos do not collide when cdylib and bin coexist

2 years agoAuto merge of #10420 - ehuss:version-bump, r=alexcrichton
bors [Fri, 25 Feb 2022 15:11:31 +0000 (15:11 +0000)]
Auto merge of #10420 - ehuss:version-bump, r=alexcrichton

Bump to 0.62.0, update changelog

2 years agoAvoid #[cfg] duplicated main in tests
Jon Gjengset [Thu, 24 Feb 2022 23:17:31 +0000 (15:17 -0800)]
Avoid #[cfg] duplicated main in tests

It makes the logic really hard to follow.

2 years agoImprove precision of host build.rustflags tests
Jon Gjengset [Thu, 24 Feb 2022 22:56:46 +0000 (14:56 -0800)]
Improve precision of host build.rustflags tests

2 years agoMake docs more accurate
Jon Gjengset [Thu, 24 Feb 2022 22:56:23 +0000 (14:56 -0800)]
Make docs more accurate

2 years agoMake rustflags/rustdocflags an enum
Jon Gjengset [Thu, 24 Feb 2022 22:56:09 +0000 (14:56 -0800)]
Make rustflags/rustdocflags an enum

2 years agoUpdate changelog for 1.60
Eric Huss [Thu, 24 Feb 2022 22:18:15 +0000 (14:18 -0800)]
Update changelog for 1.60

2 years agoBump to 0.62.0
Eric Huss [Thu, 24 Feb 2022 21:47:20 +0000 (13:47 -0800)]
Bump to 0.62.0

2 years agoAuto merge of #10416 - Eh2406:less_mut, r=alexcrichton
bors [Thu, 24 Feb 2022 19:18:05 +0000 (19:18 +0000)]
Auto merge of #10416 - Eh2406:less_mut, r=alexcrichton

Some small clean ups.

Just some small changes I noticed while exploring the code base.
The only thing nontrivial was noticing that get_registry_index already calls validate_package_name.

2 years agofmt
Jacob Finkelman [Thu, 24 Feb 2022 18:28:15 +0000 (18:28 +0000)]
fmt

2 years agoHashMap::from not into
Jacob Finkelman [Thu, 24 Feb 2022 18:24:33 +0000 (18:24 +0000)]
HashMap::from not into

2 years agoUnify logic of legacy and non-legacy code paths
Jon Gjengset [Thu, 24 Feb 2022 17:33:38 +0000 (09:33 -0800)]
Unify logic of legacy and non-legacy code paths

2 years agoAuto merge of #10417 - davidpaulmcintyre:cargo-test-doc, r=alexcrichton
bors [Thu, 24 Feb 2022 15:12:24 +0000 (15:12 +0000)]
Auto merge of #10417 - davidpaulmcintyre:cargo-test-doc, r=alexcrichton

Documentation change to cargo-test.md

i added helpful links in the src/man/carg-test.md to show reader how to write unit/integration tests.

i made change to source at src/doc/man/cargo-test.md, then ran
mdbook serve
./build-man.sh
cargo fmt —all

i tested links by viewing md page and its linked pages using mdbook serve

<img width="960" alt="Screen Shot 2022-02-23 at 5 03 31 PM" src="https://user-images.githubusercontent.com/10999581/155435822-f4784513-5b0f-4e2c-8cf1-ede613f64e15.png">

2 years agoHandle host.rustdocflags
Jon Gjengset [Thu, 24 Feb 2022 00:45:09 +0000 (16:45 -0800)]
Handle host.rustdocflags

2 years agomove changes to man files
David McIntyre [Thu, 24 Feb 2022 00:42:20 +0000 (19:42 -0500)]
move changes to man files

2 years agoDon't == true
Jon Gjengset [Thu, 24 Feb 2022 00:36:53 +0000 (16:36 -0800)]
Don't == true

2 years agoMake rustflags logic more linear
Jon Gjengset [Thu, 24 Feb 2022 00:36:14 +0000 (16:36 -0800)]
Make rustflags logic more linear

2 years agoRemove env_var from test names that don't use env
Jon Gjengset [Thu, 24 Feb 2022 00:35:41 +0000 (16:35 -0800)]
Remove env_var from test names that don't use env

2 years agodon't need mut
Jacob Finkelman [Wed, 23 Feb 2022 20:46:51 +0000 (20:46 +0000)]
don't need mut

2 years agofix relative link path
David McIntyre [Wed, 23 Feb 2022 22:00:31 +0000 (17:00 -0500)]
fix relative link path

2 years agoinitial commit
David McIntyre [Wed, 23 Feb 2022 21:17:51 +0000 (16:17 -0500)]
initial commit

2 years agodont call validate_package_name when get_registry_index alredy does it.
Jacob Finkelman [Wed, 23 Feb 2022 20:46:13 +0000 (20:46 +0000)]
dont call validate_package_name when get_registry_index alredy does it.

2 years ago&String -> &str
Jacob Finkelman [Wed, 23 Feb 2022 19:43:29 +0000 (19:43 +0000)]
&String -> &str

2 years agoAuto merge of #10411 - ehuss:fix-rustflags-gate, r=alexcrichton
bors [Tue, 22 Feb 2022 19:55:51 +0000 (19:55 +0000)]
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.

2 years agoAuto merge of #10408 - Urgau:check-cfg-features, r=alexcrichton
bors [Tue, 22 Feb 2022 19:12:30 +0000 (19:12 +0000)]
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 [..]

2 years agoAdd common profile validation.
Eric Huss [Tue, 22 Feb 2022 18:50:18 +0000 (10:50 -0800)]
Add common profile validation.

2 years agoAuto merge of #10401 - ehuss:target-dep-doc-fix, r=alexcrichton
bors [Tue, 22 Feb 2022 18:36:30 +0000 (18:36 +0000)]
Auto merge of #10401 - ehuss:target-dep-doc-fix, r=alexcrichton

Remove invalid target-specific dependency example.

The example with disjoint target configs does not work (and AFAIK has never worked).  It fails with the error:

```
  Dependency 'native' has different source paths depending on the build target. Each dependency must have a single canonical source path irrespective of build target.
```

This removes it to avoid confusion.

cc #7753

2 years agoAdd test for -Z check-cfg-features with namespaced features
Loïc BRANSTETT [Tue, 22 Feb 2022 17:43:12 +0000 (18:43 +0100)]
Add test for -Z check-cfg-features with namespaced features

2 years agoDisable -Z check-cfg-features tests on windows due to weird normalization issues
Loïc BRANSTETT [Tue, 22 Feb 2022 17:33:03 +0000 (18:33 +0100)]
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/")"

2 years agoRemove invalid target-specific dependency example.
Eric Huss [Sun, 20 Feb 2022 16:10:31 +0000 (08:10 -0800)]
Remove invalid target-specific dependency example.

2 years agoAuto merge of #10398 - piggynl:cargo-doc-fixes-1, r=weihanglo
bors [Tue, 22 Feb 2022 17:18:24 +0000 (17:18 +0000)]
Auto merge of #10398 - piggynl:cargo-doc-fixes-1, r=weihanglo

Fix errors in `cargo fetch` usage guide

This is a recreation of #9785.

1. By [the doc](https://doc.rust-lang.org/cargo/commands/cargo-build.html#manifest-options), `cargo build` will always access the network unless `--frozen` or `--offline` is present. Instead, `cargo fetch` will fetch dependencies, and which will allow running subsequent Cargo commands in offline mode.

2. A general template was used for `--target` that is not appropriate for `cargo fetch`.

2 years agoAdd -Z check-cfg-features to enable compile-time checking of features
Loïc BRANSTETT [Tue, 22 Feb 2022 12:37:56 +0000 (13:37 +0100)]
Add -Z check-cfg-features to enable compile-time checking of features

2 years agoAuto merge of #10404 - ehuss:fix-config-broken-links, r=alexcrichton
bors [Tue, 22 Feb 2022 14:57:08 +0000 (14:57 +0000)]
Auto merge of #10404 - ehuss:fix-config-broken-links, r=alexcrichton

Fix some broken doc links.

This fixes a few links in the config chapter that weren't linking correctly.

2 years agoAuto merge of #9992 - Byron:rfc-3028, r=ehuss
bors [Tue, 22 Feb 2022 03:56:46 +0000 (03:56 +0000)]
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](https://github.com/rust-lang/cargo/blob/00e925f61fbd9f2d956046aea5af6b7636ab2931/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)

2 years agoadd support for artifact dependencies (#9096)
Sebastian Thiel [Thu, 21 Oct 2021 09:57:23 +0000 (17:57 +0800)]
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

bd45ac81ba062a7daa3b0178dfcb6fd5759a943c

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:
https://github.com/rust-lang/cargo/blob/c0e6abe384c2c6282bdd631e2f2a3b092043e6c6/src/cargo/core/compiler/unit_dependencies.rs#L1119
.

Simplify filtering.

2 years agoFix some broken doc links.
Eric Huss [Mon, 21 Feb 2022 18:45:31 +0000 (10:45 -0800)]
Fix some broken doc links.

2 years agoFix up doc to reflect latest semantics change
Jon Gjengset [Mon, 21 Feb 2022 18:28:50 +0000 (10:28 -0800)]
Fix up doc to reflect latest semantics change

2 years agoRetain legacy behavior with tath != false
Jon Gjengset [Mon, 21 Feb 2022 18:20:32 +0000 (10:20 -0800)]
Retain legacy behavior with tath != false

2 years agoAuto merge of #10346 - yerke:yerke/no-run-test-executable-path, r=ehuss
bors [Sun, 20 Feb 2022 15:47:58 +0000 (15:47 +0000)]
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.

2 years agoEnable propagating rustflags to build scripts
Jon Gjengset [Wed, 16 Feb 2022 23:35:53 +0000 (15:35 -0800)]
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.

2 years agoAdd regression test for #10206
Jon Gjengset [Wed, 16 Feb 2022 23:59:26 +0000 (15:59 -0800)]
Add regression test for #10206

2 years agoSimplify unused build scripts in tests
Jon Gjengset [Thu, 17 Feb 2022 18:22:03 +0000 (10:22 -0800)]
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.

2 years agoRun target-applies-to-host tests on stable
Jon Gjengset [Thu, 17 Feb 2022 18:10:53 +0000 (10:10 -0800)]
Run target-applies-to-host tests on stable

2 years agoFix errors in `cargo fetch` usage guide
Piggy NL [Thu, 17 Feb 2022 16:26:40 +0000 (00:26 +0800)]
Fix errors in `cargo fetch` usage guide

Co-authored-by: Caleb Maclennan <caleb@alerque.com>
2 years agoAuto merge of #10396 - jonhoo:clap-deprecations, r=epage
bors [Thu, 17 Feb 2022 15:27:59 +0000 (15:27 +0000)]
Auto merge of #10396 - jonhoo:clap-deprecations, r=epage

Avoid new deprecation warnings from clap 3.1.0

### What does this PR try to resolve?

This fixes a number of new deprecations in [clap 3.1.0](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md#310---2022-02-16) that are currently causing CI to fail for all other PRs due to `-Dwarnings`.

2 years agoTidy up subcommand logic slightly
Jon Gjengset [Thu, 17 Feb 2022 04:04:19 +0000 (20:04 -0800)]
Tidy up subcommand logic slightly

2 years agoMatch semantics of SubcommandRequiredElseHelp
Jon Gjengset [Thu, 17 Feb 2022 04:03:00 +0000 (20:03 -0800)]
Match semantics of SubcommandRequiredElseHelp

2 years agoBump clap to match when deprecations happened
Jon Gjengset [Thu, 17 Feb 2022 04:01:57 +0000 (20:01 -0800)]
Bump clap to match when deprecations happened

2 years agoAvoid new deprecation warnings from clap 3.1.0
Jon Gjengset [Thu, 17 Feb 2022 00:25:58 +0000 (16:25 -0800)]
Avoid new deprecation warnings from clap 3.1.0

2 years agoAuto merge of #10379 - weihanglo:issue-10370, r=alexcrichton
bors [Tue, 15 Feb 2022 04:24:07 +0000 (04:24 +0000)]
Auto merge of #10379 - weihanglo:issue-10370, r=alexcrichton

cargo-new should not add ignore rule on Cargo.lock inside subdirs

2 years agoAuto merge of #10385 - hi-rustin:rustin-patch-badge, r=alexcrichton
bors [Mon, 14 Feb 2022 15:12:49 +0000 (15:12 +0000)]
Auto merge of #10385 - hi-rustin:rustin-patch-badge, r=alexcrichton

Add a badge for github actions

Follow up https://github.com/rust-lang/cargo/pull/10380

See: https://github.com/rust-lang/cargo/pull/10380#issuecomment-1036321131

2 years agoAdd a badge for github actions
hi-rustin [Sat, 12 Feb 2022 10:01:45 +0000 (18:01 +0800)]
Add a badge for github actions

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoAuto merge of #10380 - hi-rustin:rustin-patch-badges, r=alexcrichton
bors [Fri, 11 Feb 2022 15:16:28 +0000 (15:16 +0000)]
Auto merge of #10380 - hi-rustin:rustin-patch-badges, r=alexcrichton

Remove outdated badges

We seem to have abandoned it early on.

2 years agoRemove outdated badges
hi-rustin [Fri, 11 Feb 2022 13:41:23 +0000 (21:41 +0800)]
Remove outdated badges

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoTest for cargo new/init autodetct and ignore file rules
Weihang Lo [Fri, 11 Feb 2022 10:49:35 +0000 (18:49 +0800)]
Test for cargo new/init autodetct and ignore file rules

2 years agocargo-new should not add ignore rule on Cargo.lock inside subdirs
Weihang Lo [Fri, 11 Feb 2022 10:48:25 +0000 (18:48 +0800)]
cargo-new should not add ignore rule on Cargo.lock inside subdirs

Have traced down the issue. It feel like the original intent is to
ignore `Cargo.lock` and `target` at project root but not subdirectories.

1. The original implementation did ignore root `/Cargo.lock`.
   https://github.com/rust-lang/cargo/pull/321
2. Someday one wanted to support both gitignore and hgingore's syntax
   and removed the leading slash.
   https://github.com/rust-lang/cargo/pull/1247
3. Later, one found that we should not ignore `target` other than
   under root directory and added `/target` back.
   https://github.com/rust-lang/cargo/pull/4099
4. It turns out that the syntax is not compatible between gitignore
   and hgignore. Therefore, one started to use hgignore special syntax
   to handle `Cargo.lock`.
   https://github.com/rust-lang/cargo/pull/4342

This commit rollbacks to what original implementation tries to do.

2 years agoAuto merge of #10376 - joshtriplett:strip-no-off, r=alexcrichton
bors [Wed, 9 Feb 2022 22:08:49 +0000 (22:08 +0000)]
Auto merge of #10376 - joshtriplett:strip-no-off, r=alexcrichton

Remove `strip = "off"` (and undocumented `strip = "n"`/`strip = "no"`)

2 years agoRemove `strip = "off"` (and undocumented `strip = "n"`/`strip = "no"`)
Josh Triplett [Wed, 9 Feb 2022 21:44:38 +0000 (13:44 -0800)]
Remove `strip = "off"` (and undocumented `strip = "n"`/`strip = "no"`)

The `strip` option allows the string `"off"`, which `rustc` doesn't
have, and maps it to `"none"`. Remove that equivalent, and just keep
`"none"`.

Simplify and clarify the documentation for `strip` accordingly.

`strip` reused the `is_off` function from `lto`, which also had the net
effect of allowing `"n"` and `"no"`, which weren't documented as
supported. This change drops those as well.

2 years agoAuto merge of #10375 - tmandry:patch-1, r=alexcrichton
bors [Wed, 9 Feb 2022 20:04:06 +0000 (20:04 +0000)]
Auto merge of #10375 - tmandry:patch-1, r=alexcrichton

Fix unmatched backticks

2 years agoFix unmatched backticks
Tyler Mandry [Wed, 9 Feb 2022 19:50:03 +0000 (11:50 -0800)]
Fix unmatched backticks

2 years agoAuto merge of #10371 - hi-rustin:rustin-patch-rustup-link, r=ehuss
bors [Tue, 8 Feb 2022 14:55:05 +0000 (14:55 +0000)]
Auto merge of #10371 - hi-rustin:rustin-patch-rustup-link, r=ehuss

Add rustup link

I think it might be better to add a link for rustup.

2 years agoTest: ensure dep-infos do not collide when cdylib and bin coexist
Weihang Lo [Tue, 8 Feb 2022 14:13:33 +0000 (22:13 +0800)]
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.

2 years agoAdd rustup link
hi-rustin [Tue, 8 Feb 2022 14:09:56 +0000 (22:09 +0800)]
Add rustup link

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoAuto merge of #10365 - itsjohncs:completion-speedup, r=alexcrichton
bors [Mon, 7 Feb 2022 15:47:24 +0000 (15:47 +0000)]
Auto merge of #10365 - itsjohncs:completion-speedup, r=alexcrichton

Improve startup time of bash completion.

`cargo list` takes about .15 seconds on my computer which is
substantial enough to be the slowest command run when my shell starts
according to [sstephenson's bashprof](https://github.com/sstephenson/bashprof).

This commit defers running `cargo list` until we need it for the first
time.

# Testing

After starting a new shell (which has loaded cargo's bash completion)
type `cargo <TAB><TAB>` and see the output matches the output prior to
this change (ie: the commands given by `cargo list`). You should
observe a small delay. You should observe no such delay on subsequent
attempts within the same session.

2 years agoImprove startup time of bash completion.
itsjohncs [Sun, 6 Feb 2022 23:45:57 +0000 (15:45 -0800)]
Improve startup time of bash completion.

`cargo list` takes about .15 seconds on my computer which is
substantial enough to be the slowest command run when my shell starts
according to sstephenson's bashprof.

This commit defers running `cargo list` until we need it for the first
time.

2 years agoAuto merge of #10245 - joshtriplett:stabilize-timings, r=joshtriplett
bors [Sat, 5 Feb 2022 04:45:49 +0000 (04:45 +0000)]
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.

2 years agoAuto merge of #10360 - hi-rustin:rustin-patch-clippy, r=alexcrichton
bors [Fri, 4 Feb 2022 15:14:30 +0000 (15:14 +0000)]
Auto merge of #10360 - hi-rustin:rustin-patch-clippy, r=alexcrichton

Remove needless borrow

Make clippy happy.

2 years agoRemove needless borrow
hi-rustin [Fri, 4 Feb 2022 02:46:44 +0000 (10:46 +0800)]
Remove needless borrow

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoAuto merge of #10341 - hi-rustin:rustin-patch-doc-deps, r=ehuss
bors [Thu, 3 Feb 2022 17:53:13 +0000 (17:53 +0000)]
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.

2 years agoInline non_custom_build_and_non_transitive_deps
hi-rustin [Thu, 3 Feb 2022 12:43:23 +0000 (20:43 +0800)]
Inline non_custom_build_and_non_transitive_deps

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agodisplay bench exec info differently
Yerkebulan Tulibergenov [Wed, 2 Feb 2022 16:17:09 +0000 (08:17 -0800)]
display bench exec info differently

2 years agoAuto merge of #10349 - epage:install, r=ehuss
bors [Tue, 1 Feb 2022 01:32:48 +0000 (01:32 +0000)]
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.

2 years agoAuto merge of #10348 - epage:vendor, r=alexcrichton
bors [Mon, 31 Jan 2022 19:16:05 +0000 (19:16 +0000)]
Auto merge of #10348 - epage:vendor, r=alexcrichton

fix(vendor): Use tables for sample config

Fixes #10345

2 years agoadd short path name for executables
Yerkebulan Tulibergenov [Mon, 31 Jan 2022 18:37:02 +0000 (10:37 -0800)]
add short path name for executables

2 years agoAuto merge of #10347 - a1phyr:patch-1, r=weihanglo
bors [Mon, 31 Jan 2022 18:35:04 +0000 (18:35 +0000)]
Auto merge of #10347 - a1phyr:patch-1, r=weihanglo

Add bash completion for `cargo clippy`

### What does this PR try to resolve?

Having shell completion on `cargo clippy` is useful

2 years agoAuto merge of #10337 - WaffleLapkin:merge_futures_with_all_features, r=alexcrichton
bors [Mon, 31 Jan 2022 17:52:10 +0000 (17:52 +0000)]
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

2 years agoAuto merge of #10350 - epage:edit, r=alexcrichton
bors [Mon, 31 Jan 2022 17:06:50 +0000 (17:06 +0000)]
Auto merge of #10350 - epage:edit, r=alexcrichton

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.

I included the `Cargo.toml` change to ensure any existing lock files on people's machines get updated so the test won't mysteriously start failing for them when doing a `pull`.

2 years agotest: Fix compatibilty with new toml_edit
Ed Page [Mon, 31 Jan 2022 13:21:44 +0000 (07:21 -0600)]
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.

2 years agofix(install): Keep v1 file formatting the same
Ed Page [Mon, 31 Jan 2022 13:21:44 +0000 (07:21 -0600)]
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.