Alex Crichton [Wed, 29 Jan 2020 08:21:19 +0000 (00:21 -0800)]
Replace `std::sync::mpsc` with a much simpler queue
We don't need the complexity of most channels since this is not a
performance sensitive part of Cargo, nor is it likely to be so any time
soon. Coupled with recent bugs (#7840) we believe in `std::sync::mpsc`,
let's just not use that and use a custom queue type locally which should
be amenable to a blocking push soon too.
bors [Thu, 5 Mar 2020 23:02:29 +0000 (23:02 +0000)]
Auto merge of #7965 - jiegec:master, r=alexcrichton
Don't create hardlink for library test and integrations tests, fixing #7960
Related issue: #7960
Problem:
Tests are run under deps, but it is still copied to its parent directory. It leads to separation between the executable and its debug symbols (.dSYM directory).
bors [Thu, 5 Mar 2020 17:09:08 +0000 (17:09 +0000)]
Auto merge of #7970 - ehuss:revert-debug-assert-filter, r=alexcrichton
Partially revert change to filter debug_assertions.
This partially reverts the changes from #7943. It caused a regression with the rocket_contrib crate. I knew that was the only crate that had a `cfg(debug_assertions)` dependency, and I saw that it had been fixed, but I did not realize the fix hadn't been published (and will be in a semver incompatible release).
This retains the old behavior for `cfg(debug_assertions)` of issuing a warning. I kept the filter for `CARGO_CFG_DEBUG_ASSERTIONS` for build scripts because that was the original intent for the change, and I don't see anyone using that.
bors [Wed, 4 Mar 2020 15:37:33 +0000 (15:37 +0000)]
Auto merge of #7959 - ehuss:restricted-crate-names, r=alexcrichton
Try to better handle restricted crate names.
This attempts to improve handling of restricted crate names, particularly for `cargo new` and `cargo init`. Hopefully the code is straightforward to follow, but in summary the changes are:
**General changes**
* Add more details to the error messages about why a name is not allowed, and what is allowed.
* Change the valid package name check to be restricted to Unicode XID. This brings it in line with non_ascii_idents support in rustc. For the most part, this is pretty much the same as before. Note: this is used for the package name, and registry names. The differences are:
* Package names cannot start with numbers. Previously this was only rejected in `cargo new`. crates.io also rejects numbers. Numbers are also not valid crate names.
* Package names cannot start with dash `-`. This is a somewhat arbitrary change, but seems like it would stem problems. crates.io also rejects this.
* Package names cannot start with these characters that were previously allowed: https://gist.github.com/ehuss/804a797950001b5226e1264b6f65211f#file-not_start_but_alphanumeric-txt
* Most of these are wacky numbers or other strange things.
* Package names cannot contain these characters that were previously allowed: https://gist.github.com/ehuss/804a797950001b5226e1264b6f65211f#file-not_continue_but_alphanumeric-txt
* These are mostly odd things that for whatever reason the Unicode people decided not to include. It seems unlikely to me that someone would want to use one of these.
* Display a warning on Windows if a Cargo target is a special Windows filename. The build error tends to be hard to understand, so the hope is the warning will make it evident.
* `cargo package/publish`: Warn if a special Windows name is in the package.
**cargo new/init specific changes**
* Update keyword list to 2018 edition.
* Add warning if creating a library that has one of the conflicting names (deps/examples/build/incremental).
* Warn about conflicting std names (core/std/alloc/proc-macro).
* Windows reserved names: Rejected on windows, warned on other platforms.
* Warn about non-ASCII package names.
* Only print the `--name` suggestion for `cargo init`. I found the suggestion confusing, and I feel like it doesn't really make sense for `cargo new` (since it would only affect the directory name).
bors [Tue, 3 Mar 2020 20:17:11 +0000 (20:17 +0000)]
Auto merge of #7962 - ehuss:features2-required-feature-inactive, r=alexcrichton
Fix bug with new feature resolver and required-features.
If required-features are used, then the code for checking those features would crash if a dependency was not activated. The solution here is to not be strict about only requesting activated packages.
For context, the reason this can panic is to check for any bugs in the resolver or places that make bad assumptions. I missed this particular case, though.
bors [Mon, 2 Mar 2020 18:05:34 +0000 (18:05 +0000)]
Auto merge of #7956 - ehuss:fix-collision-test, r=alexcrichton
Fix rare failure in collision_export test.
Seen once on CI in #7952 (https://dev.azure.com/rust-lang/cargo/_build/results?buildId=22112&view=logs&j=a5e52b91-c83f-5429-4a68-c246fc63a4f7&t=d4864165-4be3-5e34-b483-a6b05303aa68). I was able to reproduce it locally, though it is rare. There seems to be some kind of race issue on macOS with two processes trying to symlink the same directory at the same time. The solution is to serialize the build so they don't run at the same time.
bors [Mon, 2 Mar 2020 17:38:11 +0000 (17:38 +0000)]
Auto merge of #7947 - quark-zju:ignore-broken-git, r=ehuss
Ignore broken Cargo.toml in git sources
Commit 3d6de4177489a5d450f35e92288512be85492678 (#3998) made cargo
ignore Cargo.toml files that are invalid TOML in a git source.
This change further ignores Cargo.toml files that are valid TOML but
cannot really be loaded in a git source.
Jun Wu [Fri, 28 Feb 2020 23:52:19 +0000 (15:52 -0800)]
Ignore broken Cargo.toml in git sources
Commit 3d6de4177489a5d450f35e92288512be85492678 (#3998) made cargo
ignore Cargo.toml files that are invalid TOML in a git source.
This change further ignores Cargo.toml files that are valid TOML but
cannot really be loaded.
bors [Thu, 27 Feb 2020 16:37:10 +0000 (16:37 +0000)]
Auto merge of #7934 - ehuss:query-error-context, r=Eh2406
Provide extra context on a query failure.
This adds error context when a query fails, primarily to tell you which parent package included the dependency that failed. For example, imagine deep within your dependency graph you have a `git` dependency, and it fails to download. The current error doesn't tell you where in the graph that `git` dependency was included.
I also slightly tweaked the `failed to load source` error message. I felt like the existing wording could be misinterpreted that it was an error loading the dependency *for* the given package. I felt like there were multiple ways to interpret it, so I tried to simplify it to avoid that possibility.
bors [Thu, 20 Feb 2020 23:04:43 +0000 (23:04 +0000)]
Auto merge of #7905 - ehuss:license-file-updates, r=alexcrichton
Better support for license-file.
This adds some changes to how `cargo package` and `cargo publish` handle the `license-file` field. This also incorporates some refactoring which hopefully makes the code a little clearer and straightforward, but which also resulted in some minor behavior changes.
* Warn if license-file points to a non-existent file.
* Automatically include license-file, even if it is not listed in the `package.include` list (similar to how Cargo.toml/lock are automatically included).
* If license-file points outside of the package root, copy the file to the package root (and rewrite the field in Cargo.toml).
* Files are now sorted when archived.
* `Archiving: Cargo.toml.orig` is explicitly printed where before it did not report that.
* `cargo package --list` now shows `Cargo.toml.orig` where before it was not reported.
bors [Thu, 20 Feb 2020 20:35:44 +0000 (20:35 +0000)]
Auto merge of #7820 - ehuss:features2-split, r=alexcrichton
Add new feature resolver.
This adds a new resolver which handles feature unification independently of the main resolver. This can be enabled with the `-Zfeatures` flag which takes a comma-separated list of options to enable new behaviors. See `unstable.md` docs for details.
There are two significant behavior changes:
1. Ignore targets that are not enabled.
2. Do not unify features between build_deps, dev_deps, and normal deps.
The "forks" in the unit graph are handled by adding `DepKind` to `UnitFor`. The feature resolver tracks features independently for the different dependency kinds.
Unfortunately this currently does not support decoupling proc_macro dependencies. This is because at resolve time it does not know which dependencies are proc_macros. Moving feature resolution to after the packages are downloaded would require massive changes, and would make the unit computation much more complex. Nobody to my knowledge has requested this capability, presumably because proc_macros are relatively new, and they tend not to have very many dependencies, and those dependencies tend to be proc-macro specific (like syn/quote). I'd like to lean towards adding proc-macro to the index so that it can be known during resolve time, which would be much easier to implement, but with the downside of needing to add a new field to the index.
I did not update `cargo metadata`, yet. It's not really clear how it should behave. I think I'll need to investigate how people are currently using the feature information and figure out how it should work. Perhaps adding features to "dep_kinds" will be the solution, but I'm not sure.
The goal is to try to gather feedback about how well this new resolver works. There are two important things to check: whether it breaks a project, and how much does it increases compile time (since packages can be built multiple times with different features). I'd like to stabilize it one piece at a time assuming the disruption is not too great. If a project breaks or builds slower, the user can implement a backwards-compatible workaround of sprinkling additional features into `Cargo.toml` dependencies. I think `itarget` is a good candidate to try to stabilize first, since it is less likely to break things or change how things are built. If it does cause too much disruption, then I think we'll need to consider making it optional, enabled *somehow*.
There is an environment variable that can be set which forces Cargo to use the new feature resolver. This can be used in Cargo's own testsuite to explore which tests behave differently with the different features set.
Eric Huss [Thu, 30 Jan 2020 19:12:23 +0000 (11:12 -0800)]
Ensure dev-dep features are unified if any are used.
There is a complex issue where `cargo test -Zfeatures=dev_dep` was
building things incorrectly if there was a binary executable. The issue
is that lib.rs needed to be built twice (once linked against normal
dependencies, once against dev dependencies), but the current Unit
structure can't distinguish between the two, and thus it was picking the
wrong one.
Instead of allowing `cargo test` to build binaries without
dev-dependency features, just link main.rs against the
dev-dependency-unified versions.
We may need to revisit this in the future, but for now it is not clear
what people want or how this should work. Fixing this would require
substantial changes to how unit dependencies are computed (to properly
handle deduplication), so for now we'll use a simpler solution. It would
also mean `cargo test` would take longer on some projects (because it
would need to build the library 3 times instead of twice).
bors [Thu, 20 Feb 2020 03:25:54 +0000 (03:25 +0000)]
Auto merge of #7906 - ehuss:macos-10.15, r=alexcrichton
Switch azure to macOS 10.15.
Switches CI to the macOS 10.15 image. Since 32-bit support is no longer available, this changes how cross-compile testing works. I decided to use `x86_64-apple-ios` as a cross target, since it can easily build/link on macOS. `cargo run` won't work without a simulator, so some of the tests are restructured to check if `cargo run` is allowed. If you do have a simulator, it should Just Work. CI doesn't seem to be configured with a simulator installed, and I didn't bother to look if that would be possible (the simulators tend to be several gigabytes in size).
An alternative approach would be to use wasm as a cross target, which is also fairly easy to support. But wasm is a sufficiently different target that it can cause some issues in some tests, and is a bit harder to run as an executable.
This also adds some more help text on how to configure cross-compile tests.
Rustup is now installed on macOS by default, so no need to install it. Unfortunately self-updates are not allowed, but hopefully that won't be an issue.
bors [Wed, 19 Feb 2020 20:33:53 +0000 (20:33 +0000)]
Auto merge of #7892 - KaneGreen:rustc-about-text, r=ehuss
Modified the help information of cargo-rustc
### Motivation
The original help information for `cargo build` is
> Compile a local package and all of its dependencies
And the original help information for `cargo rustc` is
> Compile a package and all of its dependencies
These messages are **too similar** to make it difficult to distinguish the differences between the two commands.
According to the [cargo book](https://doc.rust-lang.org/cargo/commands/cargo-rustc.html), `cargo rustc` is characterized by
> pass extra options to the compiler
I think this should be written into the help text of the command.
In addition, the `<args> ...` parameters of `cargo rustc` lack help text and need to be added.
### Modification
See the commit files.
### Problems
Maybe some words in my modification are not accurate enough. If you have better wording, welcome to point out. Thanks.
bors [Tue, 18 Feb 2020 15:24:43 +0000 (15:24 +0000)]
Auto merge of #7697 - ehuss:bin-test-env, r=alexcrichton
Set an environment variable for tests to find executables.
This adds the environment variable `CARGO_BIN_EXE_<name>` so that integration tests can find binaries to execute, instead of doing things like inspecting `env::current_exe()`.
The use of uppercase is primarily motivated by Windows whose Rust implementation behaves in a strange way. It always ascii-upper-cases keys to implement case-insensitive matching (which loses the original case). Seems less likely to result in confusion?
bors [Tue, 18 Feb 2020 14:42:57 +0000 (14:42 +0000)]
Auto merge of #7896 - ehuss:internal-errors, r=alexcrichton
Rework internal errors.
This changes the behavior of "internal" errors, which were previously hidden and only displayed with `--verbose`. The changes here:
- `internal` now means "a cargo bug", and is always displayed and requests that the user file a bug report.
- Added `VerboseError` to signify an error that should only be displayed with `--verbose`. This is only used in one place, to display the `rustc` compiler command if the compiler exited with a normal error code (i.e. not a crash).
- Audited the uses of internal errors, and promoted some to normal errors, as they seemed to contain useful information, but weren't necessarily bugs in cargo.
- Added some details to some errors.
- Sometimes the "run with --verbose" message wasn't being printed when I think it should. This happened when rustc failed while other rustc processes were running. Another case was with `cargo install` installing multiple packages, and one of them fails.
bors [Mon, 17 Feb 2020 00:08:14 +0000 (00:08 +0000)]
Auto merge of #7891 - ehuss:stringlist-fixes, r=Eh2406
Improvements to StringList config handling.
`StringList` was using an untagged enum to deserialize a string or list. Unfortunately, serde does not handle untagged enums very well. The error messages are not very good, and it doesn't interact with untyped deserializers (like our environment variables). This switches it to a newtype struct, and then has hard-coded support for it in the deserializer. This fixes some deserialization errors (like treating `true` as a boolean) and provides better error messages.
`StringList` is currently used for `build.rustflags`, `target.*.rustflags`, and `target.*.runner`.