Commit graph

16967 commits

Author SHA1 Message Date
Scott Schafer 307c7f825c
feat: Add a basic linting system 2024-03-23 10:26:02 -06:00
Scott Schafer abf0953292
feat: Add -Zcargo-lints 2024-03-23 10:24:50 -06:00
bors 7ff7e34260 Auto merge of #13627 - Muscraft:rename-lint-table-tests, r=epage
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.
2024-03-22 17:40:06 +00:00
Scott Schafer 31c3052524
refactor(testsuite): Rename lints to lints_table 2024-03-22 11:33:58 -06:00
bors 8bcecfeed4 Auto merge of #13618 - ehuss:always-rebuild-unit-graph, r=epage
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
2024-03-21 21:37:26 +00:00
bors b8b7fa5cd1 Auto merge of #13619 - epage:fold, r=Muscraft
refactor(toml): Push diagnostic complexity on annotate-snippets
2024-03-21 21:05:16 +00:00
Ed Page 69bbb2c1ae refactor(toml): Push diagnostic complex on annotate-snippets 2024-03-21 15:51:32 -05:00
Eric Huss e0e000e1e5 Fix debuginfo strip when using --target 2024-03-21 13:39:45 -07:00
bors c3ad639bb9 Auto merge of #13614 - ehuss:fix-cdn-publish, r=weihanglo
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.
2024-03-21 16:33:49 +00:00
Eric Huss 97d896fe52 Fix publish script due to crates.io CDN change 2024-03-21 09:32:05 -07:00
bors d2fbe57b81 Auto merge of #13613 - weihanglo:empty-alias, r=epage
fix(alias): dont panic when resolving an empty alias
2024-03-21 12:56:31 +00:00
Weihang Lo 46214f3c79
fix(alias): dont panic when resolving an empty alias 2024-03-21 00:44:18 -04:00
Weihang Lo 352d8bbe8e
test(alias): panic if alias is empty
This demonstrate the current bad behavior
2024-03-21 00:41:19 -04:00
bors f0ae765191 Auto merge of #13609 - Muscraft:update-annotate-snippets, r=epage
Update annotate snippets

This updates `annotate-snippets` to `0.11.0`, which introduces the new builder API as well as a few rendering fixes.
2024-03-20 21:08:00 +00:00
bors 5b776ec880 Auto merge of #13610 - weihanglo:refactor-vendor, r=epage
refactor(vendor): tiny not important refactors
2024-03-20 19:49:11 +00:00
Weihang Lo 9f96d7b937
refactor: use a dense pattern matching for str 2024-03-20 15:38:25 -04:00
Weihang Lo 75712e1e30
refactor: reuse Package::root() instead 2024-03-20 14:18:05 -04:00
Scott Schafer f983e2028c
feat: Set term_width for Renderer 2024-03-20 11:01:54 -06:00
Scott Schafer 96bbaa11bf
chore: Update annotate-snippets 2024-03-20 10:42:10 -06:00
bors 266a5ef5ea Auto merge of #13561 - epage:msrv-report, r=weihanglo
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
2024-03-20 00:55:52 +00:00
bors d438c80c45 Auto merge of #13603 - epage:toml3, r=weihanglo
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
2024-03-19 16:11:22 +00:00
bors ecb89a1a4e Auto merge of #13606 - dvdhrm:pr/initlib, r=weihanglo
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
2024-03-19 15:39:48 +00:00
Ed Page 627217aa62 docs: Fix original_toml doc comments 2024-03-19 10:18:41 -05:00
bors 3e7852bb65 Auto merge of #13602 - mrobinson:fix-minor-grammar-error, r=weihanglo
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.
2024-03-19 15:04:32 +00:00
David Rheinsberg b673c1010f 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.

Signed-off-by: David Rheinsberg <david@readahead.eu>
2024-03-19 11:07:41 +01:00
bors 1e70a10a25 Auto merge of #13604 - weihanglo:version-bump, r=epage
Bump to 0.80.0; update changelog

[rendered](https://github.com/weihanglo/cargo/blob/version-bump/CHANGELOG.md)
2024-03-18 21:34:35 +00:00
Weihang Lo d85644ea55
Update changelog for 1.79.0 2024-03-18 17:29:31 -04:00
Weihang Lo 6706ee9c35
Update changelog for 1.78.0 2024-03-18 17:29:31 -04:00
Ed Page 00d542f58a refactor(features): Remove redundant is_local
Its the caller's job to decide whether the warning is relevant
2024-03-18 11:41:06 -05:00
Weihang Lo e6dccf946f
Bump to 0.80.0 2024-03-18 11:44:35 -04:00
Martin Robinson 8fa25ba41d chore: Fix minor grammar nit in command-line help
A *very* minor grammar correction. "Require" used in this way is
typically followed by the infinitive.
2024-03-18 14:32:28 +01:00
Ed Page 9882ab3260 refactor(toml): Proces unused keys on Manifest 2024-03-16 19:45:34 -05:00
bors 69726309bf Auto merge of #12783 - dvdhrm:pr/libname2, r=ehuss
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.
2024-03-16 20:50:35 +00:00
Ed Page 0305ad332f refactor(toml): Pull out TomlManifest to WorkspaceConfig 2024-03-15 21:26:16 -05:00
Ed Page c1a53f344a refactor(toml): Don't move lints to verify them
This is a hold over from when this was unstable
2024-03-15 21:20:18 -05:00
Ed Page 0048f2f816 refactor(core): Reuse TomlManifest for TomlProfiles 2024-03-15 21:14:54 -05:00
Ed Page 8152bfbb5e refactor(core): Expose all of the variants of VirtualManifests 2024-03-15 21:14:50 -05:00
Ed Page a694ea9777 refactor(core): Have Manifest track true original_toml
This will help with doing lint analysis after parsing
2024-03-15 21:14:45 -05:00
Ed Page 9b8486b82a refactor(toml): Clarify what TomlManifest we are working with 2024-03-15 20:55:46 -05:00
Ed Page 368ad2ba09 refactor(toml): Pull nested ws fn out 2024-03-15 20:41:34 -05:00
Ed Page 914dc145ce refactor(toml): Remove unused trim 2024-03-15 20:38:06 -05:00
Ed Page fa765fbf6f refactor(toml): Consolidate on a single way to track warnings 2024-03-15 20:37:46 -05:00
Ed Page 7cfa2aead3 refactor(toml): Leverage cap lints for project warnings, rather than recreate it 2024-03-15 20:37:37 -05:00
Ed Page 74cdee2eb5 refactor(toml): Clarify which toml we are working with 2024-03-15 20:35:31 -05:00
Ed Page edee996f18 refactor(toml): Remove redundant creation of manifest path 2024-03-15 20:35:31 -05:00
bors 2fe739fcf1 Auto merge of #13591 - epage:namespace, r=weihanglo
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
2024-03-15 21:39:18 +00:00
bors 36108cbebf Auto merge of #13593 - epage:toml2, r=Muscraft
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
2024-03-15 21:09:29 +00:00
bors c319962079 Auto merge of #13337 - epage:unicode, r=weihanglo
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
2024-03-15 20:41:31 +00:00
Ed Page a1fc7fe269 refactor: Expose source/spans to Manifest for emitting lints
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.
2024-03-15 15:41:03 -05:00
Ed Page 196e8b44e7 docs: Explain what a resolved toml is 2024-03-15 15:29:56 -05:00