Commit graph

12427 commits

Author SHA1 Message Date
Scott Schafer 7063248b15 add cargo-features to unstable docs for workspace inheritance 2022-05-10 14:27:47 -05:00
bors b3f6772a66 Auto merge of #10646 - koic:use_rust_2021_prelude, r=epage
Use the traits added to the Rust 2021 Edition prelude

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

This PR uses the traits added to the Rust 2021 Edition prelude.

> The `TryInto`, `TryFrom` and `FromIterator` traits are now part of the prelude.

https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html
2022-05-10 16:48:05 +00:00
bors cc9e3014a3 Auto merge of #10594 - weihanglo:issue-10560, r=ehuss
Pass `--target` to `rustdoc` for `cargo test` if specified with host target.
2022-05-10 15:56:03 +00:00
Koichi ITO 1626762fe4 Use the traits added to the Rust 2021 Edition prelude
Follow up https://github.com/rust-lang/rust/pull/96861.

This PR uses the traits added to the Rust 2021 Edition prelude.

> The `TryInto`, `TryFrom` and `FromIterator` traits are now part of the prelude.

https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html
2022-05-10 21:46:45 +09:00
Weihang Lo ba2b250c2e
test: pass --target to rustdoc even if specified with host target 2022-05-10 16:56:19 +08:00
Weihang Lo 1f0d328a7e
Pass --target down to rustdoc if specified with host target 2022-05-10 16:56:19 +08:00
bors 9fa2bba679 Auto merge of #10281 - Gnurfos:depinfo_relative, r=ehuss
Fix use of .. in dep-info-basedir

### Summary

This allows setting, in .cargo/config's dep-info-basedir, some relative path that goes above the crate's directory.

### Motivation

In a setup like this:

```
repo_root
├── Makefile
├── some_c_things
│   └── foo.c
└── rust_things
    ├── Cargo.toml
    └─── src
        └── lib.rs
```

If you want the generated .d files to be includable directly in the Makefile (without post-processing), you need them to mention paths relative to the root, like:

rust_things/target/....: rust_things/src/lib.rs

### Implementation

For this you need to have relative paths with parent directories (in this case ..) in dep-info-basedir, which does not work without the change in this PR (due to render_filename doing only strip_prefix, while the basedir still contains literal ..s).

Let me know if this change is acceptable. Another implementation could be to canonicalize in ConfigRelativePath::resolve_path instead, especially since that struct outputs absolute paths. But that would have it access the filesystem, while it currently doesn't.
2022-05-07 19:49:54 +00:00
bors 7ed2769031 Auto merge of #10639 - catandcoder:master, r=ehuss
fix some typos
2022-05-07 17:54:05 +00:00
cuishuang 6f13c466d2 fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-05-08 01:07:28 +08:00
bors 9c61a3d10b Auto merge of #10638 - Muscraft:move-snapshot-tests, r=epage
Move snapshot tests into testsuite

