Commit graph

10370 commits

Author SHA1 Message Date
bors e099df243b Auto merge of #9108 - CPerezz:locked_warn, r=alexcrichton
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
2021-02-01 16:24:34 +00:00
bors c6f2815698 Auto merge of #9121 - vext01:extra-link-arg-doc, r=alexcrichton
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))
2021-02-01 15:39:10 +00:00
bors 4e4490f337 Auto merge of #9120 - dimo414:patch-1, r=alexcrichton
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.
2021-02-01 15:06:07 +00:00
Edd Barrett 0b515f38b0 Document -Z extra-link-arg. 2021-02-01 14:51:50 +00:00
Michael Diamond 2663d7d3af
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.
2021-01-31 23:27:56 -08:00
bors c5f7fa1bdb Auto merge of #9115 - djc:fix-msrv-handling, r=ehuss
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?
2021-01-30 22:50:11 +00:00
Dirkjan Ochtman 040d27f39d Don't try to parse MSRV if feature is not enabled 2021-01-30 23:14:30 +01:00
CPerezz b526fadca4
Impl warn for locked install withoud 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
2021-01-30 01:09:16 +01:00
bors 8a3361c126 Auto merge of #9110 - klensy:simple-fix, r=alexcrichton
simplify char range check

Instead manually checking ranges for char, use std method.
2021-01-29 15:04:09 +00:00
klensy dcc9587160 trivial char range check 2021-01-29 01:27:16 +03:00
bors c3abcfe8a7 Auto merge of #9097 - ehuss:tracking-issue-template-update, r=alexcrichton
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.
2021-01-25 16:16:43 +00:00
bors 414ccb5d49 Auto merge of #9098 - ehuss:extra-new-name-help, r=alexcrichton
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
2021-01-25 15:46:16 +00:00
bors 17a7b0748d Auto merge of #9102 - alexcrichton:fix-serede, r=ehuss
Fix compilation with serde 1.0.122

This may or may not be a bug in serde, but let's commit a fix here first
in any case.

Closes #9101
2021-01-25 15:16:52 +00:00
Alex Crichton f097d02ea6 Fix compilation with serde 1.0.122
This may or may not be a bug in serde, but let's commit a fix here first
in any case.

Closes #9101
2021-01-25 07:12:39 -08:00
Eric Huss fdb8ea1e03 Add some extra help to cargo new and invalid package names. 2021-01-24 13:21:25 -08:00
Eric Huss 78839fab47 Minor update to tracking issue template. 2021-01-23 07:44:46 -08:00
bors b52fc0a827 Auto merge of #9095 - ehuss:spec-suggestion, r=alexcrichton
Add suggestion for bad package id.

This adds some suggestions to the error message if a pkgid spec does not match any packages.
2021-01-22 23:18:00 +00:00
Eric Huss b04c7fb849 Add suggestion for bad package id. 2021-01-22 13:38:53 -08:00
bors 24cf9c5e0a Auto merge of #9093 - ehuss:remove-registry-new, r=alexcrichton
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.
2021-01-22 19:24:40 +00:00
Eric Huss eaa5896405 Remove Registry::new. 2021-01-22 11:06:51 -08:00
bors 638f33d036 Auto merge of #9035 - weihanglo:fix/git-init-search-path, r=alexcrichton
Fix: set default git config search path for tests

Fixes https://github.com/rust-lang/cargo/issues/8863 by setting the default config search path.

