Commit Graph

17362 Commits

Author SHA1 Message Date
Scott Schafer d5bc35d844
refactor(lints): Keep workspace and package lints separate 2024-04-24 14:52:45 -06:00
Scott Schafer 2655b069c6
test(cargo-lints): Add a test for workspace inheritance 2024-04-24 14:48:48 -06:00
Scott Schafer b83c0a4939
refactor(cargo-lints): Cleanup getting the level for a lint 2024-04-24 14:48:38 -06:00
bors 955503e1de Auto merge of #13800 - epage:u3, r=weihanglo
fix(toml): Don't double-warn when underscore is used in workspace dep

### What does this PR try to resolve?

This is prep for removing them in the 2024 Edition and is part of rust-lang/rust#123754 and #13629

Particularly, I wanted to make sure I didn't make things worse and in doing so found there was room for improvement.

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

### Additional information
2024-04-24 20:25:10 +00:00
bors e3d42b6019 Auto merge of #13798 - epage:underscore, r=weihanglo
fix(toml): Be more forceful with underscore/dash redundancy

### What does this PR try to resolve?

This is prep for removing them in the 2024 Edition and is part of rust-lang/rust#123754 and #13629

During #13783, I had considered making the 2024 edition behavior a "unused key" warning.  However, the work and code mess to pipe the data through correctly handle the two fields in all cases didn't seem worth it (and a hard error might be better to help users transition).

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

### Additional information
2024-04-24 19:55:43 +00:00
Ed Page 751fd47d34 fix(toml): Don't double-warn when underscore is used in workspace dep 2024-04-24 14:22:23 -05:00
Ed Page 4cc82833bd test(toml): Show default_features warning for workspace dependencies 2024-04-24 13:51:31 -05:00
Ed Page b81f94a8e9 refactor(toml): Move underscore validation to resolving 2024-04-24 13:32:04 -05:00
bors 52dae0c1f6 Auto merge of #13793 - ijackson:symlink, r=epage
Fix warning suppression for config.toml vs config compat symlinks

### What does this PR try to resolve?

Background: the cargo config file is being renamed from `.cargo/config` to `.cargo/config.toml`.  There's code in new cargo to look for both files (for compatibility), to issue a warning when onliy the old filename is found, and also to issue a warning if both files are found.  The warning suggests making a symlink if compatibility with old cargo is wanted.

An attempt was made to detect when both the old and new files exists, but one is a symlink to the other, but as reported in #13667, this code is not effective.  (It would work only if the symlink had the precise absolute pathname that cargo has decided to use for the lookup, which would be an unnatural way to make the link.)

Logically, the warning should appear when both files exist *but are different*.  That is the anomalous situation that will generate confusing behaviour.   By "different" we ought to mean "aren't the very same file".

That's what this MR implements, where possible.  On Unix, we use the information from stat(2).  That's not available on other platforms; on those, we arrange to also tolerate a symlink referring to precisely `config.toml` as a relative pathname, which is also fine, since by definition the target is then in the same directrory as `config`.

Fixes #13667.

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

I have interleaved the new tests with the commits that support them.  In each case, a functional commit is followed by a test which fails just beforehand.

(This can be observed by experimentally reordering the branch.)

I have also done ad-hoc testing.

### Additional information

I'm making the assumption that a symlink containing a relative path does something sane on Windows.  This assumption may be unwarranted.  If so, "Handle `config` -> `config.toml` (without full path)" needs to be dropped, and the test case needs to be `#[cfg(unix)]`.

But also, in this case, we should probably put some warnings in the stdlib docs!
2024-04-24 17:36:34 +00:00
bors 70fb498994 Auto merge of #13797 - Muscraft:cleanup-linting-system, r=epage
Cleanup linting system

There are a number of problems with the current linting system, most notably that lints could run without `-Zcargo-lints` being set. This PR fixes that issue and a few others that are low-hanging fruit.
2024-04-24 16:31:40 +00:00
Ian Jackson 2f16838385 config reading: use same_file for suppressing "both files" warning (fmt)
Apply deferred indentation changes.  Whitespace change only.
2024-04-24 15:28:09 +01:00
Ian Jackson 23440c0dcd config reading: use same_file for suppressing "both files" warning
This is 100% reliable on Unix, and better on Windows.

(In this commit I avoid reindenting things to make review easier; the
formatting will be fixed in the next commit.)

