8991 Commits

Author SHA1 Message Date
Alex Crichton
4c665c0ecd Don't assume iowait always increases on Linux
According to [documentation] looks like this value is documented as it
can decrease, so let's handle that without overflowing.

[documentation]: http://man7.org/linux/man-pages/man5/proc.5.html
2020-01-15 07:06:45 -08:00
bors
cb9de44655 Auto merge of #7799 - ehuss:consistent-dash, r=alexcrichton
Consistently use em-dash in environment documentation page.
2020-01-15 14:55:13 +00:00
Eric Huss
c622bea91b Add and update some doc comments.
Just some random things that I felt could use clarification.
2020-01-14 18:07:08 -08:00
Eric Huss
90887061b9 Consistently use em-dash in environment documentation page. 2020-01-14 18:02:31 -08:00
bors
0a4ec29176 Auto merge of #7774 - giraffate:update_credentials, r=ehuss
Load credentials only when needed

Credentials are always loaded, even if these are not used. If
access to confidential files such as credentials is not given,
`cargo build` fails despite not using credentials.

Fixes #7624.
2020-01-15 00:31:05 +00:00
Johannes Brechtmann
f917e169ab Fix wrong directories in host_libdir.
This fixes a regression from #7475 where the sysroot_target_libdir leaks into
the host libdir. This can cause problems when the dynamic linker does
not ignore the target libraries but tries to load them instead. This
happens for example when building on x86_64-musl for aarch64-musl.
2020-01-14 23:02:43 +01:00
Takayuki Nakata
438d005b2c Refactoring to use Vacant/Occupied instead of remove/insert 2020-01-14 22:11:16 +09:00
Takayuki Nakata
8076f578a3 Refactoring of creating files in tests
Use `mkdir_p` and `fs::write`.
2020-01-14 16:15:29 +09:00
bors
ad3dbe10e1 Auto merge of #7750 - ehuss:named-config-profiles, r=alexcrichton
Add named config profiles.

This adds support for named config profiles. Previously, only `dev` and `release` were allowed in config files, it now supports all profile names. I think it would be strange to have arbitrarily named profiles in `Cargo.toml`, but not allow them in config. This is a deviation from the RFC, but RFC 2282 was written before named profiles which I think changes the landscape.

This diff is a little large due to some refactoring to make it work well. Overview of the changes:
- Removed `ProfileKind` and only use an `InternedString` to track the name of the profile. I didn't feel like the enum carried its cognitive weight, and it seems to simplify some things.
- `Profiles` is no longer stored in the manifest. There was no need to do a bunch of processing for each manifest. `Manifest` now only retains the low-level `TomlProfiles`. A single `Profiles` now lives in `BuildContext`.
- The profile name requested by the user is no longer passed around. It is given to `Profiles::new` and retained inside `Profiles`.
- `Profiles::get_profile` no longer follows the priority stack and inheritance each time a profile is requested. Instead, the profile is computed once (in `Profile::new`) and merged into a single profile. This simplifies getting a profile, and makes it easier to deal with getting the config values in one place.
- I switched profile names to be `InternedString` instead of `String`. There's not a strong reason to do this, other than it seemed a little strange to be creating lots of `String`s.
    - I also added `PartialEq<str>` for `InternedString`. It has come up a few times in the past, and it seems useful. I'm not sure if it was excluded intentionally?
- The validation that the profile exists is now done in one place (`Profiles::new`).
- I removed the back-compatibility for the `overrides` key (which was renamed to `package` back in October).