Just wait https://github.com/rust-lang/git2-rs/pull/656 being merged and update Cargo.toml the new release of git2-rs 😄
2021-01-22 15:29:39 +00:00
Weihang Lo 06d65a48f8
chore: bump versions of git2 and libgit2-sys 2021-01-22 23:27:44 +08:00
bors ba3311e714 Auto merge of #9092 - ehuss:unstable-updates, r=alexcrichton
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.
2021-01-21 21:04:12 +00:00
Eric Huss a58e7ffdbc Add redirects on the unstable docs.
This adds some redirects so if there are any links to old documentation,
they will get redirect to new documentation.
2021-01-21 12:17:48 -08:00
Eric Huss 13b0b70da9 Update the user documentation on unstable features.
This attempts to make it clearer on the different ways
unstable features can be activated.
2021-01-21 12:17:48 -08:00
Eric Huss 778b5357be Update the internal documentation on unstable features.
Attempts to make it clearer on how the different kinds of unstable
support works, and clarify the steps for adding new features
and stabilizing.
2021-01-21 12:17:48 -08:00
Eric Huss 7bbef3defe Rework cargo-features a little.
* Add `removed` support.
* Include the version where it is stabilized.
* Include a links to the documentation in the error/warning messages.
2021-01-21 12:16:35 -08:00
Weihang Lo 332887e4aa
test: remove odd semicolon 2021-01-21 14:55:33 +08:00
Weihang Lo 02b49de61c
fix: set search path before init repos 2021-01-21 14:55:30 +08:00
Eric Huss 00615fc51a Add more helpful message with stabilized -Z flags.
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).
2021-01-20 19:46:50 -08:00
Eric Huss ff349f0205 Remove publish-lockfile key from manifest.
The feature was stabilized without the key in #7026 about 1.5 years ago.
(Will follow up with an error message in a subsequent commit.)
2021-01-20 19:31:57 -08:00
Eric Huss d89a78ee19 Add error message for wrong cargo-features placement.
This is intended to help if the user puts cargo-features in the
wrong place in Cargo.toml.
2021-01-20 19:22:51 -08:00
Eric Huss 73b98edc34 Add some comments why some options are hidden. 2021-01-20 19:18:59 -08:00
Eric Huss cf920df38b Unhide nightly-only 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.
2021-01-20 19:16:54 -08:00
bors 783bc43c66 Auto merge of #9077 - ehuss:fix-doc-resolver2-proc-macro, r=alexcrichton
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
2021-01-20 19:02:26 +00:00
Eric Huss c5e3f17f3b Optimize removing unit_deps. 2021-01-20 08:27:36 -08:00
bors 8e075c9cab Auto merge of #8037 - djc:rfc-2495, r=ehuss
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
2021-01-20 16:12:56 +00:00
Dirkjan Ochtman c221fec911 Implement support for rust-version field in project metadata 2021-01-20 11:40:41 +01:00
bors c524fa4e36 Auto merge of #9075 - alexcrichton:fix-cycles, r=ehuss
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
2021-01-18 19:51:07 +00:00
bors f13cb7fa02 Auto merge of #9081 - ximon18:typo-correction, r=ehuss
Typo correction: artifcats -> artifacts
2021-01-15 15:02:30 +00:00
Ximon Eighteen 450b4ac59c
Typo correction: artifcats -> artifacts 2021-01-15 15:24:44 +01:00
bors 49a32afe5f Auto merge of #9079 - lzutao:stray-backtick, r=ehuss
Remove stray backtick from doc

Just a minor typo.
2021-01-15 02:14:36 +00:00
Lzu Tao 206ded3d49 Remove stray backtick from doc 2021-01-15 08:24:37 +07:00
Eric Huss a58b0c589a Remove some doc collisions.
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.
2021-01-14 13:12:24 -08:00
Alex Crichton 4b4dc0a479 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
2021-01-14 10:43:06 -08:00
Dirkjan Ochtman 50cc40bc89 Fix typo in method name 2021-01-13 09:18:14 +01:00
bors a73e5b7d56 Auto merge of #9066 - rubenrua:hotfix_sort_bins, r=ehuss
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
```
2021-01-12 23:45:39 +00:00
bors 7f41cf6f78 Auto merge of #9067 - AnthonyMikh:patch-1, r=ehuss
Fix misspelling of environment variable
2021-01-12 23:16:21 +00:00
AnthonyMikh 159e88a69d Fix misspelling of environment variable 2021-01-13 01:33:35 +03:00
rubenrua eb31d1ae9b Test for sort available binaries when multiple 2021-01-12 23:18:41 +01:00