Fixes #13667
2024-04-24 15:28:08 +01:00
Ian Jackson 91f3e457ab Tests: Add test case for config.toml -> config 2024-04-24 11:45:58 +01:00
Ian Jackson dcce00745d Tests: Add test case for config -> config.toml (relative) 2024-04-24 10:12:13 +01:00
Ian Jackson 13be0cfa8b Tests: Rename config symlink creation function
"symlink A to B" is confusing; it is ambiguous (at leaset to me)
whether it means A -> B or B -> A.

And I'm about to introduce a function that does the reverse,
and also one that makes a relative rather than full path link.

So rename this function.
2024-04-24 10:03:40 +01:00
bors c939267591 Auto merge of #13790 - epage:install, r=weihanglo
fix(install): Don't respect MSRV for non-local installs

### What does this PR try to resolve?

This is part of #9930

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

### Additional information
2024-04-23 19:35:19 +00:00
Ed Page dcbf2b5d32 fix(install): Don't respect MSRV for non-local installs
This is part of #9930
2024-04-23 14:17:10 -05:00
Ed Page cd8d5f7c10 refactor(msrv): Simplify tracking of use of MSRV-aware resolver
The design for this stems from
- It being unclear what the initialization order would be
- Prematurely writing this for `Cargo.lock` version to leverage it and
  maybe to switch other MSRV-aware logic to
2024-04-23 14:15:59 -05:00
bors 125aa57ad2 Auto merge of #13782 - klensy:llibc, r=weihanglo
gate some libc usages under cfg(unix), drop os_info features

Places few `libc` usages under `cfg(unix)`. That didn't remove it from tree, but still looks cleaner.
Drop features from os_info crate, as serde support currently unused.
2024-04-23 17:32:32 +00:00
bors b89b81a6c7 Auto merge of #13785 - epage:msrv-edition2024, r=weihanglo
feat(resolver): Add default Edition2024 to resolver v3

### What does this PR try to resolve?

With #13776 done, we can now make MSRV-aware resolver the default for the new edition as part of #9930

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

### Additional information
2024-04-23 02:27:06 +00:00
bors 11d5b73b29 Auto merge of #13789 - cuviper:test-offline, r=weihanglo
Fix 2 tests for offline execution

In `alt_registry::warn_for_unused_fields`, the second part of the test
runs on `--registry crates-io`, so it needs a local replacement url.

In `install::install_global_cargo_config`, it was adding to the "config"
file, but the `pkg` before it configured the dummy registry replacement
in "config.toml". So that replacement wasn't actually used, and if you
ran tests online it was trying to install `bar v0.1.1` from the real
registry! The filename is now fixed, and the test double-checks that
we're only trying to install the local `bar v0.0.1`.
2024-04-23 01:57:56 +00:00
Josh Stone 6dda4e006b Fix 2 tests for offline execution
In `alt_registry::warn_for_unused_fields`, the second part of the test
runs on `--registry crates-io`, so it needs a local replacement url.

In `install::install_global_cargo_config`, it was adding to the "config"
file, but the `pkg` before it configured the dummy registry replacement
in "config.toml". So that replacement wasn't actually used, and if you
ran tests online it was trying to install `bar v0.1.1` from the real
registry! The filename is now fixed, and the test double-checks that
we're only trying to install the local `bar v0.0.1`.
2024-04-22 16:19:17 -07:00
Ed Page bdd4bda518 fix(toml)!: Remove support for inheriting badges
We allowed `[badges]` to inherit from `[workspace.package.badges]`

This was a bug:
- This was not specified in the RFC
- We did not document this
- Even if someone were to try to guess to use this, it is inconsistent
  with how inheritance works because this should inherit from
  `workspace.badges` instead of `workspace.package.badges`

While keeping in mind that `[badges]` is effectively deprecated.

In that context, I think its safe to break support for this without a
transition period.

Fixes #13643
2024-04-22 14:22:01 -05:00
Ed Page 034ef3c27b fix(toml): Be more forceful with underscore/dash redundancy
During #13783, I had considered making the 2024 edition behavior a
"unused key" warning.  However, I'm being too lazy in piping the data
through correctly (and a hard error might be better to help users
transition).
2024-04-22 12:47:43 -05:00
bors d29ad6788a Auto merge of #13783 - epage:underscore, r=ehuss
fix(toml): Report `_` fied variants (e.g. `dev_dependencies`) as deprecated

### What does this PR try to resolve?

This is prep for removing them in the 2024 Edition and is part of rust-lang/rust#123754 and #13629

This doesn't include 2024 Edition work because there is a risk of conflict with other work going on these areas.

This changes us from
- When using `-` and `_` variants: deprecated, will error some time
- Otherwise, nothing

To
- When using `-` and `_` variants: unused field warning
- When using only `_`: deprecation, will be removed in 2024

