Commit graph

11793 commits

Author SHA1 Message Date
Aleksey Kladov 0468cd6db4 doc: it's valid to use OUT_DIR for intermediate artifacts
Eg, storing `.o` files in OUT_DIR is ok! See
https://github.com/rust-lang/cargo/issues/9661#issuecomment-1021029381
for some discussion.
2022-01-25 13:22:48 +03:00
bors 9978fd72c8 Auto merge of #10324 - ehuss:fix-doc-undocumented-dep, r=alexcrichton
Fix documenting with undocumented dependencies.

#10201 introduced a bug where dependencies that have `doc=false` weren't being built at all when running `cargo doc` if the project did not have any binaries.  That means the rmeta file was missing, and the `--extern` flag was not being passed to rustdoc.

The solution is to ensure the `rmeta` file gets generated, but only skip generating the `CompileMode::Doc` unit for undocumented dependencies.

This unblocks the bootstrap bump.
2022-01-25 04:48:08 +00:00
Eric Huss fdeb38b903 Fix documenting with undocumented dependencies. 2022-01-24 17:10:05 -08:00
bors 58790d3b5e Auto merge of #10305 - weihanglo:issue-10268, r=alexcrichton
do not compile test for bins flagged as `test = false`

### What does this PR try to resolve?

Fixes #10268

#6683 introduced a behavior that compiles all bin targets, but for bins with `test = false` they shouldn't be compiled with `--test` as testbins.

### How should we test and review this PR?

In the first commit of this PR, I refines the test `test_filtered_excludes_compiling_examples` to reflect the current wrong behavior (test passed). The following two commits correct the behavior and the test accordingly. The last few commits encapsulate scattered target selection logic into functions on `CompileFilter`.
2022-01-20 15:07:43 +00:00
Weihang Lo 2f5b3033f2
Update doc for CompileFilter 2022-01-20 13:02:17 +08:00
Weihang Lo ecbaec1a9f
Use new_all_targets in cargo-fix when no target selection exists 2022-01-20 13:02:17 +08:00
Weihang Lo 0a73f8b9fd
Extract logic of single bin target filter to single_bin 2022-01-20 13:02:17 +08:00
Weihang Lo 5aa985c42a
Extract logic of lib target only filter to lib_only 2022-01-20 13:02:05 +08:00
Weihang Lo 9138c35d8c
Extract logic of all test target filter to all_test_targets 2022-01-20 13:01:54 +08:00
bors bb96b3a3e8 Auto merge of #10086 - epage:toml, r=ehuss
Port cargo from toml-rs to toml_edit

Benefits:
- A TOML 1.0 compliant parser
- Unblock future work
  - Have `cargo init` add the current crate to the workspace, rather
    than error
  - #5586: Upstream `cargo-add`

TODO
- [x] Analyze performance and address regressions
- [x] Identify and resolve incompatibiies
- [x] Resolve remaining test failures, see
      https://github.com/ordian/toml_edit/labels/cargo
- [x] ~~Switch the code from https://github.com/rust-lang/cargo/pull/10176 to only parse once~~ (this PR is being merged first)
2022-01-20 03:56:18 +00:00
bors 7e89966d6c Auto merge of #10306 - eholk:git-default-branch, r=alexcrichton
Fix new::git_default_branch with different default

The test `new::git_default_branch` would fail if the current user had already configured a different default branch.

This patch changes the test to first write a `.gitconfig` file with the default branch set to master. This puts us in a state where we still have the old default, and then the subsequent change to the config file will make sure that config changes are still respected.
2022-01-19 17:09:36 +00:00
Eric Holk 1683cd5eec Refactor create_empty_config to create_default_config 2022-01-19 08:45:03 -08:00
Eric Holk 40c51392dd Fix new::git_default_branch with different default
The test new::git_default_branch would fail if the current user had
already configured a different default branch.

This patch changes the test to first write a .gitconfig file with the
default branch set to master. This puts us in a state where we still
have the old default, and then the subsequent change to the config file
will make sure that config changes are still respected.
2022-01-18 14:51:21 -08:00
Weihang Lo bee3534f27
test: do not compile test for bins flagged as test = false 2022-01-19 03:36:53 +08:00
Weihang Lo 0a7a7bd5ef
do not compile test for bins flagged as test = false
Binaries without `test = false` are included by default, so no need to
explicitly compile all binaries.
2022-01-19 03:35:35 +08:00
Weihang Lo f07dcd13a0
test: compile all bins when TESTNAME arg exists
This behavior is not correct should be fixed.
Update this test only for pointing out the current behavior.
2022-01-19 02:47:30 +08:00
bors 95bb3c92bf Auto merge of #10243 - hi-rustin:rustin-patch-collision, r=ehuss
Error when setting crate type of both dylib and cdylib in library

close https://github.com/rust-lang/cargo/issues/10231

Error when setting crate type of both dylib and cdylib in library. Cargo can't support that at this time, since they both output the same filename.
2022-01-18 17:39:35 +00:00
bors 528ab12353 Auto merge of #10300 - ehuss:list-help, r=alexcrichton
Include `help` in `--list`

