85 Commits

Author SHA1 Message Date
Ed Page
cd139dadff fix(toml): Clarify the edition is on the float
I decided to keep it light for now as there are frustrations with this
warning but we may want to weigh that with providing a suggestion for
the edit, a help to use `cargo fix` (once implemented), etc.
2026-02-25 15:12:38 -06:00
Ed Page
bee20ff529 feat(lints): Add missing_lints_inheritance
Fixes #15579

Some naming inspiration from rust-lang/rust-clippy#15092.

There are several ways to go with this lint and I'm leaving the final
decisions to the stabilization conversations.
- Could be called `missing_lints` but that makes it sound like its
  needed even when there is no `workspace.lints`
- The name implies it should lint for an empty `[lints]`
  - Naming to be specific enough is hard
  - We could lint on a `[lints]` without `workspace = true` but then
    they will have to turn this lint to `allow` when intentionally not
    inheriting, adding boilerplate, while we're mainly trying to cover the
    case of people thinking implicit inheritance is a thing.
2026-02-04 14:57:32 -06:00
Ed Page
f2402fc620 test(lints): Avoid missing_lints_inheritance 2026-02-04 14:57:02 -06:00
Ed Page
2e98cb26e2 test(lints): Add tests for missing_lints 2026-02-04 14:11:06 -06:00
Ed Page
48d18b2d20 feat(lints): Add unused_workspace_package_fields lint
To make this more easily scale and deal with unknown fields (e.g. #13258),
I iterated on the TOML directly.

Fixes #15868
2026-02-03 12:27:34 -06:00
Ed Page
93708d8268 test(lints): Verify unused_workspace_package_fields 2026-02-03 12:11:55 -06:00
Ed Page
3ed3cefeac feat(lints): Add unused workspace dependency lint 2026-01-30 11:42:05 -06:00
Ed Page
a2ba770a51 test(lints): Show unused workspace dependencies behavior 2026-01-30 10:39:15 -06:00
Ed Page
f612dafd1b fix(lints): Fully remove inherited redundant items in suggestions 2026-01-29 07:27:52 -06:00
Ed Page
4a358af4b4 test(lints): Show package metadata lints with inheritance 2026-01-27 14:36:30 -06:00
Ed Page
f4b456ec20 feat(lints): Add redundant_homepage lint
Fixes #15871
2026-01-26 20:47:33 -06:00
Ed Page
a454ae017e test(lints): Show cases for redundant_homepage 2026-01-26 20:31:00 -06:00
Ed Page
c1e52c62b0 feat(lints): Add non_snake_case_features 2026-01-26 15:17:56 -06:00
Ed Page
6646031bcf feat(lints): Add non_kebab_case_features 2026-01-26 15:17:12 -06:00
Ed Page
5859c55791 test(lints): Add tests for non_*_case_features 2026-01-26 11:12:32 -06:00
Ed Page
971ec1f99b feat(lints): Add non_snake_case_packages 2026-01-26 08:31:59 -06:00
Ed Page
5d922e146d feat(lints): Add non_kebab_case_packages 2026-01-26 08:31:31 -06:00
Ed Page
6e4af4e40c test(lints): Add tests for package name case lints 2026-01-26 08:30:31 -06:00
Ed Page
6478dd29ec fix(lints): Pluralize non_kebab_case_bins
From https://rustc-dev-guide.rust-lang.org/diagnostics.html?#lint-naming

> If a lint applies to a specific grammatical class, mention that class
> and use the plural form: use `unused_variables` rather than
> `unused_variable`. This makes `#[allow(unused_variables)]` read correctly.
2026-01-24 21:35:32 -06:00
Ed Page
4071ddae4e feat(lint): Add redundant_readme lint
Name and styling was inspired by
[redundant_static_lifetimes](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes)

Fixes #15869
2026-01-23 14:18:02 -06:00
Ed Page
12b79e92b3 test(lints): Add redundant_readme lint 2026-01-23 13:43:04 -06:00
Scott Schafer
0f6e232518 fix: show implicit_minimum_version_req emitted source once per package 2026-01-20 22:13:28 -07:00
Scott Schafer
768308307b fix: Move implicit_minimum_version_req emitted source to primary group 2026-01-20 22:13:28 -07:00
Scott Schafer
fb08c99bdf test: Make a implicit_minimum_version_req test ordered 2026-01-20 22:13:28 -07:00
Ed Page
6a5bef29fc feat(lints): Add non_kebab_case_bin lint
Regarding lint naming:
- I didn't go with `non_kebab_case` because we had received
  encouragement to be more specific than `non_camel_case` when
  discussing this at the All Hands
- I went with `bin` rather than `bin_name` because the thing we are
  ultimately linting is the binary file stem, not any specific field, and if
  other fields end up contributing to the binary name, we should include
  those, like
  [bin.namefilename](https://doc.rust-lang.org/cargo/reference/unstable.html#different-binary-name)
  or any potential [prefixes or suffixes](https://github.com/rust-lang/cargo/issues/1970)

Regarding the lint's look: I tried to make this look as much like rustc
as possible:
```
    Checking cargo v0.95.0 (/home/epage/src/personal/cargo)
warning: function `Is_default_main` should have a snake case name
   --> src/cargo/lints/rules/non_kebab_case_bin.rs:188:4
    |
188 | fn Is_default_main(path: Option<&cargo_util_schemas::manifest::PathValue>) -> bool {
    |    ^^^^^^^^^^^^^^^ help: convert the identifier to snake case (notice the capitalization): `is_default_main`
    |
    = note: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default
```

Fixes #15586
2026-01-20 14:53:46 -06:00
Ed Page
5cd00ce20e test(lints): Add non_snake_case_bin_name tests 2026-01-16 16:54:22 -06:00
Scott Schafer
3ed083194c test: Use a larger default term width 2025-12-15 16:59:09 -07:00
Weihang Lo
c3da571165 test(lint): redact more due to line got omitted
```
---- expected: tests/testsuite/lints/implicit_minimum_version_req.rs:716:27
++++ actual:   stderr
   1    1 | [WARNING] dependency version requirement without an explicit minimum version
   2    2 |  --> Cargo.toml:7:[..]
   3    3 |   |
   4      - 7 | bar = { git = '[ROOTURL]/bar', version = "0.1" }
        4 + 7 | ...known-linux-gnu/tmp/cit/t2182/bar', version = "0.1" }
   5    5 |   |                                      [..]^^^^^ missing full version components
   6    6 |   |
   7    7 | [HELP] consider specifying full `major.minor.patch` version components
   8    8 |   |
   9    9 | 7 | bar = { git = '[ROOTURL]/bar', version = "0.1.0" }
  10   10 |   |                                          [..]++
  11   11 |   = [NOTE] `cargo::implicit_minimum_version_req` is set to `warn` in `[lints]`
  12   12 | [UPDATING] git repository `[ROOTURL]/bar`
  13   13 | [LOCKING] 1 package to latest compatible version
  14   14 | [CHECKING] bar v0.1.0 ([ROOTURL]/bar#[..])
  15   15 | [CHECKING] foo v0.0.0 ([ROOT]/foo)
  16   16 | [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
```

See https://github.com/rust-lang/rust/pull/149934#issuecomment-3649057452
2025-12-13 10:01:04 -05:00
Weihang Lo
e5db075f20 fix(lints): handle lints separately at ws pkg level
`unknown_lints` is special that it analyzes only at package level,
and warn if your lint is inherited from workspace.

According to the discussion in
<https://github.com/rust-lang/cargo/pull/16321#discussion_r2586539709>,
we should lint against workspace always plus selected packages.

This additionally handles unstable lint gating.
2025-12-09 01:00:36 -05:00
Weihang Lo
148dd33424 fix(lint): dont talk about ws inheritance when linting packages 2025-12-09 01:00:35 -05:00
Weihang Lo
e739958fb1 refactor(lint): bail outside lint logic 2025-12-09 01:00:35 -05:00
Weihang Lo
b17b78209d test(lint): bad lint but not inheriting
Cargo should always capture unknown/feature-gated lin at workspace level
2025-12-09 01:00:16 -05:00
Weihang Lo
864bf9677f feat(lint): lint also workspace dependencies
This has a future performance that version requirments in
`[workspace.dependencies]` shoud avoid reparse
2025-12-08 17:39:44 -05:00
Weihang Lo
192475a6f5 feat(lint): new implicit_minimum_version_req lint
Add a new `cargo::implicit_minimum_version_req` lint:
Only check if dependency has a single caret requirement.
All other requirements (multiple, tilde, wildcard)
are not linted by this rule, as they usually have significance
on what version fields get specified.

This currently lints only dependencies with no workspace inheritance.
2025-12-08 17:39:43 -05:00
Weihang Lo
6cd7e71482 test(lint): show current behavior for version requirements 2025-12-08 15:43:46 -05:00
Weihang Lo
a594f32cdc fix(lints): plural form correctly 2025-12-02 00:03:35 -05:00
Weihang Lo
12aa62cab1 test(lints): show lint error number
This wasn't shown because AlreadyPrintedError was skipped.
2025-12-02 00:02:12 -05:00
Weihang Lo
b3d07f74e4 fix(lints): plural form correctly 2025-12-01 13:25:56 -05:00
Weihang Lo
7b1bc3dd65 fix(lints): show lint error number
This wasn't shown because AlreadyPrintedError was skipped.
2025-12-01 13:03:03 -05:00
Scott Schafer
c94d1358e9 feat: Add unstable rustc-unicode flag 2025-11-12 08:24:30 -07:00
Scott Schafer
da5d9152fa feat: Add lint for global use of hint-mostly-unused 2025-09-22 16:47:54 -06:00
Scott Schafer
8a86027041 test: Blanket use of hint-mostly-unused 2025-09-22 11:47:16 -06:00
Ed Page
eac1ad1cd3 fix(shell): Don't bold the colon after error/warn/note 2025-09-05 09:40:24 -05:00
Ed Page
7d6d673e23 fix(cli): Adjust terminal styles to match rustc
Fixes #12740
2025-09-04 16:35:40 -05:00
Scott Schafer
d36c326926 chore(deps): update rust crate annotate-snippets to 0.12.1 2025-09-02 15:43:38 -06:00
Scott Schafer
2ef151bdc9 fix: Emit inline help after first snippet 2025-09-02 15:43:37 -06:00
Scott Schafer
069723ebff fix(unknown_lints): Make emitted_source come before other groups 2025-08-19 16:19:40 -06:00
Ross Sullivan
92d9a94d02 chore: Migrated testsuite to testsuite::prelude 2025-06-25 22:37:24 +09:00
Scott Schafer
ccbe572a74 fix: Make UI tests handle hyperlinks consistently 2025-06-05 21:58:25 -06:00
Eric Huss
b5394da406 Update annotate-snippets from 0.11.4 to 0.11.5
Changelog: https://github.com/rust-lang/annotate-snippets-rs/blob/master/CHANGELOG.md#0115---2024-12-09

Looks to have some minor rendering differences.
2025-02-09 12:46:36 -08:00