Add the `transmute_int_to_non_zero` lint
Fixes#10288
This adds a new complexity lint `transmute_int_to_non_zero` which checks for transmutes to any of the `NonZero*` types, and suggests their `new_unchecked` method instead.
r? `@llogiq`
changelog: New lint: [`transmute_int_to_non_zero`]
Add question-mark-used lint
This lint complains when the question mark operator (try operator) is used. This is a restriction lint that can be useful on local scopes where a custom error handling macro is supposed to be used to augment the error based on local scope data before returning.
Fixes#10340
---
changelog: New lint [`question_mark_used`]
[#10342](https://github.com/rust-lang/rust-clippy/pull/10342)
<!-- changelog_checked -->
Add `let_underscore_untyped`
Fixes#6842
This adds a new pedantic `let_underscore_untyped` lint which checks for `let _ = <expr>`, and suggests to either provide a type annotation, or to remove the `let` keyword. That way the author is forced to specify the type they intended to ignore, and thus get forced to re-visit the decision should the type of `<expr>` change. Alternatively, they can drop the `let` keyword to truly just ignore the value no matter what.
r? `@llogiq`
changelog: New lint: [let_underscore_untyped]
[significant_drop_tightening] Add MVP
cc #9399
Creates the lint with minimum functionalities, which is a good start IMO.
---
changelog: new lint: [`significant_drop_tightening`]
[#10163](https://github.com/rust-lang/rust-clippy/pull/10163)
<!-- changelog_checked -->
Change unusual_byte_groupings to require byte groupings of equal size
Fixes issue #6556
This lint required byte groupings of size 2 or 4 for `Radix::Binary` and `Radix::Hexadecimal`. Since there are good reasons for allowing groups of other sizes, this PR relaxes the restriction. This lint now requires that
- group sizes after the first group be of the same size and
- greater or equal in size to the first group.
---
changelog: [`unusual_byte_groupings`]: reduce false positives by relaxing restriction requiring groups of specific sizes.
Ignore synthetic type parameters for `extra_unused_type_parameters`
There was a minor bug around calculating spans when forming the help message. An example:
```rust
fn unused_opaque<A, B>(dummy: impl Default) {}
// ^^ ^
```
In this case, the entire list of generics should be highlighted, instead of each individual parameter. The culprit is the `impl Default`, which registers as a type parameter but doesn't live within the `<...>`. Because synthetic parameters can't ever be manually created, we just ignore them for this lint.
r? `@flip1995`
changelog: none
<!-- changelog_checked -->
Fix false positives for `extra_unused_type_parameters`
Don't lint external macros. Also, if the function body is empty, any type parameters with bounds on them are not linted. Note that only the body needs be empty - this rule still applies if the function takes any arguments.
fixes#10318fixes#10319
changelog: none
<!-- changelog_checked -->
uninlined_format_args: do not inline argument with generic parameters
Fix#10339
---
changelog: FP: [`uninlined_format_args`]: No longer lints for arguments with generic parameters
[#10343](https://github.com/rust-lang/rust-clippy/pull/10343)
<!-- changelog_checked -->
fix [`needless_return`] incorrect suggestion when returning if sequence
fixes: #10049
---
changelog: [`needless_return`]: fix incorrect suggestion on if sequence
Liberate late-bound regions rather than erasing them in `needless_pass_by_value`
changelog: [`needless_pass_by_value`]: fixes an ICE when there are late-bound regions in function arguments that are needlessly passed by value
Fixesrust-lang/rust#107147
r? `@matthiaskrgr`
manual_let_else: let/else is not divergent by default
The divergent `else` block of a `let`/`else` statement does not make the `let/else` statement itself divergent.
Fixes#10296
changelog: [`manual_let_else`]: do not consider `let`/`else` to be divergent by default
[never_loop] Fix#10304
It is not sufficient to ignore break from a block inside the loop. Instructions after the break must be ignored, as they are unreachable. This is also true for all instructions in outer blocks and loops until the right block is reached.
Fixes#10304
---
changelog: FP: [`never_loop`]: No longer lints, for statements following break statements for outer blocks.
[#10311](https://github.com/rust-lang/rust-clippy/pull/10311)
<!-- changelog_checked-->
It is not sufficient to ignore break from a block inside the loop.
Instructions after the break must be ignored, as they are unreachable.
This is also true for all instructions in outer blocks and loops
until the right block is reached.
This lint complains when the question mark operator (try operator)
is used. This is a restriction lint that can be useful on local
scopes where a custom error handling macro is supposed to be used
to augment the error based on local scope data before returning.
lintcheck: fix clap panic
clap 4.1.4 panics if `-` is used at the start of an argument:
```
$ cargo lintcheck
[…]
thread 'main' panicked at 'Argument recursive: long "--recursive" must not start with a `-`, that will be handled by the parser', /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.4/src/builder/debug_asserts.rs:82:13
```
changelog: none
<!-- changelog_checked -->