Commit Graph

13379 Commits

Author SHA1 Message Date
Eric Huss 9247e8155f Fix unused attribute on Windows. 2023-01-22 14:02:23 -08:00
bors af8ec1407b Auto merge of #11603 - jofas:11398-fix, r=weihanglo
[Doc]: Added links to the `Target` section of the glossary for occurences of `target triple`

Fix for #11398. #11398 raises the concern that it isn't always abundantly clear in the cargo book, what a `target triple` (i.e. `x86_64-unknown-linux-gnu`) is. This is unfortunate, as it is well described in the [glossary](https://doc.rust-lang.org/cargo/appendix/glossary.html#target) of the cargo book (including the command on how to get all targets supported by `rustc`). To mitigate this problem I added links to the glossary entry for target triples to the sections where triples are referenced, but not enough information is given on what they are and how they look like.
2023-01-22 01:36:45 +00:00
bors 6c095cce88 Auto merge of #11558 - Muscraft:stabilize-cargo-fix-message, r=epage
feat: stabilize auto fix note

A note that some warnings could be fixed by running a `cargo fix` command was added in #10989 and made to work with `clippy` in #11399. It has only been turned on for `nightly` builds so far; this PR would make it show on `stable`.

The original motivation for making this note `nightly` only, was to [allow for iteration](https://github.com/rust-lang/cargo/issues/10976#issuecomment-1289297978) on the message output. There has yet to be any feedback on the message format in the time that it has been on `nightly`. This was brought up in a recent cargo team meeting and it was thought that we should move forward with showing this on `stable`.

close #10976
2023-01-22 00:50:42 +00:00
bors 96d5330f4c Auto merge of #11576 - lu-zero:clarify-pkg-vs-crate, r=weihanglo
Clarify the difference between CARGO_CRATE_NAME and CARGO_PKG_NAME

Since I ended up asking on zulip.
2023-01-22 00:01:41 +00:00
bors a38b83cff2 Auto merge of #11609 - ehuss:libgit2-sys-pin, r=weihanglo
Temporarily pin libgit2-sys.

There are some issues with the most recent libgit2-sys 0.14.2 not working on Windows (https://github.com/libgit2/libgit2/issues/6453 and https://github.com/libgit2/libgit2/issues/6454). Until we figure out what to do with it, this pins the release to the previous version.
2023-01-21 22:56:05 +00:00
bors b8e63ec6f1 Auto merge of #11610 - ehuss:disable-public-network-windows, r=epage
Disable network SSH tests on windows.

These tests have a high failure rate on Windows, so this disables them for now. I don't know exactly why they are failing. If I had to take a wild guess, I would suspect the use of WinCNG for the SSH backend, which may mean it is out of our control.
2023-01-21 21:15:35 +00:00
Eric Huss ede3bdf2d3 Disable network SSH tests on windows. 2023-01-21 13:06:07 -08:00
Eric Huss 198d2ee432 Temporarily pin libgit2-sys. 2023-01-21 12:14:31 -08:00
jofas 63e9b77d8a removed noisy links 2023-01-21 11:24:54 +01:00
Luca Barbato 9ba48bffb2 Clarify the difference between CARGO_CRATE_NAME and CARGO_PKG_NAME 2023-01-21 10:09:34 +01:00
bors 7e2a3c21e0 Auto merge of #11409 - Muscraft:default-feat-workspace-dep, r=weihanglo
fix(toml): Add `default-features` to `TomlWorkspaceDependency`

In #11329 it was noted that `default-features` is ignored when used in a dependency that inherits from a workspace i.e.
```toml
[workspace]
members = []
[workspace.dependencies]
dep = "0.1"

[package]
name = "bar"
version = "0.2.0"
authors = []
[dependencies]
dep = { workspace = true, default-features = false }
```

This problem is caused by problems with deserializing a `TomlDependency` and not emitting an unused manifest key correctly. When discussed in a recent Cargo team meeting we felt the best course of action was to allow `default-features = false` when inheriting a dependency, but it does not change actually set `default-features`. It will be used to warn when there is a difference between the definition in `[workspace.dependencies]` and `[dependencies]` i.e.
```toml
[package]
name = "bar"
version = "0.2.0"
[dependencies]
dep = { workspace = true, default-features = false }

[workspace]
members = []
[workspace.dependencies]
dep = { version = "0.1", default-features = true }
```

This does not entirely resolve the problem with unused manifest keys. A follow up PR and issue will be created to address those concerns.

close #11329
2023-01-20 18:11:39 +00:00
jofas 05e6d6febd added links to 'target' glossary entry in documentation for configuration section of the reference 2023-01-20 17:41:44 +01:00
jofas 7f0ee92330 properly added links to the 'target' glossary entry of the 'cargo tree' and 'cargo metadata' command man pages 2023-01-20 17:41:44 +01:00
jofas 40a615ef00 added links to 'target' in documentation for unstable section of the reference 2023-01-20 17:41:16 +01:00
jofas 30a0daf9e3 added link to 'target' in documentation for build cache section of the guide 2023-01-20 17:40:03 +01:00
jofas eaaa48fbaa added link to 'target triple' in documentation for cargo-metadata and cargo-tree commands 2023-01-20 17:40:03 +01:00
bors 975817ba44 Auto merge of #11601 - weihanglo:remove-rls, r=ehuss
doc(contrib): remove rls in release process

### What does this PR try to resolve?

Remove mentions of RLS from doc of release process. RLS is no longer required to test when bumping Cargo version in rust-lang/rust.

See:

- https://github.com/rust-lang/rust/pull/100863
- https://blog.rust-lang.org/2022/07/01/RLS-deprecation.html
2023-01-20 15:40:05 +00:00
Weihang Lo 73dd06ef0e
doc(contrib): remove rls in release process 2023-01-20 15:14:39 +00:00
bors 985d561f0b Auto merge of #11224 - arlosi:sparse-stable, r=Eh2406
Stabilize sparse-registry

### What does this PR try to resolve?
Stabilize `sparse-registry`
* Does not change the default protocol for accessing crates.io

### How should we test and review this PR?
Set environment variable `REGISTRIES_CRATES_IO_PROTOCOL=sparse` or set in `config.toml`:
```
[registries.crates-io]
protocol = 'sparse'
```

cc #9069
2023-01-20 14:39:28 +00:00
bors ba6217e40f Auto merge of #11545 - kylematsuda:secret-type, r=Eh2406
Wrapper type for data that should never be logged

Fixes #11519.

So far this is just creating the new wrapper type. If this looks okay, I'll start adding this wrapper in places where tokens and secret keys are held or passed.
2023-01-20 03:21:55 +00:00
Kyle Matsuda efb972ae76 refactor some uses of Secret to avoid generating a token first before wrapping in Secret 2023-01-19 16:47:12 -07:00
Kyle Matsuda a32cef9e43 improve docs for Secret<T>; add doctest to assert that inner val is hidden 2023-01-19 15:01:34 -07:00
bors d73b935e7f Auto merge of #11596 - ehuss:semver-lints, r=epage
Add semver rule for lints

This adds a new rule to the semver compatibility list explaining the expectations around diagnostic lints.

cc #8736
2023-01-19 16:37:27 +00:00
Eric Huss 408b8d5f51 Remove lint mitigation suggesting to use a cargo feature.
Since it is not possible to have "private" features, it can be an issue
if users enable it without understanding what it is for.
2023-01-19 08:35:04 -08:00
bors 50eb688c2b Auto merge of #11414 - Muscraft:vendor-use-package, r=weihanglo
Normalize git deps when doing `cargo vendor` for resolving deps inherited from a workspace

In #11192 it was noted that workspace inheritance causes vendored git dependencies to fail since `workspace = true` does not get resolved during vendoring.

To fix this, it was suggested to make `cargo vendor` work similar to `cargo package` since it resolves manifests before packaging them. I ended up implementing this proposed solution but sadly I could not find a way to share a ton of the code other than making a few things `pub`.

close #11192
2023-01-19 10:09:05 +00:00
Scott Schafer b64b605236 fix(vendor): Make `vendor` use `Manifest`'s "original" `Cargo.toml` 2023-01-18 22:19:56 -06:00
Eric Huss 21d913401a Add more to lint semver mitigations. 2023-01-18 19:59:20 -08:00
Eric Huss 7e6c96a319 Add semver rule for lints 2023-01-18 14:45:12 -08:00
bors 23424fde2e Auto merge of #11067 - tedinski:install_workspace_root, r=weihanglo
Ignore `workspace.default-members` when running `cargo install` on root package of a non-virtual workspace

### What does this PR try to resolve?

* Fixes #11058

Two observable behaviors are fixed:

1. When running `cargo install` with `--path` or `--git` and specifically requesting the root package of a non-virtual workspace, `cargo install` will accidentally build `workspace.default-members` instead of the requested root package.
2. Further, if that `default-members` does not include the root package, it will install binaries from those other packages (the `default-members`) and claim they were the binaries from the root package! There is no way, actually, to install the root package binaries.

These two behaviors have the same root cause:

* `cargo install` effectively does `cargo build --release` in the requested package directory, but when this is the root of a non-virtual workspace, that builds `default-members` instead of the requested package.

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

I have included a test exhibiting this behavior. It currently fails in the manner indicated in the test, and passes with the changes included in this PR.

I'm not sure the solution in the PR is the _best_ solution, but the alternative I am able to come up with involves much more extensive changes to how `cargo install` works, to produce a distinct `CompileOptions` for every package built. I tried to keep the new workspace "API" `ignore_default_members()` as narrowly-scoped in its effect as possible.

### Additional information

The only way I could think this behavior change could impact someone is if they were somehow using `cargo install --path` (or `--git`) and wanting it to actually install the binaries from all of `default-members`. However, I don't believe that's possible, since if there are multiple packages with binaries, I believe cargo requires the packages to be specified. So someone would have to be additionally relying on specifying just the root package, but then wanting the binaries from more than just the root. I think this is probably an acceptable risk for merging!
2023-01-18 15:47:10 +00:00
bors fc2242a8c5 Auto merge of #11592 - jofas:11513-fix, r=weihanglo
Corrected documentation of how to cache binaries installed with `cargo install` in CI workflows

Fix for #11513. Updated the cargo book documentation on how to cache the `$CARGO_HOME` directory in CI workflows (added that the `.crates.toml` and `.crates2.json` files must be cached alongside the `/bin` folder, if installed binaries are cached)
2023-01-18 11:07:23 +00:00
jofas 37f05101b2 explaining that and must be cached alongside binaries installed with 2023-01-18 11:44:23 +01:00
Kyle Matsuda 36cad92e04 remove redundant Secret::from 2023-01-17 14:38:59 -07:00
Kyle Matsuda e2832a80a5 clean up wrapping with Secret in commands 2023-01-17 14:37:59 -07:00
bors a5d47a7259 Auto merge of #11583 - ehuss:container-tests, r=epage
Add network container tests

This adds some tests which use Docker containers to provide HTTPS and SSH servers. This should help with validating that Cargo's networking and security are working correctly.  It can also potentially be used in the future for other tests that require more complex setups.

These tests are only run on Linux in CI. macOS does not have Docker there, and the Windows Docker does not support Linux containers. The tests should work on macOS if you run them locally with Docker Desktop installed. The SSH tests do not work on Windows due to issues with ssh-agent, but the HTTPS tests should work with Docker Desktop.

These tests require an opt-in environment variable to run:

* `CARGO_PUBLIC_NETWORK_TESTS=1` — This is for tests that contact the public internet.
* `CARGO_CONTAINER_TESTS=1` — This is for tests that use Docker.
2023-01-16 18:51:50 +00:00
bors 2a5ff4cb9a Auto merge of #11579 - kawaemon:show-progress-on-git-cli-fetch, r=weihanglo
Show progress of crates.io index update even `net.git-fetch-with-cli` option enabled

### What does this PR try to resolve?

This PR fixes #11574 .

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

Please run `cargo` with `net.git-fetch-with-cli` option enabled.
It should show `git fetch`'s progress output like below.
```
❯ CARGO_NET_GIT_FETCH_WITH_CLI=true ./target/debug/cargo b
    Updating crates.io index
remote: Enumerating objects: 139821, done.
remote: Counting objects: 100% (2226/2226), done.
remote: Compressing objects: 100% (769/769), done.
receiving objects:   0% (1/139821)
```
2023-01-16 16:51:02 +00:00
bors f0b6f81a78 Auto merge of #11550 - weihanglo:issue-10607, r=ehuss
`cargo metadata` supports artifact dependencies
2023-01-16 16:05:29 +00:00
bors 8eb9a0cdfa Auto merge of #11504 - strager:fix-profile-doc, r=weihanglo
fix(docs): add required "inherits" option to example profile

## What does this PR try to resolve?

I copy-pasted then modified the example [profile.<name>] section in Cargo's docs. I was met with the following error:

> error: profile quick-build-incremental is missing an inherits directive (inherits is required for all profiles except dev or release)

## How should we test and review this PR?

Copy-paste the new docs into a `Cargo.toml` file, tweak, then try to use the new profile (`cargo build --profile mynewprofile`).

## Additional information

None
2023-01-16 15:04:46 +00:00
Weihang Lo d02e36cea1
Only output field `extern_name` when using -Zbindeps 2023-01-16 14:12:32 +00:00
Weihang Lo 690e6a4128
cargo-metadata: error out if same dep with differnt names
Previous, `cargo metadata` allows a dependency with different renamed
co-exist. However, its `resolve.nodes.deps` will miss that dependency,
which is wrong. After this commit, `cargo metadata starts erroring out
for that situation.
2023-01-16 14:12:32 +00:00
Weihang Lo 272193aa29
cargo-metadata: error out when encountering invalid artifact kind syntax
This refactor reuse the logic of
`core::compiler::unit_dependencies::match_artifacts_kind_with_targets`
to emit error if there is any syntax error in `ArtifactKind`.

It also put `match_artifacts_kind_with_targets` to a better place `core::compiler::artifact`.
2023-01-16 14:12:13 +00:00
Weihang Lo e5ec492b6f
cargo-metadata: support -Zbindeps info 2023-01-16 14:12:13 +00:00
bors 8681a5a0ca Auto merge of #11586 - hds:ssh-known-hosts-doc-update, r=weihanglo
add documentation that SSH markers aren't supported

### What does this PR try to resolve?

Cargo doesn't support the ``@cert-authority`` or ``@revoked`` markers in SSH
Known Hosts files. The lines are silently ignored.

If a user is depending on these lines to connect to a Git server via
SSH, then their command line Git client will work, but Cargo will fail
with an error that the host key doesn't match.

This change adds a note explaining that Cargo doesn't support these
markers and suggests that the user change their cargo configuration to
fetch with the CLI client instead.

This PR fixes the first part (of 4) of the suggested tasks to fix #11577.

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

This change only modifies the Cargo book source. Running `mdbook build`
and checking the SSH Known Hosts section of the appendix on Git
authentication should be sufficient to test the PR.

### Additional information

The note in this section repeats what is said in the higher section on
SSH authentication, however given the recently implemented host key
checking, it seems worth calling out the limitation that Cargo doesn't
support these markers in the SSH known hosts file explicitly. Hopefully,
it reduces support requests and questions as well.
2023-01-16 14:00:46 +00:00
Weihang Lo ca626c5915
refactor: reuse crate type strings in `ArtifactKind` 2023-01-16 13:57:27 +00:00
Hayden Stainsby f460ac2b1d add documentation that SSH markers aren't supported
Cargo doesn't support the `@cert-authority` or `@revoked` markers in SSH
Known Hosts files. The lines are silently ignored.

If a user is depending on these lines to connect to a Git server via
SSH, then their command line Git client will work, but Cargo will fail
with an error that the host key doesn't match.

This change adds a note explaining that Cargo doesn't support these
markers and suggests that the user change their cargo configuration to
fetch with the CLI client instead.

Refs: #11577
2023-01-16 14:22:25 +01:00
bors 7b4737f1c4 Auto merge of #11585 - hi-rustin:rustin-patch-typo, r=ehuss
Fix typo
2023-01-16 02:58:54 +00:00
hi-rustin 7be22aae95 Move TODO to the right place
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-01-16 10:22:16 +08:00
hi-rustin 28c134c570 Fix typo
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-01-16 09:57:17 +08:00
Matthew "strager" Glazar 80bc392e42 fix(docs): add required "inherits" option to example profile 2023-01-15 17:12:17 -08:00
Eric Huss 4cb9ac35bf Add network container tests 2023-01-14 15:10:16 -08:00
bors 88f14290f2 Auto merge of #11582 - ehuss:enable-source_config_env, r=weihanglo
Enable source_config_env test on Windows

This enables the `advaned_env::source_config_env` test on Windows. The issue with `Command` modifying the case of environment variables was fixed by https://github.com/rust-lang/rust/pull/85270.
2023-01-14 19:02:16 +00:00