This moves all tests from the `snapshot` folder into the `testsuite` folder as described by [this comment](https://github.com/rust-lang/cargo/pull/10631#discussion_r866306441). A macro was also added so there is no need to specify the path in a `snapshot` test just the file. This was done for ease of refactoring and ease of porting new tests to `snapshot`

close #10627

r? `@epage`
2022-05-07 02:14:00 +00:00
Scott Schafer 639f3bdea5 move all snapshot/init/ tests to testsuite/init/ 2022-05-06 20:51:49 -05:00
Scott Schafer 92fbc4e344 move all snapshot/cargo_add/ tests to testsuite/cargo_add/ 2022-05-06 20:51:29 -05:00
bors 6878c43e94 Auto merge of #10566 - Urgau:check-cfg-improvements, r=ehuss
Improve support of condition compilation checking

This PR is a series of improvements to the check-cfg implementation.

### What does this PR try to resolve?

This PR resolve the concern expressed in https://github.com/rust-lang/cargo/pull/10486#issuecomment-1096842314 that is:
 * Fixing the tests on Windows: e8aa51d8de
 * Merging all the -Z flags under -Zcheck-cfg: 969e282b8f
 * Moving of all of the check-cfg tests into a separate module: c18b442b30
 * And removing of an unused parameter: 068bdf4c06

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

This PR should be reviewed commit by commit and tested with the automated tests or examples.

### Additional information

I decided to use a custom macro to make the test functional under Windows, the macro generate a contains line with the correct escaping depending on the platform (windows or not windows).
2022-05-06 22:39:02 +00:00
Loïc BRANSTETT 6f2fae10ea Remove now unused context arg 2022-05-06 22:42:30 +02:00
Loïc BRANSTETT cf496db45e Re-enable check-cfg tests under windows with a custom macro for escaping 2022-05-06 22:42:30 +02:00
Loïc BRANSTETT 2d0ca84b0e Move check cfg tests to their own module 2022-05-06 22:42:28 +02:00
Loïc BRANSTETT 6a9f094c8c Convert the testsuite to use the new -Zcheck-cfg flag and syntax 2022-05-06 22:40:08 +02:00
Loïc BRANSTETT 43c193a833 Merge of unstable check-cfg cargo flags into -Zcheck-cfg 2022-05-06 22:40:08 +02:00
bors 08b8fe5c2d Auto merge of #10142 - jyn514:bin-private-link, r=ehuss
When documenting private items in a binary, ignore warnings about links to private items

Previously, rustdoc would warn about linking to private items in a binary, even
though cargo unconditionally documents private items in a binary.
This changes cargo to silence the warning, since it's only relevant in
cases where the private items might not be documented.

Fixes https://github.com/rust-lang/rust/issues/89600.
2022-05-06 19:48:59 +00:00
bors 0f75da631b Auto merge of #10582 - epage:pkgid, r=ehuss
Extend pkgid syntax with `@` support

In addition to `foo:1.2.3`, we now support `foo@1.2.3` for pkgids.  We
are also making it the default way of rendering pkgid's for the user.

### What does this PR try to resolve?

With cargo-add in #10472, we've decided to only use ``@`` in it and to add
it as an alternative to `:` in the rest of cargo.  `cargo-add`
originally used ``@`.`  When preparing it for merge, I switched to `:` to
be consistent with pkgids. When discussing this, it was felt ``@`` has
precedence in too many tools to switch to `:` but that we should instead
switch pkgid's to use ``@`,` in a backwards compatible way.  #10472 served
as the change proposal for this

See also
- https://internals.rust-lang.org/t/feedback-on-cargo-add-before-its-merged/16024/26?u=epage
- https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Multiple.20ways.20of.20specifying.20versions

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

The focus of the testing is on the parsers unit tests and on the end-to-end output.  We are not explicitly testing end-to-end input in this PR, assuming the unit tests are sufficient.

### Additional information

This only focuses on places we already accept pkgids.  Looking into supporting `foo@1.2.3` in `cargo install` and `cargo yank` is being left for a future PR.
2022-05-06 19:07:07 +00:00
bors acaf8e2613 Auto merge of #10631 - Muscraft:move-snapshot-tests, r=epage
move one `snapshot/add` test into `testsuite/cargo_add/`

This is an experiment with moving the test code related to a snapshot into the testsuite directory so it's easier to review.

- To kick the tire on these changes, a single test was ported

This is a step towards #10627.  A follow up will port all of the tests

r? `@epage`
2022-05-06 16:39:06 +00:00
Scott Schafer ea312988fb move a snapshot/add/ test into testsuite/cargo_add directory 2022-05-06 10:31:58 -05:00
bors 5b4b755cb6 Auto merge of #10605 - yoav-lavi:patch-1, r=ehuss
Add caveat for covering features

This section explains the caveats and possible solutions for features, detailing the tooling needed to 100% cover such a project.

The need for this PR is based on a conversation with `@Eh2406.`

Moved this PR here based on `@Eh2406's` comment: https://github.com/rust-lang/reference/pull/1195#issuecomment-1108968173
2022-05-05 20:55:23 +00:00
bors a2c71c5cc3 Auto merge of #10633 - hi-rustin:rustin-patch-docs-variables, r=epage
Improve CARGO_ENCODED_RUSTFLAGS and CARGO_ENCODED_RUSTDOCFLAGS variables docs

### What does this PR try to resolve?

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

It has been improved according to the three requirements in the issue.
2022-05-05 15:25:50 +00:00
hi-rustin 26a499b984 Improve CARGO_ENCODED_RUSTFLAGS and CARGO_ENCODED_RUSTDOCFLAGS variables docs
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-05-05 22:26:57 +08:00
bors 05a53e7293 Auto merge of #10629 - Muscraft:reorganize-snapshot-tests, r=epage
reorganize `snapshot` tests to better work in contexts that sort by extension

Changed snapshot file stricture from
```
<name>.in/
<name>.out/
<name>.stdout
<name>.stderr
```

To
```
<name>/in/
<name>/out/
<name>/stdout.log
<name>/stderr.log
```

This makes it easier to review and make changes when in contexts that sort by extension

close #10626

r? `@epage`
2022-05-04 14:42:24 +00:00
Scott Schafer 75612de83e remove tests/snapshots/copy.sh and tests/snapshots/rename.sh 2022-05-04 08:59:39 -05:00
Scott Schafer 0602320c6a reorganize snapshot tests for init to better work in contexts that sort by extension 2022-05-04 08:58:30 -05:00
Scott Schafer 87833663f4 reorganize snapshot tests for cargo-add to better work in contexts that sort by extension 2022-05-04 08:55:55 -05:00
bors a44758ac80 Auto merge of #10129 - jyn514:fetch-build-std, r=weihanglo
Add support for `-Zbuild-std` to `cargo fetch`

This allows downloading the dependencies for libstd in advance, which
can be useful in e.g. sandboxed build environments.

Fixes https://github.com/rust-lang/wg-cargo-std-aware/issues/22.

r? `@ehuss`
2022-05-04 02:29:34 +00:00
Joshua Nelson 55b680c194 Add support for -Zbuild-std to cargo fetch
This allows downloading the dependencies for libstd in advance, which
can be useful in e.g. sandboxed build environments.

- Abstract check for `--target` out into a function
- Try to abstract `test` special-casing into a function

  This avoids hard-coding crate names in multiple places.

- Unify handling of checks for `--target` in `BuildConfig::new`

  This makes sure it's checked consistently, without requiring each new command to check it explicitly.

- Share more code between `fetch` and `build` by adding `std_crates()`
- Warn about `--build-plan` and `-Zbuild-std` consistently, not just for `build`

  Currently only `build` uses build-plan. But cargo may choose to add it to new commands in the future (e.g. check and doc).
  Future-proof it, since it's simple to do.
2022-05-03 20:07:14 -05:00
Joshua Nelson 727baf0db1 When documenting private items in a binary, ignore warnings about links to private items
Previously, rustdoc would warn about linking to items in a binary, even
though cargo unconditionally documents private items in a binary.
This changes cargo to silence the warning, since it's only relevant in
cases where the private items might not be documented.
2022-05-03 20:03:44 -05:00
bors ad05cec893 Auto merge of #10620 - weihanglo:snapbox-cargo-init, r=epage
Migrate tests of `cargo-init` to snapbox

### What does this PR try to resolve?

An attempt of migrating tests of `cargo-init` to [snapbox](https://crates.io/crates/snapbox/).

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

To review this PR, you may compare the old and the new version one by one. Files not listed in `<test-name>.out` are not asserted, so please help me make sure we don't miss any essential file to check.

Some redundant tests are covered by other tests or renamed.

### Additional information

I won't say the process of the migration was pleasant, but overall it results to a higher coverage of output file changes. Here are steps I performed to migrate a test case:

1. Run the old test and observe its output layout. Recommend using a separate worktree to preserve the temporary test output files.
2. Read the test code to arrange its input fixture at `<test-name>.in`.
3. Copy the old output layout or hand-pick the output layout you need. You don't need to fill contents of those files. `snapbox` will do it for you.
4. Run `SNAPSHOTS=overwrite cargo test --test testsuite <your-test-filter>` to assert and generate snapshots.
5. Compare the old layout and the new layout to see if anything missing.

Something observations when dealing with the migration:

* snapbox hasn't yet support unordered assertion.
* snapbox cannot assert inexistence of a file (And probably never?).
* No performance hit so far (measured with hyperfine).
2022-05-04 00:02:04 +00:00
Weihang Lo 20c0c581f8
Note that .git folder cannot be tracked under a git repo 2022-05-04 06:32:02 +08:00
Yoav Lavi 3ac679599a
Update features.md 2022-05-03 13:36:15 +02:00
Weihang Lo aff8e810d1
Use snapbox assertion instead of old Project::cargo 2022-05-03 09:53:53 +08:00
Weihang Lo b3af6d8566
Make test fixture rustfmt.toml syntatically correct 2022-05-03 09:48:00 +08:00
Weihang Lo 0028bc2108
Rename .gitkeep to .keep
snapbox/trycmd won't copy ".keep" if present.

- <https://docs.rs/trycmd/0.13.4/trycmd/#in>
- <https://docs.rs/trycmd/0.13.4/trycmd/#out>
2022-05-03 08:44:54 +08:00
Weihang Lo c082116351
Add [EXE] substitution in snapshots 2022-05-02 08:43:53 +08:00
bors cfb89695d1 Auto merge of #10619 - klensy:te-up, r=weihanglo
dedupe toml_edit crate, followup #10603

Dedupe toml_edit crate versions, followup #10603
2022-05-02 00:39:25 +00:00
Weihang Lo 9171e18b72
Migrate tests of cargo-init to snapbox
Some redundant tests are merged or deleted.

- `gitignore_appended_not_replaced` -> `git_ignore_exists_no_conflicting_entries`
- `gitignore_added_newline_in_existing` -> `git_ignore_exists_no_conflicting_entries`
- `gitignore_no_newline_in_new` -> `simple_git`
- `terminating_newline_in_existing_git_ignore` -> `git_ignore_exists_no_conflicting_entries`
- `terminating_newline_in_new_git_ignore` -> `simple_git`
- `terminating_newline_in_new_mercurial_ignore` -> `simple_hg`
- `terminating_newline_in_existing_mercurial_ignore` -> `simple_hg_ignore_exists`
- `mercurial_added_newline_in_existing` -> `simple_hg_ignore_exists`
- `mercurial_no_newline_in_new` -> `simple_hg`
- `cargo_lock_gitignored_if_lib1` -> `simple_git`
- `cargo_lock_gitignored_if_lib2` -> `inferred_lib_with_git`
- `cargo_lock_not_gitignored_if_bin2` -> `inferred_bin_with_git`
- `cargo_lock_not_gitignored_if_bin1` -> `explicit_bin_with_git`
2022-05-02 08:16:06 +08:00
klensy 867a580f29 dedupe toml_edit crate, followup #10603 2022-05-02 03:10:38 +03:00
bors dc54f15dd3 Auto merge of #10618 - dtolnay-contrib:checkoutv3, r=ehuss
Update GitHub Actions actions/checkout@v2 to v3

The v2 implementation uses Node 12, which is end-of-life on April 30, 2022. See https://nodejs.org/en/about/releases/. Update to v3, which is based on Node 16 whose support lasts until April 30, 2024.

They made this a major version change (v2 to v3) because old GitHub Enterprise versions aren't necessarily compatible with Node 16, but for github.com-supplied runners (SaaS) there is no practical difference.
2022-04-30 21:26:16 +00:00
David Tolnay 30b26f2f7e
Update GitHub Actions actions/checkout@v2 to v3
The v2 implementation uses Node 12, which is end-of-life on April 30, 2022.
See https://nodejs.org/en/about/releases/. Update to v3, which is based on
Node 16 whose support lasts until April 30, 2024.
2022-04-30 13:46:35 -07:00
bors fb2532a6f4 Auto merge of #10581 - epage:snapbox, r=ehuss
Integrate snapbox in with cargo-test-support

### What does this PR try to resolve?

#10472 introduced snapbox to cargo's tests in the least intrusive manner by copying some cargo-test-support code.  Primarily, this PR works to de-duplicate that code.  Secondarily, it makes it possible for snapbox to be used by other cargo tests that can work with its more limited functionality compared to cargo-test-support.

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

This is broken down by commits for smaller chunks to look over with some extra details in some of the commit messages.

As this is effectively refactoring existing tests, them passing is sufficient for testing.  The main focus would be on any API design including if there are any practices that we used to do that this continues forward to snapbox that we shouldn't.

### Additional information

The cargo contributing guide also needs to be updated but I'm leaving that off for another PR once this is merged so we have a clearer idea of what the API will look like (less churn) and so we can focus the conversation for each PR.
2022-04-29 19:18:36 +00:00
bors 78b10d4e61 Auto merge of #10613 - weihanglo:issue-10612, r=epage
Fix zsh completion
2022-04-29 13:12:32 +00:00
Weihang Lo f7cca286cc
Fix zsh completion 2022-04-29 14:13:18 +08:00
bors e019061ea8 Auto merge of #10611 - Muscraft:workspace-inheritance-documentaion, r=epage
Update documentation for workspace inheritance

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

This updates documentation about workspace inheritance in the Cargo Book. This is meant to move the documentation into a state that is acceptable to move after stabilization. It currently proposes adding sections to `workspaces.md` and `specifying-dependencies.md`.

r? `@epage`
2022-04-28 19:29:10 +00:00
Scott Schafer 9ed3276bf4 Update documentation for workspace inheritance 2022-04-28 14:19:56 -05:00
bors f63f23ff1f Auto merge of #10609 - Muscraft:move-unstable-workspace-docs, r=epage
move workspace inheritance untable docs to the correct place

Workspace inheritance unstable docs were under `Stabilized and removed features`. This moves them to the correct location

r? `@epage`
2022-04-28 03:15:50 +00:00