refactor(testsuite): Rename lints to lints_table
In preparation for a linting system for cargo, we need a place to put the tests for new lints. Since they would be UI tests, it would make sense to place them in `tests/testsuite/lints/<lint name>`, but tests for `[lints]` are in `tests/testsuite/lints.rs`. To get around this, I am renaming `lints.rs` to `lints_table.rs` so they do not get confused.
Fix debuginfo strip when using `--target`
This fixes an issue where automatic `strip` of debuginfo added in https://github.com/rust-lang/cargo/pull/13257 wasn't working when the `--target` flag was used.
The problem is that the adjustment code was only running in the optimization pass that is done when `--target` is *not* specified.
The solution is to just always run the unit graph rebuild. I believe it should be safe to do so, since the adjustments it makes should be conditional on just the scenarios that matter when `--target` is not specified. The downside is that this might be a small performance hit when `--target` is used. Trying to avoid that I think would be quite challenging.
Fixes#13617
Fix publish script due to crates.io CDN change
Now that crates.io goes directly to the CDN, this has changed the HTTP response code when a crate is not found (from 404 to 403). This updates the publish script to handle more error codes to assume something isn't published. This also updates it to go directly to the endpoint instead of through the crates.io redirect.
feat: Report some dependency changes on any command
### What does this PR try to resolve?
The goal is to help users be informed when they are held back by either MSRV or semver.
Fixes#13539
### How should we test and review this PR?
### Additional information
refactor(toml): Expose surce/spans for VirtualManifests
### What does this PR try to resolve?
This is a follow up to #13593, expanding support from `Manifest` to `VirtualManifest` as well.
This also does other clean up along the way in preparation for making a more explicit `resolve_toml` phase.
### How should we test and review this PR?
### Additional information
cargo/init: avoid target.name assignments if possible
Make `cargo init` skip `target.name` assignments if the default value is suitable.
Currently, all paths of `cargo init` will set target-names to the package-name, ensuring that a suitable target-name is set. This is required for all targets but libraries. Unfortunately, library-names have more restrictions than other targets. For example, creating a library with dashes will lead to errors:
mkdir foo-bar
cd foo-bar
touch foo-bar.rs
cargo init --lib
Fortunately, target-names for libraries are inferred from the package-name. Hence, by omitting the target-name, a valid configuration will be produced.
Instead of adjusting `SourceFileInformation::target_name` to use `Option<String>`, this commit strips the field completely, since all callers set it to the package-name.
Fixes: #11259
chore: Fix minor grammar nit in command-line help
This change fixes a *very* minor grammar mistake. "Require" used in this way is
typically followed by the infinitive. In addition, since "up-to-date" is used
an adjective now it should be hyphenated.
See https://www.merriam-webster.com/dictionary/up-to-date
### Testing
I have run `cargo test` with `CFG_DISABLE_CROSS_TESTS=1` as well as `cargo
build-man` to regenerate the man pages.
Fixes#13601.
Make `cargo init` skip `target.name` assignments if the default value is
suitable.
Currently, all paths of `cargo init` will set target-names to the
package-name, ensuring that a suitable target-name is set. This is
required for all targets but libraries. Unfortunately, library-names
have more restrictions than other targets. For example, creating a
library with dashes will lead to errors:
mkdir foo-bar
cd foo-bar
touch foo-bar.rs
cargo init --lib
Fortunately, target-names for libraries are inferred from the
package-name. Hence, by omitting the target-name, a valid configuration
will be produced.
Instead of adjusting `SourceFileInformation::target_name` to use
`Option<String>`, this commit strips the field completely, since all
callers set it to the package-name.
Signed-off-by: David Rheinsberg <david@readahead.eu>
cargo: prevent dashes in lib.name
The TOML parser of Cargo currently refuses `lib.name` entries that contain dashes. Unfortunately, it uses the package-name as default if no explicit `lib.name` entry is specified. This package-name, however, can contain dashes.
Cargo documentation states that the package name is converted first, yet this was never implemented by the code-base.
Fix this inconsistency and convert the package name to a suitable crate-name first.
This fixes#12780. It is an alternative to #12640.
feat: Add 'open-namespaces' feature
### What does this PR try to resolve?
This is a step towards #13576
### How should we test and review this PR?
### Additional information
refactor: Expose source/spans to Manifest for emitting lints
### What does this PR try to resolve?
This is a follow up to #13589.
This does nothing on its own.
This is meant to short-circuit some of my refactorings so Muscraft can
start on their work on adding lints while I work to move out existing
warnings into being able to be converted to lints.
### How should we test and review this PR?
This includes documentation changes suggested in #13589
### Additional information
feat(tree): Control `--charset` via auto-detecting config value
### What does this PR try to resolve?
This tries to generalize `cargo tree --charset` so any part of cargo's output can use it. For example,
- `cargo search` could use this for fancier tables
- `cargo add` could use this for fancier feature lists
- #12235 could use this for fancy rendering like miette does (CC `@Muscraft` )
- Progress bars could use fancier characters <-- this is what I'm personally working towards
This builds on the idea from #12889 that we can use fancier terminal features so long as we have good auto-detection and provide users an escape hatch until the auto-detection is improved or in case they disagree.
As a side benefit
- `cargo tree` will auto-detect when the prior default of `--charset utf8` is a good choice
- Users can control `cargo tree --charset` via `.cargo/config.toml`
### How should we test and review this PR?
This is gradually introduced through the individual commits.
### Additional information
This does nothing on its own.
This is meant to short-circuit some of my refactorings so Muscraft can
start on their work on adding lints while I work to move out existing
warnings into being able to be converted to lints.