Notes:
- Some of the error messages aren't as good as before, because they don't tell you where the error is located (`Cargo.toml` or `.cargo/config`). This is because the location data is lost by the time validation is done. Hopefully it will be obvious from the profile name and error message. I tried to improve error messages wherever I could.
- There are more calls to `clone()` than I would like, but they are kinda hard to avoid. Should be fewer than before.
- I noticed a bug with `-Zpanic-abort-tests` not supporting named profiles. I'll fix that separately.
- I think this fixes some bugs where package overrides in config weren't merging properly with package overrides defined in `Cargo.toml`.
2020-01-13 21:37:15 +00:00
Eric Huss
dafacbb76b Update tests for formatting changes due to anyhow changes. 2020-01-13 13:36:20 -08:00
Eric Huss
77ee608de3 Add named config profiles. 2020-01-13 13:27:33 -08:00
bors
56a5503268 Auto merge of #7755 - lu-zero:rustc-crate-type, r=alexcrichton
Make cargo-rustc crate-type-aware

This fixes #7339 and makes the usage of `cargo rustc` less surprising overall.
2020-01-13 15:16:11 +00:00
bors
ae08099ce1 Auto merge of #7791 - ehuss:rename-kind, r=alexcrichton
Rename `Kind`

Rename `dependency::Kind` → `dependency::DepKind`
Rename `source_id::Kind` → `source_id::SourceKind`

I struggle when there are multiple types with the same name in the same code base. I think this makes it a little clearer what the type is.

I was tempted to also rename `registry::Kind`, but I could not think of a good name. That file is particularly hard for me to understand (locked vs normal sources, abstract trait, etc.), so I don't feel comfortable changing it. It's also localized in one file, so not as important.
2020-01-13 14:56:46 +00:00
Luca Barbato
d5eeab84c7 Have a mean to override the root package in a workspace 2020-01-12 14:18:26 +01:00
Eric Huss
0b653a43ba Rename Kind 2020-01-11 11:04:13 -08:00
bors
735f648b35 Auto merge of #7789 - gentoo90:bashcomp, r=alexcrichton
Update bash completion

Get rid of the removed options and add the new ones.
2020-01-10 22:52:41 +00:00
gentoo90
db040bfc47 Update options in bash completion 2020-01-10 23:59:46 +02:00
gentoo90
291c113078 Remove duplicate options from bash completion 2020-01-10 21:28:30 +02:00
bors
dd112dc4d1 Auto merge of #7788 - alexcrichton:retry-another, r=ehuss
Add another curl spurious network error

Witnessed in a [recent build][1] looks like this is another error that
should be safe to retry.

[1]: https://github.com/bytecodealliance/wasmtime/pull/788/checks?check_run_id=383658098#step:7:16
2020-01-10 16:55:21 +00:00
bors
6e4a159978 Auto merge of #7783 - alexcrichton:error-tweaks, r=Eh2406
Some small tweaks around error in configuration

Some minor changes I found when investigating https://github.com/rust-lang/cargo/issues/7780
2020-01-10 16:29:14 +00:00
Alex Crichton
3f9c47b60f Add another curl spurious network error
Witnessed in a [recent build][1] looks like this is another error that
should be safe to retry.

[1]: https://github.com/bytecodealliance/wasmtime/pull/788/checks?check_run_id=383658098#step:7:16
2020-01-10 08:11:06 -08:00
bors
1814ca54de Auto merge of #7787 - alexcrichton:fix-tests, r=alexcrichton
Fix tests with `url` crate update

Works around servo/rust-url#577
2020-01-10 16:01:26 +00:00
Alex Crichton
dde2734668 Fix tests with url crate update
Works around servo/rust-url#577
2020-01-10 08:00:35 -08:00
Takayuki Nakata
3c673cb573 Refactoring to loop over the key/values instead of hard-coding 2020-01-10 13:44:00 +09:00
Alex Crichton
d7b45f9992 Use context to create a chain of errors
There's an existing bug (#7782) in Cargo which exacerbates the issue
here but in general having a stack of errors is a bit easier to read and
work with than having a big long error message.
2020-01-09 10:29:22 -08:00
Takayuki Nakata
5e152863f4 Load credentials and add tests for yank and owner commands 2020-01-09 22:22:32 +09:00
Alex Crichton
d4ccae310d Remove an unnecessary call to from 2020-01-08 14:51:38 -08:00
bors
6dd57b2045 Auto merge of #7779 - ehuss:fix-cargo-lock-ignore, r=alexcrichton
Fix .gitignore of Cargo.lock in a subdirectory.

