| Age | Commit message (Collapse) | Author | Lines |
|
|
|
This comment was left behind when the method receiver was split out from
the method arguments in 4bcaddeeb23544eb2c86b600c3d775e2773758c2.
changelog: none
|
|
This lint detects and removes the unnecessary semicolon after a `match`
or `if` statement returning `()`. It seems to be quite a common
"mistake", given the number of hits (88) we had in the Clippy sources
themselves.
The lint doesn't bother about loops, as `rustfmt` already removes the
extra semicolon. It doesn't handle blocks either, as an extra block
level, followed or not by a semicolon, is likely intentional.
I propose to put the lint in `pedantic`, as putting it in `style` seems
quite hazardous given the number of hits.
Note: there exists a `redundant-semicolon` lint in the compiler, but it
is an early lint and cannot check that the expression evaluates to `()`,
so it ignores the cases we're handling here.
----
changelog: [`unnecessary_semicolon`]: new lint
|
|
|
|
This comment was left behind when the method receiver was split out from
the method arguments in 4bcaddeeb23544eb2c86b600c3d775e2773758c2.
|
|
A multipart suggestion will be used whenever the method call can be
replaced by another one with the first argument removed. It helps place
the new method call in context, especially when it is part of a larger
expression.
This fixes #13995 by applying a suggestion made by @y21.
r? @y21
changelog: [`unnecessary_map_or`]: better representation of suggestions
by placing them in context
|
|
|
|
Receivers which are references to `Option` and `Result`, or who
implement `Deref` to one of those types, will be linted as well.
|
|
A multipart suggestion will be used whenever the method call can be
replaced by another one with the first argument removed. It helps place
the new method call in context, especially when it is part of a larger
expression.
|
|
Proposing to replace
```rust
let mut x = PathBuf::from("/foo");
x.push("/bar");
```
by
```rust
let mut x = PathBuf::from("/foo");
x.push("bar");
```
changes the content of `x` (`/bar` ⇒ `/foo/bar`).
|
|
|
|
|
|
|
|
fix #13624
changelog: [`unnecessary_to_owned`]: don't suggest to use `cloned` on
`Cow` in `unnecessary_to_owned`
|
|
clippy-subtree-update
|
|
This builds upon the lint for `str::as_bytes()`, and also covers
needless uses of the iterator version `str::bytes()`.
|
|
We are checking that we are calling the `as_bytes()` method of `String`
or `str`. Checking that it returns a `slice()` does not add anything.
|
|
|
|
Removing `.map(identity)` may result in invalid code if the receiver of
`map()` is an immutable binding, and the result of `map()` is used as
the receiver of a method call expecting a mutable reference.
Fix #13904
changelog: [`map_identity`]: do not lint if this would cause mandatory
mutability to be lost
|
|
When the expression is transformed into an equality, parentheses are
needed only if the resulting equality is used:
- as a receiver in a method call
- as part of a binary or unary expression
- as part of a cast
In other cases, which will be the majority, no parentheses are required.
This makes the lint suggestions cleaner.
changelog: `none`
|
|
(#13940)
Fixes https://github.com/rust-lang/rust-clippy/issues/8528.
Similar to #13911, if there are code comments, we don't want to remove
them automatically.
changelog: Don't emit machine applicable `map_flatten` lint if there are
code comments
r? @xFrednet
|
|
|
|
recurisvely (#13891)
fixes: #4077
Continuation of #11546. r? @y21 if you don't mind?
changelog: [`needless_continue`] lint if the last stmt in loop is
`continue` recurisvely
|
|
|
|
When the expression is transformed into an equality, parentheses are
needed only if the resulting equality is used:
- as a receiver in a method call
- as part of a binary or unary expression
- as part of a cast
In other cases, which will be the majority, no parentheses are required.
This makes the lint suggestions cleaner.
|
|
|
|
|
|
|
|
|
|
Removing `.map(identity)` may result in invalid code if the receiver of
`map()` is an immutable binding, and the result of `map()` is used as
the receiver of a method call expecting a mutable reference.
|
|
|
|
|
|
`continue`, recursively
fixes: #4077
|
|
requirement configurable (#13737)
Fixes #11846.
This PR has three commits:
- The first commit adds an `initializer-suggestions` configuration to
control suggestion applicability when initializers are present. The
following are the options:
- "none": do not suggest
- "maybe-incorrect": suggest, but do not apply suggestions with `--fix`
- "machine-applicable": suggest and apply suggestions with `--fix`
- The second commit fixes suggestions to handle field attributes
(problem [noticed by
@samueltardieu](https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1859261645)).
- The third commit adds `initializer-suggestions = "machine-applicable"`
to Clippy's `clippy.toml` and applies the suggestions. (Nothing seems to
break.)
---
changelog: make `inconsistent_struct_constructor` "all fields are
shorthand" requirement configurable
|
|
|
|
Handle field attributes in suggestions
Fix adjacent code
Address review comments
https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1861352124
Address all review comments but one
This comment is not yet addressed: https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1874544907
`initializer_suggestions` -> `lint_inconsistent_struct_field_initializers`
|
|
clippy-subtree-update
|
|
|
|
(#13826)
fix #12653
changelog: [`filter_map_identity`]: don't lint for creating an iterator
from an empty array
|
|
|
|
|
|
changelog:
```
changelog: [`needless_option_take`]: now lints for all temporary expressions of type Option<T>.
```
fixes #13671
In general, needless_option_take should report whenever take() is called
on a temporary value, not just when the temporary value is created by
as_ref().
Also, we stop emitting machine applicable fixes in these cases, since
sometimes the intention of the user is to actually clear the original
option, in cases such as `option.as_mut().take()`.
|
|
filter_map_identity lint
|
|
|
|
In general, needless_option_take should report whenever
take() is called on a temporary value, not just when the
temporary value is created by as_ref()
|
|
|
|
|
|
|
|
- `ControlFlow::map_break()`
- `ControlFlow::map_continue()`
- `Iterator::map()`
|
|
|