| Age | Commit message (Collapse) | Author | Lines |
|
r? @ghost
changelog: none
|
|
|
|
|
|
|
|
This is the lint described at
https://github.com/rust-lang/rust/pull/136308#issuecomment-2625485331
that recommends using HTML to nest links inside code.
changelog: [`doc_link_code`]: warn when a link with code and a code span
are back-to-back
|
|
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`.
Close #14195
changelog: [`mem_replace_option_with_some`]: new lint
|
|
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`.
|
|
|
|
Checks for functions with method calls to `.map(_)` on an arg of type
`Option` as the outermost expression.
Fixes #774
```
changelog: [`single_option_map`]: Checks for functions with method calls to `.map(_)` on an arg of type `Option` as the outermost expression.
```
|
|
|
|
of pedantic (#14027)
While extending the `option_map_or_err_ok` lint (warn by default,
"style") to recognize η-expanded forms of `Ok`, as in
```rust
// Should suggest `opt.ok_or("foobar")`
let _ = opt.map_or(Err("foobar"), |x| Ok(x));
```
I discovered that the `manual_ok_or` lint (allow by default, "pedantic")
already covered exactly the cases handled by `option_map_or_err_ok`,
including the one I was adding. Apparently, `option_map_or_err_ok` was
added without realizing that the lint already existed under the
`manual_ok_or` name. As a matter of fact, artifacts of this second lint
were even present in the first lint `stderr` file and went unnoticed for
more than a year.
This PR:
- deprecates `option_map_or_err_ok` with a message saying to use
`manual_ok_or`
- moves `manual_ok_or` from "pedantic" to "style" (the category in which
`option_map_or_err_ok` was)
In addition, I think that this lint, which is short, machine applicable,
and leads to shorter and clearer code with less arguments (`Ok`
disappears) and the removal of one level of call (`Err(x)` is replaced
by `x`), is a reason by itself to be in "style".
changelog: [`option_map_or_err_ok` and `manual_ok_or`]: move
`manual_ok_or` from "pedantic" to "style", and deprecate the redundant
style lint `option_map_or_err_ok`.
|
|
into early lints
|
|
clippy-subtree-update
|
|
Hey folks. It's been a while since I added the `as_slice` method to
`Option`, and I totally forgot about a lint to suggest it. Well, I had
some time around Christmas, so here it is now.
---
changelog: add [`manual_option_as_slice`] lint
|
|
close #13856
changelog: [`manual_slice_fill`]: new lint
|
|
|
|
This is the lint described at
https://github.com/rust-lang/rust/pull/136308#issuecomment-2625485331
that recommends using HTML to nest links inside code.
|
|
Commit 25505302665a707bedee68ca1f3faf2a09f12c00 has extended the
`precedence` lint to include bitmasking and shift operations. The lint
is warn by default, and this generates many hits, especially in embedded
or system code, where it is very idiomatic to use expressions such as `1
<< 3 | 1 << 5` without parentheses.
This commit splits the recent addition into a new lint, which is put
into the "restriction" category, while the original one stays in
"complexity", because mixing bitmasking and arithmetic operations is
less typical.
Fix #14097
changelog: [`precedence_bits`]: new lint
|
|
Commit 25505302665a707bedee68ca1f3faf2a09f12c00 has extended the
`precedence` lint to include bitmasking and shift operations. The lint
is warn by default, and this generates many hits, especially in embedded
or system code, where it is very idiomatic to use expressions such as
`1 << 3 | 1 << 5` without parentheses.
This commit splits the recent addition into a new lint, which is put
into the "restriction" category, while the original one stays in
"complexity", because mixing bitmasking and arithmetic operations is
less typical.
|
|
|
|
clippy-subtree-update
|
|
|
|
Add a new lint `doc_overindented_list_items` to detect and fix list items
in docs that are overindented.
For example,
```rs
/// - first line
/// second line
fn foo() {}
```
this would be fixed to:
```rs
/// - first line
/// second line
fn foo() {}
```
This lint improves readabiliy and consistency in doc.
|
|
|
|
|
|
|
|
|
|
|
|
detect usage of `once_cell::sync::Lazy` and `lazy_static!`,
recommending usage of `std::sync::LazyLock` instead
|
|
|
|
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
|
|
|
|
|
|
|
|
Closes #13400.
changelog: [`unneeded_struct_pattern`]: Add new lint
|
|
changelog: [`manual_ok_err`]: new lint
Detect manual implementations of `.ok()` or `.err()`, as in
```rust
let a = match func() {
Ok(v) => Some(v),
Err(_) => None,
};
let b = if let Err(v) = func() {
Some(v)
} else {
None
};
```
which can be replaced by
```rust
let a = func().ok();
let b = func().err();
```
This pattern was detected in the wild in the Rust reimplementation of
coreutils:
https://github.com/uutils/coreutils/pull/6886#pullrequestreview-2465160137
|
|
|
|
clippy-subtree-update
|
|
|
|
clippy-subtree-update
|
|
Fixes #13375
I've added the lint next to the other attribute-related ones. Not sure
if this is the correct place, since while we are looking after the
`packed`-attribute (there is nothing we can do about types defined
elsewhere), we are more concerned about the type's representation set by
the attribute (instead of "duplicate attributes" and such).
The lint simply looks at the attributes themselves without concern for
the item-kind, since items where `repr` is not allowed end up in a
compile-error anyway.
I'm somewhat concerned about the level of noise this lint would cause
if/when it goes into stable, although it does _not_ come up in
`lintcheck`.
```
changelog: [`repr_packed_without_abi`]: Initial implementation
```
|
|
Fixes #13375
|
|
|
|
|
|
|
|
https://github.com/rust-lang/rust/issues/133150
This is more likely to be intended as an intra-doc link than it is to be
intended as a refdef. If a refdef is intended, it does not need to be
nested within a list item.
```markdown
- [`LONG_INTRA_DOC_LINK`]: this
looks like an intra-doc link,
but is actually a refdef.
The first line will seem to
disappear when rendered as HTML.
```
> - [`LONG_INTRA_DOC_LINK`]: this
> looks like an intra-doc link,
> but is actually a refdef.
> The first line will seem to
> disappear when rendered as HTML.
changelog: [`doc_nested_refdefs`]: add suspicious lint for link def at
start of list items and block quotes
|
|
|
|
Fixes #10195.
changelog: Added new [`literal_string_with_formatting_args`] `pedantic`
lint
[#13410](https://github.com/rust-lang/rust-clippy/pull/13410)
|
|
clippy-subtree-update
|
|
This is more likely to be intended as an intra-doc link than it is
to be intended as a refdef. If a refdef is intended, it does not
need to be nested within a list item or quote.
```markdown
- [`LONG_INTRA_DOC_LINK`]: this
looks like an intra-doc link,
but is actually a refdef.
The first line will seem to
disappear when rendered as HTML.
```
|