I decided to model this as an unused field warning because that is what this is and that is how any other use of `_` works.  We might hard error during a transition period but I'd eventually want these to just make the code act like anything else in the end.

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

### Additional information
2024-04-22 16:25:06 +00:00
Ed Page 9ee41598e8 feat(resolver): Add default Edition2024 to resolver v3 2024-04-22 10:45:59 -05:00
Ed Page 706f8a71c8 fix(msrv): Don't require -Zmsrv-policy for resolver=3
We still have `edition2024` guarding this.

Dealing with two feature flags to control behavior is messy.  We just
need to make sure both get stabilized :).
2024-04-22 10:45:19 -05:00
Scott Schafer 11d6013c1d
fix(cargo-lints): Respect Forbid lint level 2024-04-20 20:12:47 -06:00
Scott Schafer 2d40a475d9
feat: Add unstable im_a_teapot lint 2024-04-20 19:33:13 -06:00
Scott Schafer 00a64e4da3
fix: Only run lints when cargo-lints are enabled 2024-04-20 19:22:32 -06:00
Scott Schafer b89864cc3b
fix: Allow should not get translated to Note 2024-04-20 16:31:04 -06:00
klensy 57e820e329 cargo-credential: bump version to 0.4.5
as required by check-version-bump CI
2024-04-20 10:38:49 +03:00
bors 14b46ecc62 Auto merge of #13776 - epage:msrv-resolver, r=weihanglo
feat(resolver): Add v3 resolver for MSRV-aware resolving

### What does this PR try to resolve?
This is a part of #9930 and is important for changing the default with the new edition.

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

### Additional information
2024-04-20 04:37:21 +00:00
Ed Page d0528058a1 feat(resolver): Add v3 resolver for MSRV-aware resolving
This is a part of #9930 and is important for changing the default with
the new edition.
2024-04-19 20:02:31 -05:00
bors 02499abbe9 Auto merge of #13778 - Muscraft:unused-dependencies, r=epage
Unused dependencies cleanup

The implementation of #12826 was used as a demonstration for #12235, in #13621. The demonstration implementation was far from ideal and was lacking a few features. This PR makes the implementation "feature complete", and fixes known bugs with the initial implementation.
2024-04-19 21:28:56 +00:00
bors 80d5b607dd Auto merge of #13777 - Byron:fix-13773, r=weihanglo
fix 13773 - 'cargo build' fails when list_files() with gix is triggered

Fixes #13773.

### Tasks

* [x] reproduce issue with new test-case
* [x] update [fixed `gix-dir`](https://github.com/rust-lang/cargo/pull/13777) in Cargo.lock to turn test green
2024-04-19 18:39:22 +00:00
Scott Schafer 064184a2bb
feat(fix): Add features for unused deps on Edition 2024 2024-04-19 11:43:39 -06:00
Scott Schafer 87915e71fe
feat: Avoid creating implicit features on edition 2024 2024-04-19 11:43:38 -06:00
Scott Schafer e2741019c2
feat: Add unused_optional_dependency lint 2024-04-19 11:42:25 -06:00
Scott Schafer 8d676dde40
feat(implicit_features): Show why lint was emiited 2024-04-19 11:41:28 -06:00
Scott Schafer 7aac7f875c
fix(implicit_features): Work with any dep table 2024-04-19 11:15:02 -06:00
Scott Schafer 301010aaa0
chore(implicit_features): Cleanup getting dep features 2024-04-19 11:11:04 -06:00
Scott Schafer 9855e50dcd
refactor: Make `implicit_features` <= edition 2021 2024-04-19 11:03:05 -06:00
Scott Schafer 495f94e80e
refactor(implicit_features): Use lint description for title 2024-04-19 10:58:55 -06:00
Scott Schafer af1e5b3623
chore(implicit_features): Update lint description 2024-04-19 10:53:06 -06:00
bors b503c83088 Auto merge of #13780 - epage:toml, r=weihanglo
fix(toml): Don't crash on parse errors that point to multi-byte character

This pulls in toml-rs/toml#713

Fixes #13772
2024-04-19 13:48:21 +00:00
klensy ef39fbf231 os_info: use default-features = false, as no serde support needed 2024-04-19 15:49:19 +03:00
klensy 3215929365 gate some libc usages under cfg(unix) 2024-04-19 15:27:21 +03:00
Sebastian Thiel 3fd120b7b3
use the latest patch release of `gix-dir` to fix #13777 2024-04-19 07:11:43 +02:00
Sebastian Thiel 07d2bd7517
reproduce failure when packaging a path-dependency inside a symlinked git repository (#13773) 2024-04-19 07:11:37 +02:00