]> git.proxmox.com Git - cargo.git/log
cargo.git
2 years agoAuto merge of #10717 - jsitnicki:respect-git-submod-update-none, r=epage
bors [Tue, 7 Jun 2022 14:29:02 +0000 (14:29 +0000)]
Auto merge of #10717 - jsitnicki:respect-git-submod-update-none, r=epage

Respect submodule update=none strategy in .gitmodules

Git lets users define the default update/checkout strategy for a submodule
by setting the `submodule.<name>.update` key in `.gitmodules` file.

If the update strategy is `none`, the submodule will be skipped during
update. It will not be fetched and checked out:

1. *foo* is a big git repo

```
/tmp $ git init foo
Initialized empty Git repository in /tmp/foo/.git/
/tmp $ dd if=/dev/zero of=foo/big bs=1000M count=1
1+0 records in
1+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 0.482087 s, 2.2 GB/s
/tmp $ git -C foo add big
/tmp $ git -C foo commit -m 'I am big'
[main (root-commit) 84fb533] I am big
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 big
```

2. *bar* is a repo with a big submodule with `update=none`

```
/tmp $ git init bar
Initialized empty Git repository in /tmp/bar/.git/
/tmp $ git -C bar submodule add file:///tmp/foo foo
Cloning into '/tmp/bar/foo'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 1 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), 995.50 KiB | 338.00 KiB/s, done.
/tmp $ git -C bar config --file .gitmodules submodule.foo.update none
/tmp $ cat bar/.gitmodules
[submodule "foo"]
        path = foo
        url = file:///tmp/foo
        update = none
/tmp $ git -C bar commit --all -m 'I have a big submodule with update=none'
[main (root-commit) 6c355ea] I have a big submodule not updated by default
 2 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 foo
```

3. *baz* is a clone of *bar*, notice *foo* submodule gets skipped

```
/tmp $ git clone --recurse-submodules file:///tmp/bar baz
Cloning into 'baz'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Submodule 'foo' (file:///tmp/foo) registered for path 'foo'
Skipping submodule 'foo'
/tmp $ git -C baz submodule update --init
Skipping submodule 'foo'
/tmp $
```

Cargo, on the other hand, ignores the submodule update strategy set in
`.gitmodules` properties when updating dependencies. Such behavior can
be considered against the wish of the crate publisher.

4. *bar* is now a lib with a big submodule with update disabled

```
/tmp $ cargo init --lib bar
     Created library package
/tmp $ git -C bar add .
/tmp $ git -C bar commit -m 'I am a lib with a big submodule but update=none'
[main eb07cf7] I am a lib with a big submodule but update=none
 3 files changed, 18 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 Cargo.toml
 create mode 100644 src/lib.rs
/tmp $
```

5. *qux* depends on *bar*, notice *bar*'s submodules are fetched

```
/tmp $ cargo init qux && cd qux
     Created binary (application) package
/tmp/qux $ echo -e '[dependencies.bar]\ngit = "file:///tmp/bar"' >> Cargo.toml
/tmp/qux $ time cargo update
    Updating git repository `file:///tmp/bar`
    Updating git submodule `file:///tmp/foo`

real    0m22.182s
user    0m20.402s
sys     0m1.714s
/tmp/qux $
```

Fix it by checking if a Git repository submodule should be updated when
cargo processes dependencies.

6. With the change applied, submodules with `update=none` are skipped

```
/tmp/qux $ cargo cache -a > /dev/null
/tmp/qux $ time ~/src/cargo/target/debug/cargo update
    Updating git repository `file:///tmp/bar`
    Skipping git submodule `file:///tmp/foo`

real    0m0.029s
user    0m0.021s
sys     0m0.008s
/tmp/qux $
```

Fixes #4247.

2 years agoRespect submodule update=none strategy in .gitmodules
Jakub Sitnicki [Tue, 31 May 2022 08:36:50 +0000 (10:36 +0200)]
Respect submodule update=none strategy in .gitmodules

Git lets users define the default update/checkout strategy for a submodule
by setting the `submodule.<name>.update` key in `.gitmodules` file.

If the update strategy is `none`, the submodule will be skipped during
update. It will not be fetched and checked out:

1. *foo* is a big git repo

```
/tmp $ git init foo
Initialized empty Git repository in /tmp/foo/.git/
/tmp $ dd if=/dev/zero of=foo/big bs=1000M count=1
1+0 records in
1+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 0.482087 s, 2.2 GB/s
/tmp $ git -C foo add big
/tmp $ git -C foo commit -m 'I am big'
[main (root-commit) 84fb533] I am big
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 big
```

2. *bar* is a repo with a big submodule with `update=none`

```
/tmp $ git init bar
Initialized empty Git repository in /tmp/bar/.git/
/tmp $ git -C bar submodule add file:///tmp/foo foo
Cloning into '/tmp/bar/foo'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 1 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), 995.50 KiB | 338.00 KiB/s, done.
/tmp $ git -C bar config --file .gitmodules submodule.foo.update none
/tmp $ cat bar/.gitmodules
[submodule "foo"]
        path = foo
        url = file:///tmp/foo
        update = none
/tmp $ git -C bar commit --all -m 'I have a big submodule with update=none'
[main (root-commit) 6c355ea] I have a big submodule not updated by default
 2 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 foo
