Commit graph

10897 commits

Author SHA1 Message Date
David Tolnay 396bdd3a89
Remove parsing of broken version syntax from 5 years ago 2021-05-26 14:37:39 -07:00
David Tolnay 3b62e466ec
Update to semver 1.0.0-rc 2021-05-25 17:42:05 -07:00
bors e931e4796b Auto merge of #9486 - Dirbaio:link-arg-bin, r=ehuss
Add `cargo:rustc-link-arg-bin` flag.

This PR implements a `cargo:rustc-link-arg-bin` command to specify per-binary link args from build scripts. This follows the suggestion from the tracking issue #9426.

Syntax is `cargo:rustc-link-arg-bin=BIN_NAME=ARG`

This was previously possible to do using the `#[link_args=".."]` attribute, but it was removed in rust-lang/rust#83820 in favor of the Cargo extra-link-args feature, which can currently not specify different link args for different bins in the same crate. This PR adds back the ability to do that.
2021-05-24 16:17:27 +00:00
bors f898eff9b9 Auto merge of #9473 - lf-:meow, r=ehuss
Add a cargo-doc.browser config option

The idea of this option is to allow cargo to use a separate browser from
the rest of the system. My motivation in doing this is that I want to
write a script that adds a symbolic link in some web root on my system
such that I can access my docs via the http protocol to avoid the
limitations of the file protocol that are accessibility problems for me.
For instance, zoom is not retained across multiple pages and Stylus
filters don't work well.
2021-05-24 15:54:16 +00:00
bors 07340c95c6 Auto merge of #9437 - In-line:unknown-feature-resolver-1, r=ehuss
Fix bug when with resolver = "1" non-virtual package was allowing unknown features
2021-05-24 15:20:48 +00:00
Eric Huss 61b762b9ff Remove unneeded masquerade_as_nightly_cargo.
This was accidentally missed when it was stabilized.
2021-05-24 08:18:14 -07:00
Jade 6128b54b8a docs: cargo-doc.browser -> doc.browser; mention in cargo-{rust,}doc.1 2021-05-20 22:52:49 -07:00
Dario Nieuwenhuis daffd0a42b Add unstable docs for cargo:rustc-link-arg-bin=foo=--bar 2021-05-20 21:50:50 +02:00
Dario Nieuwenhuis 160756368f Add test for cargo:rustc-link-arg-bin=foo=--bar 2021-05-20 21:41:17 +02:00
Dario Nieuwenhuis 5382aa650a Add rustc-link-arg-bin key to specify per-bin link args. 2021-05-20 20:47:54 +02:00
Dario Nieuwenhuis 0895469aec Allow LinkType to access the Target for checking if it applies. 2021-05-20 20:47:12 +02:00
Alik Aslanyan 1839ded4aa
Cargo fmt 2021-05-20 08:36:01 +04:00
Alik Aslanyan 766c3bbcb8 Merge branch 'master' of github.com:rust-lang/cargo into unknown-feature-resolver-1 2021-05-20 08:34:48 +04:00
Alik Aslanyan 2762dcdbe9
Revert fmt 2021-05-20 08:33:57 +04:00
Alik Aslanyan ca0cce760e
Revert unnecessary changes 2021-05-20 08:31:57 +04:00
bors 6ca6dd0bff Auto merge of #9493 - ehuss:contrib-git-url, r=alexcrichton
Add GitHub link to contributor guide.

This adds a small icon on each page that links back to the GitHub source.
2021-05-18 21:48:52 +00:00
bors 0d9bc9dfad Auto merge of #9498 - ehuss:rustup-windows-workaround, r=alexcrichton
Add temporary fix for rustup on windows in CI.