This adds the `help` subcommand to the `--list` output. It previously was not included because `help` is handled differently from built-in subcommands.
2022-01-18 16:34:43 +00:00
bors c2950c83ef Auto merge of #10295 - ehuss:bash-report, r=alexcrichton
Add report subcommand to bash completion.

This adds the `cargo report` subcommand to the bash completion.
2022-01-18 15:59:45 +00:00
bors 03e24bcf67 Auto merge of #10296 - ehuss:downgrade-log, r=alexcrichton
Downgrade some log messages.

This lowers the log level of several "info" messages. I find that these can be quite noisy when using log messages, and I don't think need to be such a high log level.
2022-01-18 15:15:28 +00:00
Eric Huss b655a8965c Include help in --list 2022-01-16 11:14:04 -08:00
bors e778b3d90a Auto merge of #10298 - hi-rustin:rustin-patch-triagebot, r=ehuss
Enable shortcut for triage bot

### What does this PR try to resolve?

Enable shortcut for triage bot. See: https://github.com/rust-lang/cargo/pull/10167#issuecomment-1013815453
### How should we test and review this PR?

We need to test it after the merge. But there should be no problem with the robot. I refer to the rust configuration file.

### Additional information

I don't know if it is accepted to open it, if we don't want to open it please feel free to close my PR.
2022-01-16 17:02:31 +00:00
hi-rustin 3738002e43 Error when setting crate type of both dylib and cdylib in library
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-01-16 17:38:43 +08:00
hi-rustin 22bcd7a7ed Enable shortcut for triage bot
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-01-16 13:52:52 +08:00
Eric Huss f0aae40f00 Downgrade some log messages. 2022-01-15 14:16:50 -08:00
bors 6d19e80192 Auto merge of #10294 - ehuss:version-bump, r=Eh2406
Bump to 0.61.0, update changelog
2022-01-15 16:42:51 +00:00
Eric Huss 56e5b398c6 Add report subcommand to bash completion. 2022-01-14 14:11:52 -08:00
Eric Huss 171f67d6a9 Update changelog for 1.59 2022-01-14 13:38:39 -08:00
Eric Huss a25d3864d9 Bump to 0.61.0 2022-01-14 10:57:54 -08:00
bors 203f36ed61 Auto merge of #10291 - calebcartwright:cargo-fmt-check, r=ehuss
use new cargo fmt option

As of v1.58, cargo fmt now supports the --check flag directly. Updating it here (and in a few other r-l repos) both because it's more succinct and so more people will see/become aware
2022-01-14 00:21:19 +00:00
Caleb Cartwright 98edf2854b
ci: use new cargo fmt option 2022-01-13 17:57:25 -06:00
bors d43a5073e8 Auto merge of #10287 - Nilstrieb:docs-semver-check-run-fail, r=ehuss
Add `run-fail` to semver-check for docs

I encountered this missing feature in #10276 and therefore added it here in this separate PR.

If the breaking change does not involve a compilation error but a change in runtime behaviour, you can add `run-fail` to the codeblock. The "before" code must return exit code 0, and the "after" code must be nonzero (like a panic).

