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.
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.
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.
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
`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.
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.