The code for checking if `Cargo.lock` is ignored was erroneously assuming it was at the root of the git repo.  This would cause a problem if `Cargo.lock` is in `.gitignore` in a subdirectory.

Fixes issue noted in https://github.com/rust-lang/cargo/issues/7705#issuecomment-572027382
2020-01-08 22:28:54 +00:00
Eric Huss
3cedb8e33c Fix .gitignore of Cargo.lock in a subdirectory. 2020-01-08 10:40:17 -08:00
bors
c95f396b4c Auto merge of #7778 - ehuss:bump-crates-io, r=alexcrichton
Bump crates-io

Needed for #7776.
2020-01-08 18:26:02 +00:00
Eric Huss
b688f7da56 Bump crates-io 2020-01-08 10:05:35 -08:00
bors
bb3f2c5927 Auto merge of #7776 - alexcrichton:anyhow, r=ehuss
Migrate from the `failure` crate to `anyhow`

The `anyhow` crate interoperates with the `std::error::Error` trait
rather than a custom `Fail` trait, and this is the general trend of
error handling in Rust as well.

Note that this is mostly mechanical (sed) and intended to get the test
suite passing. As usual there's still more idiomatic cleanup that can
happen, but that's left to later commits.
2020-01-08 17:50:44 +00:00
Alex Crichton
d0430dd2b1 Run rustfmt 2020-01-07 20:01:34 -08:00
Alex Crichton
3a18c89a55 Migrate from the failure crate to anyhow
The `anyhow` crate interoperates with the `std::error::Error` trait
rather than a custom `Fail` trait, and this is the general trend of
error handling in Rust as well.

Note that this is mostly mechanical (sed) and intended to get the test
suite passing. As usual there's still more idiomatic cleanup that can
happen, but that's left to later commits.
2020-01-07 16:50:09 -08:00
bors
7059559d71 Auto merge of #7771 - moxian:needless-borrow, r=alexcrichton
Fix several needless_borrow clippy lints.