This adds a temporary fix for rustup on the Windows CI runners. The GitHub image updated to rustup 1.24.1 which has an issue (https://github.com/rust-lang/rustup/issues/2759) causing them to fail.  This is fixed in 1.24.2.  I believe the images are updated on roughly a weekly basis, and from what I can see the image just downloads the most recently release, so hopefully this will be fixed on GitHub's side in roughly a week. Until then, this will force rustup to update.

Note: Self updates aren't available on macOS images, but they seem to work on the others.
2021-05-18 20:47:05 +00:00
Eric Huss 65ca4e0d1e Add temporary fix for rustup on windows in CI. 2021-05-18 13:33:35 -07:00
bors f0b39fc853 Auto merge of #9495 - dunkyl:master, r=ehuss
3 typos and some capitalization

3 typos and...

Most of the docs use "command-line" instead of "commandline", changed where it made sense (in plain text).

Most of the docs also use "SemVer" instead of "semver", changed for consistency except for the "semver trick" (consistent with context).

I believe these are the correct files to change, since none of these changes are in doc/man?
2021-05-18 14:05:33 +00:00
dunkyl 4d8c0bb6b2 Capitalization
SemVer

Rust capitalization
2021-05-17 23:05:23 -07:00
dunkyl c4635dabce typo 2021-05-17 22:49:17 -07:00
dunkyl 67900818cf dash-style command-line 2021-05-17 22:18:10 -07:00
dunkyl 49bb10d7ed 2 typos 2021-05-17 22:17:31 -07:00
Eric Huss 073c8f4baf Add GitHub link to contributor guide. 2021-05-17 14:52:37 -07:00
Jade 50486be0c0 testsuite/doc: Check the arguments used to invoke the browser
Previously we apparently weren't doing this as we weren't checking
stdout.
2021-05-15 18:59:24 -07:00
Jade ed46a9a4de test path and args 2021-05-15 14:23:44 -07:00
Jade 6ea1eb3f7e Move browser setting to [doc], use PathAndArgs 2021-05-15 13:23:55 -07:00
bors 44596fa2b1 Auto merge of #9484 - kklibo:master, r=ehuss
fix 6 typos

Fixes #9483
2021-05-14 00:59:52 +00:00
kklibo 50da820e52 fix 6 typos 2021-05-13 17:36:02 -07:00
Alik Aslanyan 503a8670d9
Another way to fix 2021-05-13 11:30:46 +04:00
bors 070e459c2d Auto merge of #9468 - PaulDance:fix-rustdoc-warnings, r=ehuss
Fix rustdoc warnings

Change some small parts of the unit documentation in order to resolve warnings emitted when running `cargo doc` from the root of this project. It should help reduce the noise when checking that new or updated documentation builds correctly.

See the commit messages for details about the modifications themselves, although they should be rather simple.

Cheers,
Paul.
2021-05-11 18:12:23 +00:00
bors f99f96583c Auto merge of #9478 - ehuss:faster-git-status, r=alexcrichton
Improve performance of git status check in `cargo package`.

The check for a dirty repository during packaging/publishing is quite slow. It was calling `status_file` for every packaged file, which is very expensive. I have a directory that had about 10,000 untracked files. Previously, cargo would hang for over 2 minutes without any output. With this PR, it finishes in 0.3 seconds.

The solution here is to collect the status information once, and then compare the package list against it.

One subtle point is that it does not use `recurse_untracked_dirs`, and instead relies on a primitive `starts_with` comparison, which I believe should be equivalent.

This still includes an inefficient n^2 algorithm, but I am too lazy to make a better approach.

I'm moderately confident this is pretty much the same as before (at least, all the scenarios I could think of).
2021-05-11 14:22:21 +00:00
Jade e840c8e81c Add a cargo-doc.browser config option
The idea of this option is to allow cargo to use a separate browser from
the rest of the system. My motivation in doing this is that I want to
write a script that adds a symbolic link in some web root on my system
such that I can access my docs via the http protocol to avoid the
limitations of the file protocol that are accessibility problems for me.
For instance, zoom is not retained across multiple pages and Stylus
filters don't work well.
2021-05-10 21:04:41 -07:00
Eric Huss a200640dbd Improve performance of git status check in cargo package. 2021-05-10 18:15:05 -07:00
bors 7664fd653b Auto merge of #9477 - ehuss:link-test-chapter, r=alexcrichton
Link to the new rustc tests chapter.

There's a new chapter in the rustc book on how the libtest harness works, and the command-line options it offers. This adds a few links to that new chapter in the cargo book.
2021-05-10 23:32:46 +00:00
bors 253fab11c3 Auto merge of #9476 - ehuss:index-cache-bump, r=alexcrichton
Bump index cache version to deal with semver metadata version mismatch.

#9467 has uncovered an issue with how versions are handled in the index cache.  When using a debug build of Cargo, it may panic due to the [cache contents changing](5c455130b6/src/cargo/sources/registry/index.rs (L606-L619)).  The particular problem I am running into is that the index has an entry for `openssl-src 110.0.0` and `110.0.0+1.1.0f`. This is due to an issue with crates.io where it allows publishing multiple versions with the same metadata (https://github.com/rust-lang/crates.io/issues/1059).  Cargos before #9467 would populate the index cache with two entries, both with version `110.0.0`.  Afterwards, there are two separate entries (`110.0.0` and `110.0.0+1.1.0f`).

The change here is to bump the index cache version so that new versions of cargo will clear the cache, and won't trigger the assertion.

This may be a bit of a heavy-handed solution, as I think this only affects debug builds of cargo.  However, I instantly started running into this problem, so I suspect it will be a real annoyance for anyone developing cargo. Happy to discuss other possible solutions.
2021-05-10 23:04:32 +00:00
Eric Huss c2e0d756b7 Link to the new rustc tests chapter. 2021-05-10 15:31:44 -07:00
Eric Huss 7d0c068642 Bump index cache version. 2021-05-10 15:15:26 -07:00
bors e5fdd481b1 Auto merge of #9475 - PaulDance:fix-test-support-warning, r=ehuss
Fix Url::into_string deprecation warning

```rust
warning: use of deprecated associated function `url::Url::into_string`: use Into<String>
   --> src/registry.rs:183:26
    |
183 |                 dl_url().into_string(),
    |                          ^^^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default
```

is being emitted when running `cargo build` directly from the `crates/cargo-test-support` or the `crates/mdman` crate. This simply proposes a switch to the recommended method in order to resolve the deprecation warning.
2021-05-10 21:39:52 +00:00
Paul Mabileau a5b4b4710a
Bump url to 2.2.2 where Into<String> for Url is used
The base package, `cargo-test-support` and `mdman`.

Signed-off-by: Paul Mabileau <paulmabileau@hotmail.fr>
2021-05-10 22:20:11 +02:00
Paul Mabileau c021ba9acf
Fix Url::into_string deprecation warning
`url::Url::into_string` is deprecated. The `Into<String>` implementation
is now used.

Signed-off-by: Paul Mabileau <paulmabileau@hotmail.fr>
2021-05-10 22:19:00 +02:00
bors 5c455130b6 Auto merge of #9469 - PaulDance:fossil-local-settings, r=ehuss
Fix #4482 and #9449: set Fossil ignore and clean settings locally

This aims to close #4482 and close #9449.

Context: currently, the Fossil extension for `cargo new` would call `fossil settings [...]` in order to configure the created repository to ignore and allow cleaning the `target` build directory. However, as #9449 shows, it is ran from the CWD, which is probably outside of the repo, therefore it modifies global settings instead of local ones. This PR fixes that by writing the settings to local versioned files as the issue recommends.

Furthermore, as #9449 notes, configuring the repository's ignore settings only in `util::vcs::FossilRepo::init` means it is not done when the repository is not new and makes it harder to maintain equivalent support for VCS ignore system implementations. It also completely ignores the `--lib` CLI option which adds `Cargo.lock` to the ignore list for Git and Mercurial.

Therefore, the following modifications have been performed, using [the Fossil documentation](https://fossil-scm.org/home/doc/trunk/www/globs.md) as a reference for the ignore syntax:

 * All settings logic has been removed from `FossilRepo::init`.
 * `ops::cargo_new::IgnoreList::push` now requires a third argument for Fossil-specific glob syntax that is stored in a new `fossil_ignore` field.
 * `IgnoreList::format_new` uses the `fossil_ignore` field when needed just like any other VCS.
 * `IgnoreList::format_existing` handles Fossil separately for a few operations as its glob syntax does not support comments, so any lines starting with `#` cannot be included: the configurations can only be merged here.
 * `write_ignore_file` has been modified a bit as well to enable writing to two files for Fossil specifically in order to keep supporting its cleaning feature. The return type of the function is now `CargoResult<()>` instead `CargoResult<String>`: it makes the implementation easier and as the return value was actually not used, I figured it would be okay to do so, plus that return value would not make too much sense anymore for Fossil because of the two possibly different file contents.
 * `mk` has been updated to provide the correct ignore glob to `IgnoreList::push` for Fossil.
2021-05-10 17:26:27 +00:00
bors 5b37ab3c7e Auto merge of #9472 - r00ster91:bettererrors, r=alexcrichton
Improve two error messages

The first error message saying "an integer" is confusing because if you give it `4` it's an integer but it will still complain that it must be an integer. So it's more specific now and tells you that it actually needs to be `1`, `2` or `3`.
In the second error there was a space missing. It says `is not a valid setting,must be`.
2021-05-10 15:35:17 +00:00
r00ster91 b381fdb71e Improve two error messages 2021-05-10 17:28:19 +02:00
bors 45924225e9 Auto merge of #9467 - ehuss:install-metadata, r=alexcrichton
Fix `cargo install` with a semver metadata version.

This fixes an issue where `cargo install cargo-c --version 0.8.0+cargo-0.51` fails (returns a 404 error when downloading) when the index has not yet been populated through other means. The crux of the issue is that the `PackageId` interner was treating `0.8.0+cargo-0.51` and `0.8.0` the same. Due to a chain of events, the interner was getting populated with `0.8.0` first, and then from there on always returned `0.8.0`. The full version information is needed to construct the download URL, so it was failing.

The reason the interner was getting populated with a version without the metadata is the following sequence of events:

1. There is [this "fast path" code path](d1baf0d81d/src/cargo/ops/cargo_install.rs (L570)) which checks if a version of a package is already installed *before updating the index*.
2. Since the index doesn't exist yet, the resolver query returns zero entries (because the Registry Source is empty) [here](d1baf0d81d/src/cargo/ops/common_for_install_and_uninstall.rs (L546-L550)).
3. That code checks if the package has been yanked (because it can't tell the difference between "yanked" and "index not downloaded, yet").
4. It constructs a `PackageId` using a `VersionReq` where the build metadata has been removed (because version reqs don't have build metadata).
5. When the real install continues (the error here is ignored for the purpose of this fast-path check if it is already installed), it downloads the index. However, the `PackageId` values created when parsing the index JSON files are now missing the build metadata because the interner is returning the wrong entries.
6. When the download starts, the URL is built from the `PackageId` missing the build metadata.

I only changed `PackageIdInner` to pay attention to the build metadata. This seems a bit fragile, as perhaps `PackageId` should also pay attention to it. However, I don't really want to do an audit of every use of `PackageId`, and offhand I can't think of other situations where it would matter.

Closes #9410
2021-05-10 13:47:40 +00:00
Paul Mabileau 6801c49c9c
Set Fossil ignore and clean settings locally
Previously, the Fossil extension for `cargo new` would call `fossil
settings [...]` in order to configure the created repository to ignore
and allow cleaning the `target` build directory. However, as #9449
shows, it is ran from the CWD, which is probably outside of the repo,
therefore it modifies global settings instead of local ones. This aims
to fix that by writing the settings to local versioned files as the
issue recommends.

Signed-off-by: Paul Mabileau <paulmabileau@hotmail.fr>
2021-05-10 00:59:02 +02:00
Paul Mabileau 9ea1cbdeda
Fix doc warnings for cargo-util::paths
Add parentheses to disambiguate from `write!`.

Signed-off-by: Paul Mabileau <paulmabileau@hotmail.fr>
2021-05-09 19:47:08 +02:00
Paul Mabileau 2daf97c2e5
Resolve doc warnings for RegistryData
Specify `Self::finish_download` instead of just `finish_download` and
link to `crate::core:📦:Downloads` instead of `Download` as
`Downloads` is the public one, does the actual stuff and `Download` only
stores data.

Signed-off-by: Paul Mabileau <paulmabileau@hotmail.fr>
2021-05-09 19:37:13 +02:00
Paul Mabileau acf157690a
Fix rustdoc warnings for RegistrySource and RegistryData
Inline the link targets directly in the text.

Signed-off-by: Paul Mabileau <paulmabileau@hotmail.fr>
2021-05-09 19:25:45 +02:00
Paul Mabileau d7122e691e
Remove rustdoc warnings for core::features
Link `CliUnstable::add` just to `CliUnstable` instead.

Signed-off-by: Paul Mabileau <paulmabileau@hotmail.fr>
2021-05-09 19:14:52 +02:00