```

3. *baz* is a clone of *bar*, notice *foo* submodule gets skipped

```
/tmp $ git clone --recurse-submodules file:///tmp/bar baz
Cloning into 'baz'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Submodule 'foo' (file:///tmp/foo) registered for path 'foo'
Skipping submodule 'foo'
/tmp $ git -C baz submodule update --init
Skipping submodule 'foo'
/tmp $
```

Cargo, on the other hand, ignores the submodule update strategy set in
`.gitmodules` properties when updating dependencies. Such behavior can
be considered against the wish of the crate publisher.

4. *bar* is now a lib with a big submodule with update disabled

```
/tmp $ cargo init --lib bar
     Created library package
/tmp $ git -C bar add .
/tmp $ git -C bar commit -m 'I am a lib with a big submodule but update=none'
[main eb07cf7] I am a lib with a big submodule but update=none
 3 files changed, 18 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 Cargo.toml
 create mode 100644 src/lib.rs
/tmp $
```

5. *qux* depends on *bar*, notice *bar*'s submodules are fetched

```
/tmp $ cargo init qux && cd qux
     Created binary (application) package
/tmp/qux $ echo -e '[dependencies.bar]\ngit = "file:///tmp/bar"' >> Cargo.toml
/tmp/qux $ time cargo update
    Updating git repository `file:///tmp/bar`
    Updating git submodule `file:///tmp/foo`

real    0m22.182s
user    0m20.402s
sys     0m1.714s
/tmp/qux $
```

Fix it by checking if a Git repository submodule should be updated when
cargo processes dependencies.

6. With the change applied, submodules with `update=none` are skipped

```
/tmp/qux $ cargo cache -a > /dev/null
/tmp/qux $ time ~/src/cargo/target/debug/cargo update
    Updating git repository `file:///tmp/bar`
    Skipping git submodule `file:///tmp/foo`

real    0m0.029s
user    0m0.021s
sys     0m0.008s
/tmp/qux $
```

Fixes #4247.

Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
2 years agoAuto merge of #10713 - flip1995:rust-version-env, r=epage
bors [Mon, 6 Jun 2022 13:19:38 +0000 (13:19 +0000)]
Auto merge of #10713 - flip1995:rust-version-env, r=epage

Expose rust-version through env var

This adds another env var that is exposed by cargo. In Clippy we would like to use that in order to efficiently check if a rust-version is set for the current package: https://github.com/rust-lang/rust-clippy/pull/8774

Currently we either have to parse the `Cargo.toml` file ourselves or use the `cargo_metadata` crate which has a notable performance impact when running `clippy-driver` on single files.

2 years agoExpose rust-version through env var
flip1995 [Sat, 28 May 2022 16:41:41 +0000 (18:41 +0200)]
Expose rust-version through env var

2 years agoAuto merge of #10676 - djmcgill:origin/master, r=weihanglo
bors [Sun, 5 Jun 2022 23:03:21 +0000 (23:03 +0000)]
Auto merge of #10676 - djmcgill:origin/master, r=weihanglo

add validation for string "true"/"false" in lto profile

### What does this PR try to resolve?
Adds a special-cased error message for when `lto` is set to the _string_ `"true"`/`"false"` which is surprisingly (I was surprised anyway) not allowed and the error message is ambiguous. The new error message makes it clear what values are accepted.
Fixes https://github.com/rust-lang/cargo/issues/10572

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

 <!-- Demonstrate how you test this change and guide reviewers through your PR.
With a smooth review process, a pull request usually gets reviewed quicker.

If you don't know how to write and run your tests, please read the guide:
https://doc.crates.io/contrib/tests -->

Uh I've not actually tested yet that's the WIP part. But put
```
[profile.dev]
lto="false"
```
in your TOML and run `cargo build`, check that you get the new error message and that it makes sense and is helpful.

### Additional information

It's worth noting that as per https://github.com/rust-lang/rust/pull/97051 this doesn't fix the _real_ problem here IMO which is that [rust's `opt_parse_bool` cli parsing](https://github.com/rust-lang/rust/blob/491f619f564a4ff9ae4cc837e27bb919d04c31be/compiler/rustc_session/src/options.rs#L456) doesn't accept true/false which certainly seems an ad-hoc historical choice to me on first glance but also it's a much bigger change to change those semantics than this error message.

2 years agoSpecial case the string true/false error message for LTO profile arg
David McGillicuddy [Tue, 17 May 2022 18:04:48 +0000 (19:04 +0100)]
Special case the string true/false error message for LTO profile arg

2 years agoAuto merge of #10726 - weihanglo:test-doc-enhance, r=epage
bors [Sun, 5 Jun 2022 17:21:25 +0000 (17:21 +0000)]
Auto merge of #10726 - weihanglo:test-doc-enhance, r=epage

Enhance documentation of testing

2 years agoSmall wording tweak.
Eric Huss [Sun, 5 Jun 2022 17:20:53 +0000 (10:20 -0700)]
Small wording tweak.

2 years agodoc: don't mention `#[test]` in cargo-bench doc
Weihang Lo [Sat, 4 Jun 2022 13:43:52 +0000 (21:43 +0800)]
doc: don't mention `#[test]` in cargo-bench doc

This is too details and not for averaged users.

2 years agodoc: add `**Note**:` to make quote block like a note
Weihang Lo [Sat, 4 Jun 2022 13:28:03 +0000 (21:28 +0800)]
doc: add `**Note**:` to make quote block like a note

2 years agoRephrase wordings in testing docs
Weihang Lo [Fri, 3 Jun 2022 23:16:54 +0000 (07:16 +0800)]
Rephrase wordings in testing docs

- Rephrase doctest exec model as "not guranteed and may change" instead
- Mention `#[bench]` in what cargo-bench automatically runs
- Make it clear for build/rustc when mentioning bin targets auto-built

2 years agodoc: execution model of doctest
Weihang Lo [Fri, 3 Jun 2022 12:27:00 +0000 (20:27 +0800)]
doc: execution model of doctest

NOTE: This is an undocumented implementation details.

2 years agodoc: mention `cargo test` runs test targets serially
Weihang Lo [Fri, 3 Jun 2022 11:47:11 +0000 (19:47 +0800)]
doc: mention `cargo test` runs test targets serially

2 years agodoc: add more link references for tests guide
Weihang Lo [Fri, 3 Jun 2022 09:55:34 +0000 (17:55 +0800)]
doc: add more link references for tests guide

- Mention that in `src/` Cargo also collect doc tests.
- Remove outdated statement: Cargo no longer tests examples by default.
- Add a link to "Cargo Targets: Tests" to help people learn about it.

2 years agodoc: mention binary auto-built for build,bench,test,rustc
Weihang Lo [Fri, 3 Jun 2022 09:29:42 +0000 (17:29 +0800)]
doc: mention binary auto-built for build,bench,test,rustc

2 years agodoc: highlight `--doc` only applied on lib target
Weihang Lo [Fri, 3 Jun 2022 03:02:59 +0000 (11:02 +0800)]
doc: highlight `--doc` only applied on lib target

2 years agoAuto merge of #10724 - ehuss:ci-disk-space, r=Eh2406
bors [Fri, 3 Jun 2022 02:57:12 +0000 (02:57 +0000)]
Auto merge of #10724 - ehuss:ci-disk-space, r=Eh2406

Clear disk space on CI.

Cargo's testsuite uses a considerable amount of disk space. On windows-gnu, the target directory can get over 12GB, and there is only 13GB free.  We're starting to run out of disk space, so this is a stop-gap that clears out the test data before running the smoke test which uses a fair bit of space itself.

We will probably need to think about addressing #9701 somehow, otherwise we will start running out of space as we add more tests. See the linked issues in https://github.com/rust-lang/cargo/pull/9701#issuecomment-881765517 for additional context.

2 years agoClear disk space on CI.
Eric Huss [Fri, 3 Jun 2022 00:55:45 +0000 (17:55 -0700)]
Clear disk space on CI.

2 years agoAuto merge of #10720 - JohnTitor:use-latest-tar, r=ehuss
bors [Wed, 1 Jun 2022 13:32:11 +0000 (13:32 +0000)]
Auto merge of #10720 - JohnTitor:use-latest-tar, r=ehuss

Enforce to use tar v0.4.38

The latest version of `tar` crate includes https://github.com/alexcrichton/tar-rs/pull/262, which uses a bit recent timestamp when archiving.
However, [it seems rust-lang/rust uses v0.4.37](https://github.com/rust-lang/rust/blob/e0944922007e1bb4fe59809293acf4364410cccc/Cargo.lock#L5124-L5132). This PR enforces to use v0.4.38 and it would _fix_ https://github.com/rust-lang/crates.io/issues/3859 eventually.

2 years agoEnforce to use tar v0.4.38
Yuki Okushi [Wed, 1 Jun 2022 10:17:15 +0000 (19:17 +0900)]
Enforce to use tar v0.4.38

2 years agoAuto merge of #10701 - danilhendrasr:master, r=weihanglo
bors [Tue, 31 May 2022 02:03:24 +0000 (02:03 +0000)]
Auto merge of #10701 - danilhendrasr:master, r=weihanglo

Emit warning upon encountering multiple packages with the same name

Fixes: #10669
2 years agoAuto merge of #10706 - merelymyself:master, r=epage
bors [Sun, 29 May 2022 02:13:39 +0000 (02:13 +0000)]
Auto merge of #10706 - merelymyself:master, r=epage

Guide new users to add use `super::*;` to `mod test`

### What does this PR try to resolve?

Currently, `cargo init --lib` produces examples for unit tests. However, new users will find that they are unable to use functions they defined above. This should resolve the confusion.

Fixes #10559

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

This PR does not create new features. Test this PR using the already-existing tests.

### Additional information

I didn't think this was a major change, so I did not open a RFC for it. Please let me know if I should have!

2 years agoEmit warning upon encountering ambiguous deps
Danil Hendra Suryawan [Sat, 28 May 2022 03:32:04 +0000 (03:32 +0000)]
Emit warning upon encountering ambiguous deps

2 years agowhitespace 2
merelymyself [Fri, 27 May 2022 16:17:57 +0000 (00:17 +0800)]
whitespace 2

2 years agowhitespace
merelymyself [Fri, 27 May 2022 16:14:30 +0000 (00:14 +0800)]
whitespace

2 years agoGuide new users to add use super::*; to mod test
merelymyself [Fri, 27 May 2022 15:41:37 +0000 (23:41 +0800)]
Guide new users to add use super::*; to mod test

2 years agoAuto merge of #10708 - svenstaro:patch-1, r=weihanglo
bors [Fri, 27 May 2022 12:35:25 +0000 (12:35 +0000)]
Auto merge of #10708 - svenstaro:patch-1, r=weihanglo

Document how to debug change detection events

### What does this PR try to resolve?

I noticed that my build would sometimes seemingly randomly rebuild other crates. I figured this must be the build script detecting a change in some external files. In order to debug this, I figured I'd look at the Cargo sources whether something like this was already being logged. Thankfully, the logging for this was already in place but I didn't find it documented anyway so I thought it might be rather helpful in such scenarios.

I believe it's a common enough scenario that inclusion into the official documentation on this topic should be considered.

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

Build/view documentation.

### Additional information

2 years agoDocument how to debug change detection events
Sven-Hendrik Haase [Fri, 27 May 2022 10:25:10 +0000 (12:25 +0200)]
Document how to debug change detection events

This merely links to the FAQ which already explains this
topic very well.

2 years agoAuto merge of #10677 - likzn:fix_publish_p, r=ehuss
bors [Fri, 27 May 2022 00:43:33 +0000 (00:43 +0000)]
Auto merge of #10677 - likzn:fix_publish_p, r=ehuss

fix(publish): add more check when use `publish -p <SPEC>`

### Main issue
As issue say #10536 , we need add more check when user use `cargo publish -p <SPEC>`

>`@ehuss` point outs:
>From a behavior standpoint, here are some things to check:
> - In the root of a virtual workspace, it should be an error to run without -p.
>- It should be an error to pass -p for a non-workspace member.
>- It should be an error for -p to match multiple packages.
>- When using -p, it should publish that package, not the one in the current directory (which can be different).

2 years agoAuto merge of #10705 - Muscraft:workspace-source-fmt-key, r=epage
bors [Thu, 26 May 2022 23:53:56 +0000 (23:53 +0000)]
Auto merge of #10705 - Muscraft:workspace-source-fmt-key, r=epage

fix key formatting when switching to a dotted `WorkspaceSource`

This fell out of #10697 see [this comment](https://github.com/rust-lang/cargo/pull/10697#discussion_r882691624)

There was a small issue where changing the source of a `cargo_add::Dependency` to a `WorkspaceSource` would cause the dotted version to have extra space.

```toml
dep .workspace = true
dep.workspace = true
```

This makes sure the key is formatted as well as adds a unit test to make sure this doesn't come back up in the future.

r? `@epage`

2 years agofix key formatting when switching to a dotted `WorkspaceSource`
Scott Schafer [Thu, 26 May 2022 19:02:00 +0000 (14:02 -0500)]
fix key formatting when switching to a dotted `WorkspaceSource`

2 years agoclean err msg
likzn [Thu, 26 May 2022 00:49:06 +0000 (08:49 +0800)]
clean err msg

2 years agoupdate
likzn [Wed, 25 May 2022 10:17:08 +0000 (18:17 +0800)]
update

2 years agoAuto merge of #10600 - tmfink:doc-build-script-link-order, r=ehuss
bors [Wed, 25 May 2022 00:50:02 +0000 (00:50 +0000)]
Auto merge of #10600 - tmfink:doc-build-script-link-order, r=ehuss

doc: discuss build script instruction order

### What does this PR try to resolve?

It is currently not documented that the order of build script `cargo:` instructions may be relevant to linking.

This has caused issues such as: https://github.com/rust-lang/rust/issues/96328

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

Build/view documentation.

### Additional information

- Cargo maintainers should fact check my wording.
- We may need to discuss if this should also be documented for `rustc`
- Maintainers should ensure that this change does not prevent a change in what is currently unspecified behavior. Perhaps `cargo` will want to rearrange link arguments itself to resolve issues in the future?

2 years agoTest that link argument order is maintained
Travis Finkenauer [Sun, 1 May 2022 22:54:20 +0000 (15:54 -0700)]
Test that link argument order is maintained

Patch provided by @ehuss

2 years agodoc: discuss build script instruction order
Travis Finkenauer [Tue, 26 Apr 2022 08:09:38 +0000 (01:09 -0700)]
doc: discuss build script instruction order

2 years agoAuto merge of #10698 - arlosi:http-slash, r=Eh2406
bors [Tue, 24 May 2022 15:23:47 +0000 (15:23 +0000)]
Auto merge of #10698 - arlosi:http-slash, r=Eh2406

Require http-registry URLs to end with a '/'

The `url` crate normalizes URLs with no path component to end in a trailing slash. This causes the current implementation to use urls containing two slashes for registries without a path component (such as `https://index.crates.io//config.json`).

This PR resolves the issue by requiring http registry URLs to end in a slash and generating paths by concatenating. A new error message is emitted for http registry URLs that do not end in a slash.

r? `@Eh2406`

2 years agoAuto merge of #10691 - danilhendrasr:master, r=weihanglo
bors [Tue, 24 May 2022 14:42:56 +0000 (14:42 +0000)]
Auto merge of #10691 - danilhendrasr:master, r=weihanglo

No printing executable names when running tests and benchmarks with json message format

Fixes: #10684
I added a new test for this, though I'm not sure if it's necessary. Let me know if I should delete it.

2 years agoNo printing executable names when running benches with json message format
Danil Hendra Suryawan [Tue, 24 May 2022 13:44:54 +0000 (20:44 +0700)]
No printing executable names when running benches with json message format

2 years agofixed issue with formats_source
merelymyself [Tue, 24 May 2022 12:42:26 +0000 (20:42 +0800)]
fixed issue with formats_source

2 years agoGuide new users to add use `super::*;`
merelymyself [Tue, 24 May 2022 12:27:58 +0000 (20:27 +0800)]
Guide new users to add use `super::*;`

2 years agoRequire http-registry URLs to end with a '/'
Arlo Siemsen [Tue, 24 May 2022 02:39:23 +0000 (21:39 -0500)]
Require http-registry URLs to end with a '/'

2 years agocargo fmt
likzn [Tue, 24 May 2022 01:15:44 +0000 (09:15 +0800)]
cargo fmt

2 years agorust fmt
likzn [Tue, 24 May 2022 01:15:02 +0000 (09:15 +0800)]
rust fmt

2 years agofix test stderr
likzn [Tue, 24 May 2022 01:09:57 +0000 (09:09 +0800)]
fix test stderr

2 years agoAuto merge of #10683 - jonhoo:fix-10682, r=Eh2406
bors [Mon, 23 May 2022 17:34:13 +0000 (17:34 +0000)]
Auto merge of #10683 - jonhoo:fix-10682, r=Eh2406

Restore proper error for crate not in local reg

Fixes #10682.

2 years agoUpdate src/cargo/ops/registry.rs with err msg
likzn [Mon, 23 May 2022 16:58:33 +0000 (00:58 +0800)]
Update src/cargo/ops/registry.rs with err msg

Co-authored-by: Eric Huss <eric@huss.org>
2 years agoAuto merge of #10696 - ehuss:update-curl, r=epage
bors [Mon, 23 May 2022 16:50:11 +0000 (16:50 +0000)]
Auto merge of #10696 - ehuss:update-curl, r=epage

Update libcurl

This updates to the latest libcurl.

Changes in curl:
* 0.4.42: https://github.com/alexcrichton/curl-rust/releases/tag/0.4.42
* 0.4.43: https://github.com/alexcrichton/curl-rust/releases/tag/0.4.43

Changes in libcurl:
* From 7.80.0 to 7.83.1: https://curl.se/changes.html

There were several security issues addressed recently (https://curl.se/docs/security.html), however, I don't think any of them are particularly concerning for us.

2 years agoUpdate libcurl
Eric Huss [Mon, 23 May 2022 15:21:50 +0000 (08:21 -0700)]
Update libcurl

2 years agocargo fmt
likzn [Mon, 23 May 2022 13:06:34 +0000 (21:06 +0800)]
cargo fmt

2 years agorefactor logic
likzn [Mon, 23 May 2022 13:01:55 +0000 (21:01 +0800)]
refactor logic

2 years agoAuto merge of #10693 - alex-semenyuk:typos_cargo, r=ehuss
bors [Mon, 23 May 2022 02:35:39 +0000 (02:35 +0000)]
Auto merge of #10693 - alex-semenyuk:typos_cargo, r=ehuss

Fixed small typos

Fixed small typos

2 years agoReverted option
alexey semenyuk [Sun, 22 May 2022 22:15:41 +0000 (22:15 +0000)]
Reverted option

2 years agoUpdate faq.md
alexey semenyuk [Sun, 22 May 2022 15:25:55 +0000 (15:25 +0000)]
Update faq.md

2 years agoUpdate faq.md
alexey semenyuk [Sun, 22 May 2022 15:19:49 +0000 (15:19 +0000)]
Update faq.md

2 years agoUpdate cargo-run.md
alexey semenyuk [Sun, 22 May 2022 14:00:01 +0000 (14:00 +0000)]
Update cargo-run.md

2 years agoUpdate semver.md
alexey semenyuk [Sun, 22 May 2022 13:03:25 +0000 (13:03 +0000)]
Update semver.md

2 years agoTypos
alexey semenyuk [Sat, 21 May 2022 17:56:22 +0000 (17:56 +0000)]
Typos

2 years agoNo printing executable names when running tests with json message format
Danil Hendra Suryawan [Sat, 21 May 2022 16:18:20 +0000 (23:18 +0700)]
No printing executable names when running tests with json message format

2 years agoAuto merge of #10685 - Muscraft:cargo-add-workspace-source, r=epage
bors [Fri, 20 May 2022 22:41:12 +0000 (22:41 +0000)]
Auto merge of #10685 - Muscraft:cargo-add-workspace-source, r=epage

fix bugs with `workspace` key and `update_toml`

### Motivations and Context

When working on an external subcommand to help with the switch to workspace inheritance, I found issues with the output `Cargo.toml` it was creating. When a `cargo_add::Dependency` would change its source to a `WorkspsaceSource`, `workspace = true` would not show up. This lead me to discover that the `default-features` key was not being removed when the `workspace` key was set.

This fixes those issues but brought up questions about how to deal with removing keys and clearing conflicting fields in a `Dependency`. After talking with `@epage,` it was decided that this was the minimal set of changes to make while the changes to fix the other issues is workshopped.

### Changes
- add `default-features` to the list of keys to remove when the source is a `WorkspaceSource`
- insert a `workspace` key when the source is a `WorkspaceSource`

2 years agoAuto merge of #10687 - ehuss:version-bump, r=epage
bors [Fri, 20 May 2022 21:52:59 +0000 (21:52 +0000)]
Auto merge of #10687 - ehuss:version-bump, r=epage

Bump to 0.64.0, update changelog

2 years agoUpdate changelog for 1.62
Eric Huss [Fri, 20 May 2022 21:20:52 +0000 (14:20 -0700)]
Update changelog for 1.62

2 years agofix bug where `update_toml` would not remove `default-features` if `workspace` was set
Scott Schafer [Fri, 20 May 2022 21:10:02 +0000 (16:10 -0500)]
fix bug where `update_toml` would not remove `default-features` if `workspace` was set

2 years agofix bug where `workspace = true` would not show up after `update_toml`
Scott Schafer [Fri, 20 May 2022 21:01:27 +0000 (16:01 -0500)]
fix bug where `workspace = true` would not show up after `update_toml`

2 years agoBump to 0.64.0
Eric Huss [Fri, 20 May 2022 20:27:39 +0000 (13:27 -0700)]
Bump to 0.64.0

2 years agoRestore proper error for crate not in local reg
Jon Gjengset [Fri, 20 May 2022 18:24:22 +0000 (18:24 +0000)]
Restore proper error for crate not in local reg

Fixes #10682.

2 years agoAuto merge of #10678 - cbeuw:patch-1, r=weihanglo
bors [Fri, 20 May 2022 01:56:04 +0000 (01:56 +0000)]
Auto merge of #10678 - cbeuw:patch-1, r=weihanglo

List C compiler as a build dependency in README

Cargo requires a C compiler to build, this should be specified in README
```
$ cargo tree --invert cc
cc v1.0.73
[build-dependencies]
├── curl-sys v0.4.55+curl-7.83.1
│   ├── cargo v0.63.0 (C:\Users\IEUser\Documents\cargo)
│   └── curl v0.4.43
│       ├── cargo v0.63.0 (C:\Users\IEUser\Documents\cargo)
│       ├── crates-io v0.34.0 (C:\Users\IEUser\Documents\cargo\crates\crates-io)
│       │   └── cargo v0.63.0 (C:\Users\IEUser\Documents\cargo)
│       └── git2-curl v0.15.0
│           └── cargo v0.63.0 (C:\Users\IEUser\Documents\cargo)
├── libgit2-sys v0.13.4+1.4.2
│   ├── cargo v0.63.0 (C:\Users\IEUser\Documents\cargo)
│   └── git2 v0.14.4
│       ├── cargo v0.63.0 (C:\Users\IEUser\Documents\cargo)
│       ├── cargo-test-support v0.1.0 (C:\Users\IEUser\Documents\cargo\crates\cargo-test-support)
│       │   [dev-dependencies]
│       │   └── cargo v0.63.0 (C:\Users\IEUser\Documents\cargo)
│       └── git2-curl v0.15.0 (*)
├── libnghttp2-sys v0.1.7+1.45.0
│   └── curl-sys v0.4.55+curl-7.83.1 (*)
├── libssh2-sys v0.2.23
│   └── libgit2-sys v0.13.4+1.4.2 (*)
└── libz-sys v1.1.6
    ├── curl-sys v0.4.55+curl-7.83.1 (*)
    ├── flate2 v1.0.23
    │   ├── cargo v0.63.0 (C:\Users\IEUser\Documents\cargo)
    │   └── cargo-test-support v0.1.0 (C:\Users\IEUser\Documents\cargo\crates\cargo-test-support) (*)
    │   [build-dependencies]
    │   └── cargo v0.63.0 (C:\Users\IEUser\Documents\cargo)
    ├── libgit2-sys v0.13.4+1.4.2 (*)
    └── libssh2-sys v0.2.23 (*)
```

2 years agoAuto merge of #10539 - Urgau:check-cfg-build-script, r=ehuss
bors [Fri, 20 May 2022 00:55:25 +0000 (00:55 +0000)]
Auto merge of #10539 - Urgau:check-cfg-build-script, r=ehuss

Add unstable `rustc-check-cfg` build script output

This PR adds a new build script output as unstable behind `-Zcheck-cfg=output`: `rustc-check-cfg`.

### What does this PR try to resolve?

This PR add a way to add to use the unstable `--check-cfg` command line option of `rustc` and `rustdoc`.

It was discover in [Bump bootstrap compiler to 1.61.0 beta](https://github.com/rust-lang/rust/pull/95678#discussion_r842803445) that `rustc_llvm` sets some custom `cfg` from a build script and because `--check-cfg=values()` is globally enable in the Rust codebase that cause the compilation to fail. For now no values are checked in stage 0 for the entire codebase which is a shame and should be fixed with the addition of this feature.

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

Commits are separated in: implementation, tests and doc.

Testing should simply be done by adding a valid `cargo:rustc-check-cfg` in a build script.
Watch the added tests or doc to have an example.

### Additional information

This PR is also the logical next step after `-Zcheck-cfg-features`.

2 years agoList C compiler as a build dependency
Andy Wang [Thu, 19 May 2022 22:10:10 +0000 (23:10 +0100)]
List C compiler as a build dependency

2 years agoFactor custom flags management to one function
Urgau [Wed, 18 May 2022 23:12:33 +0000 (01:12 +0200)]
Factor custom flags management to one function

2 years agoAdd doc for -Zextra-check-cfg and rustc-check-cfg
Loïc BRANSTETT [Thu, 7 Apr 2022 11:13:49 +0000 (13:13 +0200)]
Add doc for -Zextra-check-cfg and rustc-check-cfg

2 years agoAdd tests for cargo:rustc-check-cfg
Loïc BRANSTETT [Thu, 7 Apr 2022 10:10:00 +0000 (12:10 +0200)]
Add tests for cargo:rustc-check-cfg

2 years agoAdd support for cargo:rustc-check-cfg in build script
Loïc BRANSTETT [Tue, 5 Apr 2022 19:58:01 +0000 (21:58 +0200)]
Add support for cargo:rustc-check-cfg in build script

2 years agofix test
likzn [Wed, 18 May 2022 16:25:59 +0000 (00:25 +0800)]
fix test

2 years agofix typo
likzn [Wed, 18 May 2022 15:42:42 +0000 (23:42 +0800)]
fix typo

2 years agoextract to registry
likzn [Wed, 18 May 2022 15:40:07 +0000 (23:40 +0800)]
extract to registry

2 years agoMerge branch 'master' into fix_publish_p
likzn [Wed, 18 May 2022 15:04:07 +0000 (23:04 +0800)]
Merge branch 'master' into fix_publish_p

2 years agofix cargo -p
likzn [Wed, 18 May 2022 14:40:55 +0000 (22:40 +0800)]
fix cargo -p

2 years agoAuto merge of #10675 - Muscraft:update-contrib-docs, r=weihanglo
bors [Wed, 18 May 2022 01:52:07 +0000 (01:52 +0000)]
Auto merge of #10675 - Muscraft:update-contrib-docs, r=weihanglo

Add notes about pre-stabilization to contributor unstable docs

This PR is meant to add more direction for contributors on the path to stabilization for unstable features. It adds a section titled `Pre-Stabilization` to the unstable contributor docs.

The idea for this [came out of the discussion](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/workspace.20inheritance.20stabilization/near/281856280) about when and how to stabilize workspace inheritance. The notes that are being added were derived from the above comment as well as the [the adding of the `Call for Testing`](https://github.com/rust-lang/this-week-in-rust/issues/3236) section to TWiR. [This comment](https://github.com/rust-lang/this-week-in-rust/pull/3260#discussion_r874977470) gives more information as well.

As for the requirement of testing notes, [there is still discussion about if they are needed](https://github.com/rust-lang/this-week-in-rust/pull/3260#discussion_r874985133).

While what was added is not comprehensive it is meant as a guide for what to do as each feature has different requirements for stabilization

r? `@epage`

2 years agoAdd notes about pre-stabilization to contributor unstable docs
Scott Schafer [Tue, 17 May 2022 17:44:10 +0000 (12:44 -0500)]
Add notes about pre-stabilization to contributor unstable docs

2 years agoAuto merge of #10674 - petrochenkov:linklib, r=ehuss
bors [Tue, 17 May 2022 15:20:10 +0000 (15:20 +0000)]
Auto merge of #10674 - petrochenkov:linklib, r=ehuss

reference: Update syntax supported by `rustc-link-lib`

This doc already contains a link below pointing to the relevant rustc documentation https://doc.rust-lang.org/nightly/rustc/command-line-arguments.html#-l-link-the-generated-crate-to-a-native-library which has the updated syntax.

2 years agoreference: Update syntax supported by `rustc-link-lib`
Vadim Petrochenkov [Tue, 17 May 2022 11:51:58 +0000 (14:51 +0300)]
reference: Update syntax supported by `rustc-link-lib`

2 years agoAuto merge of #10665 - cuviper:patch-1, r=ehuss
bors [Thu, 12 May 2022 23:16:57 +0000 (23:16 +0000)]
Auto merge of #10665 - cuviper:patch-1, r=ehuss

Correct the release dates for 1.61 and 1.62

2 years agoCorrect the release dates for 1.61 and 1.62
Josh Stone [Thu, 12 May 2022 21:55:27 +0000 (14:55 -0700)]
Correct the release dates for 1.61 and 1.62

2 years agoAuto merge of #10659 - Muscraft:prestabilization-inheritance-docs, r=epage
bors [Thu, 12 May 2022 15:19:04 +0000 (15:19 +0000)]
Auto merge of #10659 - Muscraft:prestabilization-inheritance-docs, r=epage

pre-stabilization documentation for workspace inheritance

This is adding documentation for how we would like users to test workspace inheritance.

This came about from a discussion between `@epage` and I on better ways to document "pre-stabilization" features that are looking for people to test them. One of the ideas was to add some of the documentation to `unstable.md` so that it is all in one area. Having it in one area allows us to link to it so there are testing notes and documentation in one place. It also helps when posting in various places looking for testers as we can link to the nightly docs as needed. One idea was to post in TWiR [under a new table](https://github.com/rust-lang/this-week-in-rust/issues/3236) and this also helps with this.

The new documentation covers
- What we are looking for from testers
- Where to give feedback
- How to test this feature
- An example port as a guide

r? `@epage`

2 years agopre-stabilization documentation for workspace inheritance
Scott Schafer [Thu, 12 May 2022 15:13:20 +0000 (10:13 -0500)]
pre-stabilization documentation for workspace inheritance

2 years agoAuto merge of #10658 - epage:fix, r=ehuss
bors [Thu, 12 May 2022 14:00:45 +0000 (14:00 +0000)]
Auto merge of #10658 - epage:fix, r=ehuss

test: Make curr_dir work in/out of workspace

### What does this PR try to resolve?

Get snapbox tests passing when testing `cargo` as part of the `rust-lang/rust` workspace via a git submodule.
- When running tests in the `rust-lang/cargo` repo, `file!` is relative to
the crate root and tests are run relative to the crate root and
everything is fine.
- When running tests in the `rust-lang/rust` repo, `file!` is relative to
the workspace root and tests are run relative to the crate root and
there is much sadness.

If we are compiling relative to the crate root, we could make the path
absolute and everything would be dandy but this needs to happen at
compile time.  Didn't see a way to do this.

We could stop using `curr_dir` but that makes the tests a bit noisier
with more overhead for creating a new tests from an existing case.

Since we can reasonly know what all roots will be used for `file!`, we
can just hard code-in support for those two roots.  Much happiness
ensues as everything works with this surgical hack.

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

I ran the tests in both the `cargo` and `rust` repos.  You can as well.

### Additional information

2 years agotest: Make curr_dir work in/out of workspace
Ed Page [Wed, 11 May 2022 15:30:41 +0000 (10:30 -0500)]
test: Make curr_dir work in/out of workspace

When running tests in the `rust-lang/cargo` repo, `file!` is relative to
the crate root and tests are run relative to the crate root and
everything is fine.

When running tests in the `rust-lang/rust` repo, `file!` is relative to
the workspace root and tests are run relative to the crate root and
there is much sadness.

If we are compiling relative to the crate root, we could make the path
absolute and everything would be dandy but this needs to happen at
compile time.  Didn't see a way to do this.

We could stop using `curr_dir` but that makes the tests a bit noisier
with more overhead for creating a new tests from an existing case.

Since we can reasonly know what all roots will be used for `file!`, we
can just hard code-in support for those two roots.  Much happiness
ensues as everything works with this surgical hack.

2 years agoAuto merge of #10660 - ehuss:fix-no_cross_doctests-race, r=weihanglo
bors [Wed, 11 May 2022 23:10:18 +0000 (23:10 +0000)]
Auto merge of #10660 - ehuss:fix-no_cross_doctests-race, r=weihanglo

Fix no_cross_doctests race condition.

The change in #10594 to the `no_cross_doctests` test introduced a race condition. The two `rustc` invocations happen concurrently, which means the order is not deterministic. This adds`_unordered` along with differentiating text to fix the issue.

2 years agoAuto merge of #10657 - hi-rustin:rustin-patch-docs-typo, r=weihanglo
bors [Wed, 11 May 2022 21:15:09 +0000 (21:15 +0000)]
Auto merge of #10657 - hi-rustin:rustin-patch-docs-typo, r=weihanglo

Fix typo

See: https://github.com/rust-lang/cargo/pull/10633#discussion_r870130957

r? `@epage`

2 years agoFix no_cross_doctests race condition.
Eric Huss [Wed, 11 May 2022 21:10:49 +0000 (14:10 -0700)]
Fix no_cross_doctests race condition.

2 years agoFix typo
hi-rustin [Wed, 11 May 2022 13:08:04 +0000 (21:08 +0800)]
Fix typo

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2 years agoAuto merge of #10650 - epage:install, r=ehuss
bors [Wed, 11 May 2022 03:25:36 +0000 (03:25 +0000)]
Auto merge of #10650 - epage:install, r=ehuss

feat(install): Support `foo@version` like cargo-add

### What does this PR try to resolve?

This aims to make `cargo install` consistent with
- `cargo add foo@version` from #10472
- pkgid changes in #10582
- `cargo yank foo@version` from #10597

It also offers a shorthand for people installing a specific version.

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

#10582 acted as the FCP for this, see #10597

Documentation updates are split into their own commit to not clog up browsing the code.

Examine the tests to see if they make sense

### Additional information

While the `foo@vewrsion` syntax is the same, each's semantics are different.  We had decided it was better to have the same syntax with different semantics than having the user worry about what syntax they use where.  In `cargo install`s case, it has an
implicit-but-required `=` operand while `cargo-add` allows any operand.

This doesn't use the full `pkgid` syntax because that allows syntax that
is unsupported here.

This doesn't use `cargo-add`s parser because that is for version reqs.

I held off on reusing the parser from `cargo-yank` because they had
different type system needs and the level of duplication didn't seem
worth it (see Rule of Three).

2 years agoAuto merge of #10649 - Muscraft:fix-typos, r=epage
bors [Tue, 10 May 2022 23:58:15 +0000 (23:58 +0000)]
Auto merge of #10649 - Muscraft:fix-typos, r=epage

fix typos found by the `typos-cli` crate

This fixes various typos inside `cargo`. They were found by [`typos-cli`](https://crates.io/crates/typos-cli). A few different typos were left out as they seemed either intentional or were needed. Typos found in `LICENSE-THIRD-PARTY` were left alone as well.

r? `@epage`

2 years agoAuto merge of #10597 - epage:yank, r=ehuss
bors [Tue, 10 May 2022 21:53:54 +0000 (21:53 +0000)]
Auto merge of #10597 - epage:yank, r=ehuss

feat(yank): Support foo@version like cargo-add

### What does this PR try to resolve?

In #10472, cargo-add was merged with support for an inline version
syntax of `cargo add foo@version`.  That also served as the change proposal for
extending that syntax to `cargo yank` for convenience and consistency.

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

Documentation updates are split into their own commit to not clog up browsing the code.

The ops API is generic enough that this is implemented purely in the command.

For now, the `foo@version` syntax parser is being left in the command, rather than being shared, as we see how the behavior of these different parsers diverge for their target needs to see what makes sense for refactoring.  See also The Rule of Three
- This doesn't use the full `pkgid` syntax (modified in #10582) because that allows syntax that is unsupported here.
- This doesn't use `cargo-add`s parser because that is for version reqs.

Tests were added for various combinations of flags and behavior.

### Additional information

The major difference is that `cargo-add` is specifying a version-req
while `cargo-yank` is specifying a version.  This was originally discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Multiple.20ways.20of.20specifying.20versions) and there seemed to be a desire to have one syntax rather than the user thinking about a syntax per type of version (which users won't always think about).  See also #10582 which extended the pkgid spec syntax and has some more discussion on this general trend.

`cargo-install` will be updated in a subsequent PR.

2 years agofix typos found by the `typos-cli` crate
Scott Schafer [Tue, 10 May 2022 21:47:28 +0000 (16:47 -0500)]
fix typos found by the `typos-cli` crate

2 years agoAuto merge of #10648 - Muscraft:update-workspace-inheritance-docs, r=epage
bors [Tue, 10 May 2022 19:34:45 +0000 (19:34 +0000)]
Auto merge of #10648 - Muscraft:update-workspace-inheritance-docs, r=epage

add `cargo-features` to unstable docs for workspace inheritance

The unstable docs for workspace inheritance did not include `cargo-features = ["workspace-inheritance"]`. If a user were to follow the docs cargo would throw an error saying to `feature `workspace-inheritance` is required`. It would be better to explicitly add this to the unstable docs and remove it during stabilization.

r? `@epage`

2 years agoadd `cargo-features` to unstable docs for workspace inheritance
Scott Schafer [Tue, 10 May 2022 19:27:47 +0000 (14:27 -0500)]
add `cargo-features` to unstable docs for workspace inheritance

2 years agoAuto merge of #10646 - koic:use_rust_2021_prelude, r=epage
bors [Tue, 10 May 2022 16:48:05 +0000 (16:48 +0000)]
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

2 years agoAuto merge of #10594 - weihanglo:issue-10560, r=ehuss
bors [Tue, 10 May 2022 15:56:03 +0000 (15:56 +0000)]
Auto merge of #10594 - weihanglo:issue-10560, r=ehuss

Pass `--target` to `rustdoc` for `cargo test` if specified with host target.