Fixes several [needless_borrow](https://rust-lang.github.io/rust-clippy/v0.0.212/index.html#needless_borrow) clippy lints.

I've only fixed this kind of lint errors and not others, since for some reason these are the only ones that show as red squigglies in my editor of choice.
2020-01-07 15:25:14 +00:00
bors
25eb5cd153 Auto merge of #7770 - giraffate:fix_docs, r=alexcrichton
Fix some links

- Remove unused link in doc. Follow up d1d0837.
- Update the reference link in a message. Follow up dc81356.
2020-01-07 15:04:30 +00:00
Takayuki Nakata
4b70f14903 Load credentials only when needed
Credentials are always loaded, even if these are not used. If
access to confidential files such as credentials is not given,
`cargo build` fails despite not using credentials.

Fixes #7624.
2020-01-07 23:40:58 +09:00
moxian
239ebf4f6c Fix several needless_borrow clippy lints. 2020-01-07 08:04:00 +00:00
Takayuki Nakata
f37b9bd77a Update the reference link in a message
Follow up dc81356ef.
2020-01-07 09:05:49 +09:00
Takayuki Nakata
74d062b3b0 Remove unused link in doc
Follow up d1d083789.
2020-01-07 09:05:49 +09:00
bors
6e1ca924a6 Auto merge of #7758 - jblazquez:fix-windows-uwp-dynamic-linking, r=alexcrichton
Fix dynamic linking for Windows UWP MSVC targets

When creating a dynamic library, the MSVC linker generates an import library (.lib) next to the .dll file. Cargo has explicit knowledge of this and includes those generated .dll.lib on the list of files generated by a Cargo invocation.

However, the check to see if those import libraries must be included is too strict and doesn't match any Windows targets that don't end in `pc-windows-msvc`. For example, https://github.com/rust-lang/rust/pull/63155 added several new Windows targets for targeting UWP called `*-uwp-windows-msvc`. The end result is that the sysroot for these UWP toolchains don't contain a `std-XXX.dll.lib` file and thus any executable that uses `-C prefer-dynamic` will fail to link because the `std` library is not linked at all.

This change relaxes the test and makes Cargo know about those import libraries for all Windows MSVC targets.
2020-01-06 19:11:37 +00:00
bors
5cca88f0c6 Auto merge of #7763 - ehuss:fix-target-cfg-env, r=alexcrichton
Fix CARGO_TARGET_triple_LINKER environment variable.

#7649 caused an unfortunate regression where the `CARGO_TARGET_triple_LINKER` environment variable stopped working. I did not realize `serde(flatten)` caused serde to switch to `deserialize_map` which does not support environment variables.

The solution here is to essentially revert back to how the `[target]` table used to be loaded by loading each key individually.

This also removes the `ar` field which is not used by `rustc`.
2020-01-06 17:18:52 +00:00
bors
1081bc7e66 Auto merge of #7756 - ehuss:dep-kinds-dedup, r=alexcrichton
Remove metadata dep_kinds duplicates.

In `cargo metadata`, an entry could appear multiple times in the `dep_kinds` array if it is used by multiple workspace members with different features activated.  This fixes it by de-duplicating the entries.

This is kinda related to `cargo metadata` not handling workspaces and features very well. But workspaces and features are a bit awkward overall.

Fixes #7752
2020-01-06 16:25:33 +00:00
bors
801942b74a Auto merge of #7751 - ehuss:multiple-source-definition, r=alexcrichton
Check for a source defined multiple times.

There is a bug where if a source is defined in multiple `[source]` tables, it causes a key collision in `SourceConfigMap::id2name`.  This can result in random behavior depending on which key is inserted first.

I decided to just make it an error.  I can't think of a way to make it work since the `replace-with` chain walking depends on unique sourceid->name mappings.  If anyone has ideas how to support it, I can try, but I don't immediately see how.

Closes #7692
2020-01-06 16:00:45 +00:00
bors
feb2103f60 Auto merge of #7735 - ehuss:prog-macro, r=alexcrichton
Fix typo.
2020-01-06 15:40:54 +00:00
bors
f7c5b1f839 Auto merge of #7748 - ehuss:fix-config-env-var-prefix, r=alexcrichton
Fix config env vars that are prefix of another with underscore.

This fixes the CARGO_BUILD_TARGET_DIR and CARGO_PROFILE_DEV_DEBUG_ASSERTIONS environment variables.  Hopefully the big comment explains everything, but to review:

`deserialize_option` does not know the type of the value it is about to deserialize.  The type could be a struct, in which case it needs to check if `CARGO_FOO_BAR_*` environment variables are set. However, when deserializing something like `build.target`, this prefix check will incorrectly match `CARGO_BUILD_TARGET_DIR` which happens to be a prefix of `CARGO_BUILD_TARGET_*`.  It attempts to call `visit_some` which fails if `CARGO_BUILD_TARGET` is not set.

The solution here is to detect scenarios where one field is a prefix of another, and skip the environment prefix check (by setting `Deserializer::env_prefix_ok` appropriately).  This means we cannot have `Option<SomeStruct>` be a prefix of another field with an underscore.  I think that's fine, and we should try to probably avoid these kinds a prefixes anyways.

Closes #7253.
2020-01-06 15:20:09 +00:00
Eric Huss
35b924db5a Fix CARGO_TARGET_triple_LINKER environment variable. 2020-01-02 11:50:00 -08:00
Javier Blazquez
a1b846189c Fix dynamic linking for Windows UWP targets 2019-12-31 16:08:22 -08:00
Eric Huss
7acf376d78 Remove metadata dep_kinds duplicates. 2019-12-30 10:58:24 -08:00
bors
4111e1a11f Auto merge of #7741 - giraffate:add_test_for_cargo_pkgid, r=ehuss
Add test for `cargo pkgid`

There was no test for `cargo pkgid` command.
2019-12-29 17:42:45 +00:00