Jon Gjengset [Wed, 31 Mar 2021 19:35:23 +0000 (12:35 -0700)]
Include allowed features in fingerprint
If this weren't the case, a user that compiled, and then re-ran cargo
with a particular set of allowed features would not see any breakage
even if other unstable features were used.
The downside of this is that changing allow-features causes a full
re-compile, but that still _seems_ like the right thing to do.
bors [Fri, 26 Mar 2021 16:59:39 +0000 (16:59 +0000)]
Auto merge of #9307 - ijackson:exit-code-string, r=joshtriplett
tests: Tolerate "exit status" in error messages
"exit code" is wrong terminology on Unix. I am trying to fix this in Rust stdlib in https://github.com/rust-lang/rust/pull/83462 but this currently breaks the cargo test suite.
Ian Jackson [Fri, 26 Mar 2021 16:18:37 +0000 (16:18 +0000)]
tests: Tolerate "exit status" in error messages
"exit code" is wrong terminology on Unix. I am trying to fix this in
Rust stdlib in
https://github.com/rust-lang/rust/pull/83462
but this currently breaks the cargo test suite.
See that MR for full explanation of the change.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
bors [Fri, 26 Mar 2021 14:38:38 +0000 (14:38 +0000)]
Auto merge of #9298 - alexcrichton:mac-split-debuginfo-default, r=ehuss
Default macOS targets to `unpacked` debuginfo
This commit continues the work from #9112 to enable `unpacked` split
debuginfo on macOS targets by default. This has been discussed on [internals]
for awhile now and no breakage has emerged while significant speedups
have. This is expected to be a compile-time and `target`-directory size
win for almost all macOS Rust projects.
While breakage is possible it's possible to mitigate this with
project-local or global cargo configuration of the `dev` and `test` profiles.
Alex Crichton [Wed, 24 Mar 2021 21:04:56 +0000 (14:04 -0700)]
Default macOS targets to `unpacked` debuginfo
This commit continues the work from #9112 to enable `unpacked` split
debuginfo on macOS targets by default. This has been discussed on [internals]
for awhile now and no breakage has emerged while significant speedups
have. This is expected to be a compile-time and `target`-directory size
win for almost all macOS Rust projects.
While breakage is possible it's possible to mitigate this with
project-local or global cargo configuration of the `dev` and `test` profiles.
bors [Thu, 25 Mar 2021 20:07:04 +0000 (20:07 +0000)]
Auto merge of #9300 - alexcrichton:fix-publish-metadata, r=ehuss
Fix publication of packages with metadata and resolver
This commit fixes an issue where packages which specify `resolver = '2'`
cannot be packaged if they also have a `package.metadata` table. The
issue is that the `toml` serialization implementation serializes fields
in order which requires that tables be emitted last.
Alex Crichton [Thu, 25 Mar 2021 16:13:40 +0000 (09:13 -0700)]
Fix publication of packages with metadata and resolver
This commit fixes an issue where packages which specify `resolver = '2'`
cannot be packaged if they also have a `package.metadata` table. The
issue is that the `toml` serialization implementation serializes fields
in order which requires that tables be emitted last.
bors [Thu, 25 Mar 2021 14:06:51 +0000 (14:06 +0000)]
Auto merge of #9299 - ehuss:fix-config-include, r=alexcrichton
Fix config includes not working.
The config-include feature wasn't working because the config values were being loaded before the call to `configure`, so the unstable flag was always false.
I had to remove the unstable warning because it was a bit awkward to support, and I figure it's not that important.
bors [Mon, 22 Mar 2021 21:04:12 +0000 (21:04 +0000)]
Auto merge of #9282 - lf-:remove-author, r=ehuss
RFC 3052: Stop including authors field in manifests made by cargo new
See https://github.com/rust-lang/rust/issues/83227
~~This is definitely a draft as there are a couple of tests I'm still working on fixing.~~ One question I ran into while digging through these test failures is that there is a Cargo config option for author name, `cargo-new.name`. Should we keep supporting that? I feel like perhaps we should as the user has specified explicit intent that they want their name in the authors of a manifest as generated by `cargo new`, but it seems weird to support *just* that case. There is likewise an environment variable `CARGO_NAME` that signals similar intent.
Should we completely drop the feature of putting in author names, and require people to manually put them in if they wish, or allow these limited cases where the user is specifically instructing *cargo* to do it?
bors [Mon, 22 Mar 2021 14:40:21 +0000 (14:40 +0000)]
Auto merge of #9290 - ehuss:non-member-features, r=alexcrichton
Refactor feature handling, and improve error messages.
This changes the way feature strings are handled with an eye towards fixing some improper handling and to improve error messages. The key change is to stop treating all features as free-form strings and instead try to handle them as typed values. This helps avoid needing to deal with parsing different feature syntax (like `dep:` or `foo/bar`) or forgetting to handle it properly.
Overview of refactoring changes:
* `RequestedFeatures` changed to an enum to differentiate between features coming from the command-line, and those that are from a dependency.
* Moved parsing of CLI features to an earlier stage (now stored in `CompileOptions`), and ensures that they are properly handled as `FeatureValue` instead of strings.
* Pushed some feature validation earlier. For example, `DetailedTomlDependency` now validates things so you can see the location for the errant `Cargo.toml` (previously some validation was deep in the resolver, which provided poor errors).
This is a pretty large PR, but at the core it is just changing `RequestedFeatures` and then dealing with the fallout from that. Hopefully this is an improvement overall.
List of user-visible changes:
* Fix handling in resolver V2 of `--features bar?/feat` and `--features dep:bar`
* Better error handling for `bar/feat` and `dep:bar` in dependency declarations.
* Feature keys in the `[features]` table can no longer contain slashes.
* Fixed a minor issue with `cargo tree -e features --all-features -Z namespaced-features`
* Fixed a panic with `cargo tree` involving `-Z weak-dep-features`
I did a small amount of benchmarking, and I wasn't able to record much of a difference.
bors [Mon, 22 Mar 2021 14:11:51 +0000 (14:11 +0000)]
Auto merge of #9292 - ehuss:cargo-util, r=alexcrichton
Split out cargo-util package for cargo-test-support.
This splits out code from `cargo` that was being used by `cargo-test-support` in order to remove the dev-dependency cycle on the `cargo` crate. The intent here is to improve development build times. On my system, `touch src/cargo/lib.rs ; cargo check --profile=test` goes from 6.4 seconds to 3.5. I suspect more substantial changes (more than just `touch`) should exhibit even more improvements.
This has a substantial downside that it is another package to manage publishing, particularly with making sure the version is updated correctly for crates.io. I'm uncertain if on balance it is worth it, but I lean towards moving forward with it.
Eric Huss [Sat, 20 Mar 2021 21:31:09 +0000 (14:31 -0700)]
Remove use of Rustc from cargo-test-support.
cargo-test-support wasn't using any of the caching or other logic from
Rustc, so this just swaps with a very basic implementation in order to
remove the dependency on `cargo`.
bors [Sat, 20 Mar 2021 02:36:40 +0000 (02:36 +0000)]
Auto merge of #9237 - yaymukund:serde-expecting, r=ehuss
Use serde's error message option to avoid implementing `Deserialize`.
This is a cleanup based on https://github.com/serde-rs/serde/issues/1883, which fell out of https://github.com/rust-lang/cargo/pull/8664
It looks like this changes the resulting error messages. I'll leave it up to you to decide if the tradeoff makes sense here. Maybe the correct answer here is to make `serde`'s error messages include more details (e.g. `invalid type: int`).
bors [Tue, 16 Mar 2021 21:36:55 +0000 (21:36 +0000)]
Auto merge of #9268 - ehuss:2021-fix-edition-v2-warning, r=alexcrichton
Add report if `cargo fix --edition` changes features.
This adds a small report if using `cargo fix --edition` to transition from 2018 to 2021 to determine if the new resolver will result in different features.
There is a gauntlet of checks that must pass before it even tries to show the differences:
* If the resolver is already specified, skip.
* If in a virtual workspace, skip (no way to specify global edition).
* If not migrating the root package, skip. The edition only changes the resolver in the root package.
* If not migrating all targets, skip. It's uncertain if the user intends to set the package edition or not.
bors [Tue, 16 Mar 2021 20:55:20 +0000 (20:55 +0000)]
Auto merge of #9275 - ehuss:features-non-member, r=alexcrichton
Fix --feature pkg/feat for V1 resolver for non-member.
#8997 had an unintended regression where `-p foo --feature foo/feat` syntax where `foo` is an **optional non-member** fails with an error that `foo` did not match any packages. The issue is that the member/feature selection routine needed to slot this into the features for the package in the current working directory (it was incorrectly treating `foo` as a workspace member).
V2 outright does not allow specifying features for non-workspace members.
bors [Tue, 16 Mar 2021 18:23:15 +0000 (18:23 +0000)]
Auto merge of #9276 - ehuss:fix-collision-root-removal, r=alexcrichton
Fix doc duplicate removal of root units.
The doc collision removal code didn't consider the possibility that there was a collision with a root unit. This caused problems in conjunction with #9142 where cargo would panic because a root unit got removed from the graph because of a filename collision. The solution here is to avoid removing root units during the doc collision sweep.
This has a downside that this reintroduces a filename collision.
An alternate solution would be to make the set of root units mutable, and remove from that list, but I figured this is simpler and more conservative.
bors [Mon, 15 Mar 2021 16:58:26 +0000 (16:58 +0000)]
Auto merge of #9204 - jonhoo:patch-in-config, r=alexcrichton
Support [patch] in .cargo/config files
This patch adds support for `[patch]` sections in `.cargo/config.toml`
files. Patches from config files defer to `[patch]` in `Cargo.toml` if
both provide a patch for the same crate.
The current implementation merge config patches into the workspace
manifest patches. It's unclear if that's the right long-term plan, or
whether these patches should be stored separately (though likely still
in the manifest). Regardless, they _should_ likely continue to be
parsed when the manifest is parsed so that errors and such occur in the
same place regardless of where a patch is specified.
bors [Sun, 14 Mar 2021 23:15:17 +0000 (23:15 +0000)]
Auto merge of #9262 - Matt-Gleich:master, r=Eh2406
🍱 Crop favicon
Hello! At first glance I found doc.rust-lang.org/cargo's favicon to be a bit small compared to other site's favicons. Looked into it and found that the logo hasn't been cropped. All I did was crop the favicon in this PR. As you can see from the image below (new favicon on the right) it looks much better:
bors [Sat, 13 Mar 2021 01:18:40 +0000 (01:18 +0000)]
Auto merge of #9252 - ehuss:prefer-dynamic-ws, r=alexcrichton
Fix logic for determining prefer-dynamic for a dylib.
The logic for determining if a dylib should use `prefer-dynamic` used to be something like "do not use prefer-dynamic if it is the current package".
The current logic has a strange behavior where it works as intended if there is only one package in the workspace, but a workspace with multiple packages will always use `prefer-dynamic`.
Instead of using `current_opt`, which isn't a good concept to use in a workspace, I switched this to be "primary" (a package selected on the command-line).
**History**
* 9879a0a5f621a4ae44b2d9dc62a0175404c05f8f Initial prefer-dynamic behavior.
* #3221 changed to the faulty logic (see comments at https://github.com/rust-lang/cargo/pull/3221#discussion_r88535221). I think there was some confusion there.
* #3478 fixed the logic for one of the changed conditions, but not the one for prefer-dynamic
bors [Thu, 11 Mar 2021 19:57:49 +0000 (19:57 +0000)]
Auto merge of #9255 - ehuss:fix-deps-filtering, r=Eh2406
Fix issue with filtering exclusive target dependencies.
#8777 incorrectly changed the filtering logic for dependencies. Essentially it split `filter(any(A && B && C && D))` into two parts `filter(any(A && B)).filter(any(C && D))` which doesn't have the same meaning. The solution here is to pass a closure so that the conditions are joined again.
bors [Wed, 10 Mar 2021 15:22:00 +0000 (15:22 +0000)]
Auto merge of #9249 - ehuss:doc-pkgid-spec, r=alexcrichton
Update pkgid-spec docs.
The old docs for the pkgid spec weren't correct. Specs never supported abbreviated URLs or aliases for the index (like `crates.io`). This tries to correct that and add a little more detail.
bors [Tue, 9 Mar 2021 22:46:30 +0000 (22:46 +0000)]
Auto merge of #9233 - alexcrichton:reword-edition, r=ehuss
Wordsmith the edition documentation a bit more
This hopes to clear up a few recent PRs about the `edition` key in the
manifest. It shuffles things around so the defaults are talked about in
two different paragraphs. The first one talks about how `cargo new` uses
the 2018 edition and is the only paragraph to use the word "default".
The second section talks about the usage of 2015 with no `edition` field
present.
This didn't end up being quite as clear as I hoped it might be, but I'm
hoping that this provides a bit more emphasis or otherwise just
restructures things a bit to be more clear.
Not sure which commit breaks this. Cargo shipped with rust 1.46 didn't unwrap on a `None` but 1.47 did. Even checkouted to 149022b1d8f382e69c1616f6a46b69ebf59e2dea (cargo of rust 1.46), it still unwrap unexpectedly.
So I ended up following the [Specification grammer](https://doc.rust-lang.org/cargo/reference/pkgid-spec.html#specification-grammar) to make sure there is a `host` in the pkgid urls.
$ cargo +1.47 pkgid /path
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/tools/cargo/src/cargo/core/package_id_spec.rs:234:50
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```