Example case that I tested (ignore the trailing dot, it's for github markdown to not hate me)

```
```rust,ignore,run-fail
// MAJOR CHANGE

///////////////////////////////////////////////////////////
// Before
pub fn foo() {}
///////////////////////////////////////////////////////////
// After
pub fn foo() {
    panic!("hey!");
}
///////////////////////////////////////////////////////////
// Example usage that will break.
fn main() {
    updated_crate::foo();
}
```.
```
2022-01-13 23:38:53 +00:00
bors c6745a3d7f Auto merge of #10290 - maxwase:is_symlink_stabilized, r=Eh2406
Use `is_symlink()` method

I've came across this comment
```rust
// Replace with std implementation when stabilized, see
// https://github.com/rust-lang/rust/issues/85748
```
and fixed this due to the method stabilization in 1.58
2022-01-13 22:42:26 +00:00
maxwase 2623af0c43 Use is_symlink() method 2022-01-14 00:36:24 +03:00
Ed Page 320c279f43 Port cargo from toml-rs to toml_edit
Benefits:
- A TOML 1.0 compliant parser
- Unblock future work
  - Have `cargo init` add the current crate to the workspace, rather
    than error
  - #5586: Upstream `cargo-add`
2022-01-13 09:27:27 -06:00
Nilstrieb 6865218f15 docs: add run-fail to semver check
if the breaking change does not involve a compilation error but a change in runtime behaviour, you can add `run-fail` to the codeblock. The "before" code must return exit code 0, and the "after" code must be nonzero (like a panic).
2022-01-12 20:43:14 +01:00
bors e77c0719fd Auto merge of #10269 - ehuss:stabilized-new-features, r=alexcrichton
Stabilize namespaced and weak dependency features.

This stabilizes the namespaced and weak dependency features.  Support is now enabled on crates.io, so this should be ready to go.

As a part of this change, the new feature resolver is now enabled all of the time. This is fairly risky, since there are likely edge cases that haven't been exercised.
NOTE: Projects using `resolver="1"` *should* continue to have the same behavior, the old resolver behavior is emulated.

Closes #8813
Closes #8832
2022-01-12 15:15:09 +00:00
bors 06b9d31743 Auto merge of #10265 - epage:clap-port, r=joshtriplett
Port cargo to clap3

### What does this PR try to resolve?

This moves cargo to the latest major version of clap.

This supersedes #10259  and #10262

### How should we test and review this PR?

For testing, I mostly relied on existing tests.  I did manually validate that `cargo run <non-escaped command args>` behaved the same between both
```console
$ cargo run release --help
    Finished dev [unoptimized + debuginfo] target(s) in 0.22s
     Running `target/debug/cargo-release release --help`
cargo-release 0.18.8
...

$ cargo run --manifest-path ../cargo/Cargo.toml -- run release --help
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `/home/epage/src/personal/cargo/target/debug/cargo run release --help`
    Finished dev [unoptimized + debuginfo] target(s) in 1.31s
     Running `target/debug/cargo-release release --help`
cargo-release 0.18.8
...
```

For reviewing, I split out each deprecation resolution into a separate commit so its easy to focus on more mechanical changes (most of the deprecation fixes) from interesting ones (the port, the `Arg::multiple` deprecation)

### Additional information

- One parser change found by `cargo_config::includes` is that clap 2
  would ignore any values after a `=` for flags.
  `cargo config --show-origin` is a flag but the test passed `--show-origin=yes` which
  happens to give the desired result for that test but is the same as
  `--show-origin=no` or `--show-origin=alien-invasion`.
- `ArgMatches` now panics when accessing an undefined argument but clap
  takes advantage of that for sharing code across commands that have
  different subsets of arguments defined.  I've extended clap so we can
  "look before you leap" and put the checks at the argument calls to
  start off with so its very clear what is tenuously shared.  This
  allows us to go in either direction in the future, either addressing
  how we are sharing between commands or by moving this down into the
  extension methods and pretending this clap feature doesn't exist
- On that topic, a test found clap-rs/clap#3263.  For now, there is a
  hack in clap.  Depending on how we fix that in clap for clap 4.0, we
  might need to re-address things in cargo.
- `value_of_os` now requires setting `allow_invalid_utf8`, otherwise it
  asserts.  To help catch this, I updated the argument definitions
  associated with lookups reported by:
  - `rg 'values?_os' src/`
  - `rg 'values?_of_os' src/`
- clap now reports `2` for usage errors, so we had to bypass clap's
  `exit` call to keep the same exit code.
- `cargo vendor --sync` did not use `multi_opt` and so it has both
  multiple occurrences **and** multiple values.  If we want to deprecate
  this, we'll need `unstable-grouped` to be stablized (or pin our clap
  version) and ensure each group has only 1 value.
2022-01-11 23:47:29 +00:00
bors 0655dd25a0 Auto merge of #10217 - zhamlin:feat/profile-rustflags, r=ehuss
feat: support rustflags per profile

Fix for issue https://github.com/rust-lang/cargo/issues/7878
2022-01-10 16:56:16 +00:00
Zach Hamlin 68fd67319d feat: support rustflags per profile 2022-01-09 11:35:15 -06:00
Eric Huss 43a063c80a Stabilize namespaced and weak dependency features. 2022-01-06 15:56:56 -08:00
bors aee9262070 Auto merge of #10267 - joshtriplett:pr-template-bors-comments, r=alexcrichton
Make bors ignore the PR template so it doesn't end up in merge messages
2022-01-06 21:52:20 +00:00
Josh Triplett c1a5a4c6b2 Make bors ignore the PR template so it doesn't end up in merge messages 2022-01-06 12:24:12 -08:00
Ed Page 92fa72d480 refactor: Resolve Arg::multiple deprecation
Note: `cargo vendor --sync` did not use `multi_opt` and so it has both
multiple occurrences **and** multiple values.  If we want to deprecate
this, we'll need `unstable-grouped` to be stablized (or pin our clap
version) and ensure each group has only 1 value.
2022-01-06 09:18:14 -06:00
Ed Page 6e08a30e26 refactor: Resolve SubCommand::with_new deprecation 2022-01-06 09:14:12 -06:00
Ed Page 24f301b3e1 refactor: Resolve App::settings deprecation 2022-01-06 09:14:08 -06:00
Ed Page 0ab4d0cbfa refactor: Resolve App::help deprecation 2022-01-06 09:14:02 -06:00
Ed Page 5cd062e4dc refactor: Resolve App::template deprecation 2022-01-06 09:13:58 -06:00
Ed Page aed031253a refactor: Resolve App::usage deprecation 2022-01-06 09:13:54 -06:00
Ed Page f9b28cfbba refactor: Resolve App::get_matches_safe deprecation 2022-01-06 09:13:51 -06:00