Impl warn for locked install without Cargo.lock
If we're installing in --locked mode and there's no `Cargo.lock` published
ie. the bin was published before https://github.com/rust-lang/cargo/pull/7026
the cargo install errors were not stating that it was due to the lack of
the `Cargo.lock` file. Instead, the error seemed completely unrelated.
Therefore, this tries to address this by adding a warn in the stderr
output.
Closes#9106
I will need some help on the testing side (assuming the code I added for the warning is correct).
It looks to me that the publish function implemented for testing purposes does not publish `Cargo.lock` which is the actual convention. Should this be updated too? See #7026
Document -Z extra-link-arg.
Whilst reading the cargo source code, I encountered `-Z extra-link-arg`. I'd missed this flag before because it is not documented in `-Z help`.
This commit adds the one-liner documentation.
([This argument **is** mentioned in the unstable cargo book](https://doc.rust-lang.org/beta/cargo/reference/unstable.html#extra-link-arg))
Flip 'foo' and 'bar' to be consistent
The "Renaming dependencies" section initially uses 'foo' as the crate name and 'bar' as a rename, but then swaps them and uses 'bar' as the example crate name in the context of optional dependencies. Now both examples in this section treat 'foo' as the original crate name.
The "Renaming dependencies" section initially uses 'foo' as the crate name and 'bar' as a rename, but then swaps them and uses 'bar' as the example crate name in the context of optional dependencies. Now both examples in this section treat 'foo' as the original crate name.
Don't try to parse MSRV if feature is not enabled
`@ehuss` is something like this what you had in mind? Should we add tests to make sure this works correctly?
If we're installing in --locked mode and there's no `Cargo.lock` published
ie. the bin was published before https://github.com/rust-lang/cargo/pull/7026
the cargo install errors were not stating that it was due to the lack of
the `Cargo.lock` file. Instead, the error seemed completely unrelated.
Therefore, this tries to address this by adding a warn in the stderr
output.
Closes#9106
Minor update to tracking issue template.
Just some minor tweaks, move the "about" to the bottom since it isn't that important (I think the summary should be first). Also add a link to an RFC if it is an RFC.
Add some extra help to `cargo new` and invalid package names.
Binaries are not as restricted as package names, so provide some help in case the user really wants a binary with that name.
Closes#8829
Remove Registry::new.
`Registry::new` doesn't work in most circumstances because crates.io requires a user-agent, and it does not set one.
This also bumps the version over 0.32 due to #8914.
Closes#8914.
Closes#9040.
Unstable updates
This is a collection of updates for unstable/nightly feature support, intended to provide better messages for users and better internal and external documentation. Separated by commit, in summary:
* Added comments and new docstrings for improved internal documentation.
* Added new documentation to the reference guide on how unstable things work.
* Also added redirects for stabilized features so any external links won't be broken.
* Add a targeted error message if you put `cargo-features` in the wrong place in `Cargo.toml`.
* Remove `publish-lockfile`. The feature was stabilized without the key in #7026 about 1.5 years ago. Also added "removed" support for features, which prints out a more helpful error message.
* Add help messages about stabilized `-Z` flags (instead of spitting out an unhelpful error message).
* Add help messages about stabilized `cargo-features` features.
* Add more context to the error when using `cargo-features` on stable.
* Unhide nightly CLI flags. I changed my mind on how these should work. I think it is useful to "advertise" the existence of these options on stable. The error message if you try to use it should help guide on what to do.
Closes#9074.
Previously, when something was stabilized, Cargo would spit out a very
unhelpful error message about an unknown -Z flag. This changes it so
that it displays a helpful warning (or error).
I changed my mind on how these should work. I think it is useful to
"advertise" the existence of these options on stable. The error message
if you try to use it should help guide on what to do.
Fix some issues with `cargo doc` and the new feature resolver.
This contains two related commits fixing some issues with `cargo doc` and the new feature resolver.
The first commit fixes a panic. The old code was using `UnitFor::new_normal` when computing doc units, but this was wrong. That essentially circumvents the new feature resolver, and breaks determining the correct features to use. I don't remember exactly what I was thinking when I wrote that, other than "rustdoc shouldn't care", but it does matter.
Unfortunately changing that makes collisions worse because it aggravates #6313, so the second commit adds some logic for removing some collisions automatically. Specifically:
- Prefers dependencies for the target over dependencies for the host (such as proc-macros).
- Prefers the "newest" version if it comes from the same source.
There are still plenty of situations where there can be collisions, but I'm uncertain on the best way to handle those.
Fixes#9064
Implement support for rust-version field in project metadata
Needs a bunch more work, but I'd like some early feedback! Remaining work:
- [x] Bikeshedding name (picked `rust-version` here over `msrv` or `min-rust-version`)
- [x] Failing test for local dependency with unsatisfied MSRV
- [x] Requirement cannot be smaller than 1.27
- [x] Requirement cannot be smaller than initial release of edition used
- [x] Check for `run`, `verify` and `publish` subcommands
- [x] More tests (would love feedback on this)
- [x] Handle pre-release identifiers
- [x] Disallow semver range operators
- [x] Feature gate it
- [x] Add documentation for unstable feature
Minimal version of `@moxian's` earlier take in #7801.
cc rust-lang/rust#65262
Fix a bug in Cargo's cyclic dep graph detection
Cargo's cyclic dependency graph detection turns out to have had a bug
for quite a long time as surfaced by #9073. The bug in Cargo has to do
with how dev-dependencies are handled. Cycles are "allowed" through
dev-dependencies because the dev-dependency can depend on the original
crate. Our cyclic graph detection, however, was too eagerly flagging a
package as known to not have a cycle before we had processed everything
about it.
The fix here was basically to just simplify the graph traversal. Instead
of traversing the raw `Resolve` this instead creates an alternate
in-memory graph which has the actual edges we care about for cycle
detection (e.g. every edge that wasn't induced via a dev-dependency).
With this simplified graph we then apply the exact same algorithm, but
this time it should be less buggy because we're not trying to do funky
things about switching sets about what's visited halfway through a
traversal.
Closes#9073
There are some cases where `cargo doc` will try to document two things
with the same crate_name. This attempts to automatically remove some of
those duplicates based on some rules:
- Prefers dependencies for the target over dependencies for the host
(such as proc-macros).
- Prefers the "newest" version if it comes from the same source.
There are still plenty of situations where there can be collisions, but
I'm uncertain on the best way to handle those.
Cargo's cyclic dependency graph detection turns out to have had a bug
for quite a long time as surfaced by #9073. The bug in Cargo has to do
with how dev-dependencies are handled. Cycles are "allowed" through
dev-dependencies because the dev-dependency can depend on the original
crate. Our cyclic graph detection, however, was too eagerly flagging a
package as known to not have a cycle before we had processed everything
about it.
The fix here was basically to just simplify the graph traversal. Instead
of traversing the raw `Resolve` this instead creates an alternate
in-memory graph which has the actual edges we care about for cycle
detection (e.g. every edge that wasn't induced via a dev-dependency).
With this simplified graph we then apply the exact same algorithm, but
this time it should be less buggy because we're not trying to do funky
things about switching sets about what's visited halfway through a
traversal.
Closes#9073
Sort available binaries when multiple
From:
```
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: basic-tutorial-13, basic-tutorial-6, basic-tutorial-1, basic-tutorial-4, basic-tutorial-9, basic-tutorial-2, basic-tutorial-3, basic-tutorial-5, basic-tutorial-12, playback-tutorial-4, basic-tutorial-8, basic-tutorial-7
```
To:
```
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: basic-tutorial-1, basic-tutorial-12, basic-tutorial-13, basic-tutorial-2, basic-tutorial-3, basic-tutorial-4, basic-tutorial-5, basic-tutorial-6, basic-tutorial-7, basic-tutorial-8, basic-tutorial-9, playback-tutorial-4
```