fix(test): Suggest `--` for libtest arguments
We already do this so long as the argument doesn't look like a `cargo test` argument (e.g. `--show-output`)
but `--ignored` looks like `--ignore-rust-version` do the the suggestion algorithms prefix checks.
Before
```
error: unexpected argument '--ignored' found
tip: a similar argument exists: '--ignore-rust-version'
Usage: cargo test --ignore-rust-version [TESTNAME] [-- [ARGS]...]
For more information, try '--help'.
```
After
```
error: unexpected argument '--ignored' found
tip: a similar argument exists: '--ignore-rust-version'
tip: to pass '--ignored' as a value, use '-- --ignored'
Usage: cargo test --ignore-rust-version [TESTNAME] [-- [ARGS]...]
For more information, try '--help'.
```
This was fixed in clap-rs/clap#5356 and we just need to update to take advantage of it.
Fixes#12494
We already do this so long as the argument doesn't look like a
`cargo test` argument (e.g. `--show-output`)
but `--ignored` looks like `--ignore-rust-version` do the the suggestion
algorithms prefix checks.
Before
```
error: unexpected argument '--ignored' found
tip: a similar argument exists: '--ignore-rust-version'
Usage: cargo test --ignore-rust-version [TESTNAME] [-- [ARGS]...]
For more information, try '--help'.
```
After
```
error: unexpected argument '--ignored' found
tip: a similar argument exists: '--ignore-rust-version'
tip: to pass '--ignored' as a value, use '-- --ignored'
Usage: cargo test --ignore-rust-version [TESTNAME] [-- [ARGS]...]
For more information, try '--help'.
```
Fixes#12494
chore(ci): Drop MSRV:1 patch field
This was missed when I did MSRV:3
This make it less annoying for people to keep up on every patch with their own MSRVs.
Update tests for changes in latest nightly
There were two changes that has caused nightly tests to start failing:
* LLVM was updated, and that caused a change in the expected data layout for the target. (https://github.com/rust-lang/rust/pull/120055 update to LLVM 18)
* https://github.com/rust-lang/rust/pull/121049 Do not point at `#[allow(_)]` as the reason for compat lint triggering. The test was looking for the `unused_variables` note, which is no longer printed.
docs: Minor clarification of build script metadata.
This adds a minor clarification to the build script docs around links metadata. "As mentioned above in the output format" didn't really clue me in to what section it was talking about, or clearly tell me how to set the metadata.
Fix old_cargos tests
Some of these tests have bitrotted a bit since they aren't enabled by default. The issues are:
* Change to `config` to `config.toml` shouldn't have been made to this test since old cargos can't read config.toml.
* Cargo's own `Carog.toml` now using dotted keys breaks parsing on some old versions, ignore them.
* `cargo pkgid` is now emitting a different format.
* #13085 changed how packages are published in the testsuite to correctly include the `[features]` table in the generated `Cargo.toml`. This exposed an oversight in the `old_cargos::new_features` test wasn't actually testing things correctly. It now correctly illustrates the errors received in older versions. I have a vague memory of this, but I don't remember why it was done this way.
* #10907 changed the default config to use `[registries]` instead of `[source]` to implement source replacement of crates.io. Older versions can't handle that.
Some of these tests probably should just be deleted, since I don't think they are really bringing much value. Or at least they should have some floor that they won't test under. However, I'm not quite ready to do that.
Fix confusing error messages for sparse index replaced source
The built-in sparse crates.io index `index.crates.io` is implemented in Cargo using source replacement.
When an error occurs downloading from the sparse index, the message includes text that looks like the user configured source replacement, even when they did not.
This change extends the special case for the built-in replacement of crates.io to include all the error messages for source replacement in addition the the description special case.
fix(compiler): Clarify Finished message
### What does this PR try to resolve?
As highlighted on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/cargo.20build.20default.20profile/near/418316528), many users think "Rust is slow" because of the `dev` profile.
While a perfect solution is still being worked out, this attempts what will hopefully be smaller, incremental step that hopefully maintains balance of the different needs.
We are changing the message from:
```
Finished dev [unoptimized + debuginfo] target(s) in [..]s
```
to
```
Finished `dev` profile [unoptimized + debuginfo] target(s) in [..]s
```
where `dev profile` is a link to [the Cargo book](https://doc.rust-lang.org/cargo/reference/profiles.html#profiles).
The intent is
- Clarify what `dev` even means
- Add `profile` to give it context
- Quote it to highlight this is something mutable
- Make the profile content stand out on hover by being a link
- Help people learn more by following the link
For now, this leaves the profile description alone.
### How should we test and review this PR?
### Additional information
chore(bump-check): include rustfix and cargo-util-schemas
The workspace now has these two crates in stable, beta, and nightly channels.
Checking semver compatibility against them should work now.
feat: Add hint for adding members to workspace
### What does this PR try to resolve?
Fixes https://github.com/rust-lang/cargo/issues/13403
### How should we test and review this PR?
Reviewd commit by commit
### Additional information
fix: Don't duplicate comments when editing TOML
### What does this PR try to resolve?
`toml_edit` <0.22 has a bug that will cause
```toml
[lints]
rust.unsafe_op_in_unsafe_fn = "deny"
rust.explicit_outlives_requirements = "warn"
# rust.unused_crate_dependencies = "warn"
clippy.cast_lossless = "warn"
clippy.doc_markdown = "warn"
clippy.exhaustive_enums = "warn"
```
to be written out as
```toml
[lints]
rust.unsafe_op_in_unsafe_fn = "deny"
rust.explicit_outlives_requirements = "warn"
# rust.unused_crate_dependencies = "warn"
clippy.cast_lossless = "warn"
# rust.unused_crate_dependencies = "warn"
clippy.doc_markdown = "warn"
# rust.unused_crate_dependencies = "warn"
clippy.exhaustive_enums = "warn"
```
when it is parsed and then saved.
See toml-rs/toml#673
This affects any format-preserving edits we do, including:
- `cargo add`
- `cargo remove`
- `cargo init` / `cargo new` editing the workspace
### How should we test and review this PR?
I didn't add any tests as this is covered by `toml_edit`s tests (we already don't cover a fraction of the edit preserving tests it has)
### Additional information
Update git2
This updates git2 primarily to pull in the update for libgit2 1.7.2 which fixes three security issues. `@weihanglo` did some investigation, and it looks like cargo may be susceptible to one of them with rev parsing. I am uncertain of the severity, but the CVE seems to imply that it is mainly a denial-of-service with an infinite loop from a well-crafted spec.
See https://github.com/libgit2/libgit2/releases/tag/v1.7.2 for more information.
fix: Switch more notes/warnings to lowercase
See https://doc.crates.io/contrib/implementation/console.html#style
By fixing existing cases, we make it more likely people will copy a case they should.
I left out multi-sentence cases because I was unsure how to handle those
Don't add the new package to workspace.members if there is no existing workspace in Cargo.toml.
### What does this PR try to resolve?
Fixed https://github.com/rust-lang/cargo/issues/13345
If the current package has no workspace table in Cargo.toml, then if you run `cargo add foo`, don't create the workspace inline item and don't add `foo` into the workspace.members.
### How should we test and review this PR?
Reviewed by commit by commit.
### Additional information
`toml_edit` <0.22 has a bug that will cause
```toml
[lints]
rust.unsafe_op_in_unsafe_fn = "deny"
rust.explicit_outlives_requirements = "warn"
clippy.cast_lossless = "warn"
clippy.doc_markdown = "warn"
clippy.exhaustive_enums = "warn"
```
to be written out as
[lints]
rust.unsafe_op_in_unsafe_fn = "deny"
rust.explicit_outlives_requirements = "warn"
clippy.cast_lossless = "warn"
clippy.doc_markdown = "warn"
clippy.exhaustive_enums = "warn"
```
when it is parsed and then saved.
See toml-rs/toml#675
This affects any format-preserving edits we do, including:
- `cargo add`
- `cargo remove`
- `cargo init` / `cargo new` editing the workspace
Remove build metadata from curl-sys version.
#13379 added the build metadata to the curl-sys version, but cargo spits a warning that you shouldn't do that. It also didn't add the metadata correctly, as the version is `+curl-8.6.0`. This removes that, since it isn't needed.
Fix markdown line break in cargo-add
This fixes a backslash line break in the cargo-add documentation. A future version of mdbook will adhere to the commonmark spec more closely, and this will end up showing as a literal backslash.