fix(install): Keep v1 file formatting the same
Inspired by #10345, I looked for other cases where
`toml_edit::easy::to_string` is used (which outputs inline tables) to
see if we should switch to `to_string_pretty`. The crates v1 file was
the only case I found.
As a side effect, we can no longer elide the empty `dev-dependencies`
table in published manifests. This was the behavior before `toml_edit`,
so not much of a loss.
Do not ignore `--features` when `--all-features` is present
This allows to specify dependency features when using `--all-features`, for example:
```shell
$ cargo run --example example --all-features --features="tracing/log"
```
You can test this in this repository: https://github.com/WaffleLapkin/cargo_all_some_features, it contains an example with ``required-features = [..., "tracing/log"]`` that is impossible to run with `--all-features` without this patch.
An attempt to fix#10333
test: Fix compatibilty with new toml_edit
`toml_edit` fixed a bug in 0.13.4 that this test was relying on that is
meant to help with rust-lang/cargo#10349. This basically restores us
back to the pre-toml_edit behavior for published manifests.
I included the `Cargo.toml` change to ensure any existing lock files on people's machines get updated so the test won't mysteriously start failing for them when doing a `pull`.
`toml_edit` fixed a bug in 0.13.4 that this test was relying on that is
meant to help with rust-lang/cargo#10349. This basically restores us
back to the pre-toml_edit behavior for published manifests.
Inspired by #10345, I looked for other cases where
`toml_edit::easy::to_string` is used (which outputs inline tables) to
see if we should switch to `to_string_pretty`. The crates v1 file was
the only case I found.
As a side effect, we can no longer elide the empty `dev-dependencies`
table in published manifests. This was the behavior before `toml_edit`,
so not much of a loss.
extra-link-arg-etc: support all link types (credit @davidhewitt)
This commit adds support for the remaining link types to `-Zextra-link-arg-etc`:
`
rustc-link-arg-tests
rustc-link-arg-benches
rustc-link-arg-examples
`
This would be useful in PyO3, where users writing Python extension modules (which do link against libpython) want to run cargo tests for extension module. As executables, these tests need to link against libpython.
This is a follow up of https://github.com/rust-lang/cargo/pull/9416 by `@davidhewitt`
This allows to specify dependency features when using `--all-features`,
for example:
```shell
$ cargo run --package a --example example --all-features --features="tracing/log"
```
Update publishing link for semver rules.
This updates the publishing guide to point to the chapter on SemVer rules which is more complete and up-to-date than RFC 1105.
For `Workspace::find_root`, `cargo_util::path::PathAncestors` won't do
path normalization while walking back the ancestors. The responsibility
lies in the caller. Thus, `cargo install` should normalize its `--path`
argument before passing in `SourceId::for_path` and `Workspace::new`.
`Config::reload_rooted_at` is not affected because cargo always starts
searching and merging configs from where it is invoked.
Remove deprecated --host arg for search and publish cmds
### What does this PR try to resolve?
close https://github.com/rust-lang/cargo/issues/10304
### How should we test and review this PR?
Remove deprecated --host arg for search and publish cmds.
Use local git info for version.
#10178 caused an unintended change where cargo is being built twice in rust-lang/rust's CI. It is being built once as a CLI, and a second time for RLS. The cause is the `CFG_COMMIT_HASH` environment variable changes between those two builds (it is set for the tool being built).
The solution here is to grab the git information from cargo's own build script. This is guaranteed to always be in the `src/tools/cargo` directory for both tools.
This should help save a minute or two in the dist builders.
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.
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`.
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)