about summary refs log tree commit diff
path: root/clippy_lints/src/declared_lints.rs
AgeCommit message (Collapse)AuthorLines
2025-02-20Rustup (#14262)Philipp Krones-2/+2
r? @ghost changelog: none
2025-02-20Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-1/+5
2025-02-19add `owned_cow` lintAndre Bogus-0/+1
2025-02-16add `manual_contains` lintlapla-cogito-0/+1
2025-02-14doc_link_code: add check for links with code spans that render weird (#14121)Catherine Flores-0/+1
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
2025-02-12New lint: `mem_replace_option_with_some` (#14197)llogiq-0/+1
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`. Close #14195 changelog: [`mem_replace_option_with_some`]: new lint
2025-02-12New lint: `mem_replace_option_with_some`Samuel Tardieu-0/+1
`mem::replace(opt, Some(v))` can be replaced by `opt.replace(v)`.
2025-02-12New lint: `unbuffered_bytes`jonathan-0/+1
2025-02-09Add `single_option_map` lint (#14033)llogiq-0/+1
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. ```
2025-02-09Add single_option_map lintYusuf Raji-0/+1
2025-02-07Deprecate redundant lint `option_map_or_err_ok` and take `manual_ok_or` out ↵dswij-1/+0
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`.
2025-02-07Convert `EMPTY_LINE_AFTER_OUTER_ATTR` and `EMPTY_LINE_AFTER_OUTER_ATTR` lint ↵Guillaume Gomez-2/+2
into early lints
2025-02-06Merge commit '3e3715c31236bff56f1c63a1de2c7bbdfcfb0923' into ↵Philipp Krones-0/+4
clippy-subtree-update
2025-02-03new `manual_option_as_slice` lint (#13901)Alejandra González-0/+1
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
2025-02-03add `manual_slice_fill` lint (#14082)llogiq-0/+1
close #13856 changelog: [`manual_slice_fill`]: new lint
2025-02-03add `manual_slice_fill` lintlapla-cogito-0/+1
2025-01-30doc_link_code: add check for `text`[`adjacent`] style linksMichael Howell-0/+1
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.
2025-01-30New lint: `precedence_bits`, with recent additions to `precedence` (#14115)llogiq-0/+1
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
2025-01-30New lint: `precedence_bits`, with recent additions to `precedence`Samuel Tardieu-0/+1
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.
2025-01-29Add new lint `return_and_then`Aaron Ang-0/+1
2025-01-28Merge commit '51d49c1ae2785b24ef18a46ef233fc1d91844666' into ↵Philipp Krones-0/+8
clippy-subtree-update
2025-01-28Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-0/+8
2025-01-28Add new lint `doc_overindented_list_items`Yutaro Ohno-0/+1
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.
2025-01-26new `manual_option_as_slice` lintAndre Bogus-0/+1
2025-01-26remove `clippy::double_neg`Kalle Wachsmuth-1/+0
2025-01-25Rename slice_as_bytes -> sliced_string_as_byteswowinter13-1/+1
2025-01-25Address linter & changelog issueswowinter13-1/+1
2025-01-25New lintwowinter13-0/+1
2025-01-24add new lint `non_std_lazy_statics`J-ZhengLi-0/+1
detect usage of `once_cell::sync::Lazy` and `lazy_static!`, recommending usage of `std::sync::LazyLock` instead
2025-01-23Deprecate the `option_map_or_err_ok` lintSamuel Tardieu-1/+0
2025-01-20New lint: `unnecessary_semicolon` (#14032)llogiq-0/+1
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
2025-01-19New lint: `unnecessary_semicolon`Samuel Tardieu-0/+1
2025-01-15add `manual_repeat_n` lintlapla-cogito-0/+1
2025-01-13New lint `useless-nonzero-new_unchecked`Samuel Tardieu-0/+1
2025-01-12Add new lint `unneeded_struct_pattern` (#13465)Catherine Flores-0/+1
Closes #13400. changelog: [`unneeded_struct_pattern`]: Add new lint
2025-01-10New lint: manual_ok_err (#13740)Alejandra González-0/+1
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
2025-01-10New lint: manual_ok_errSamuel Tardieu-0/+1
2025-01-09Merge commit '19e305bb57a7595f2a8d81f521c0dd8bf854e739' into ↵Philipp Krones-0/+1
clippy-subtree-update
2025-01-01Add lint for calling last() on DoubleEndedIteratorQuentin Santos-0/+1
2024-12-26Merge commit '609cd310be44677ae31d452a17b0f8207e1abfe1' into ↵Philipp Krones-0/+4
clippy-subtree-update
2024-12-16Initial impl of `repr_packed_without_abi` (#13398)Alex Macleod-0/+1
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 ```
2024-12-15Initial impl `repr_packed_without_abi`Lukas Lueg-0/+1
Fixes #13375
2024-12-15Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-0/+3
2024-12-15Add new lint `unneeded_struct_pattern`Asuna-0/+1
2024-12-06new lint for `as *const _` and `as *mut _` castingSoveu-0/+1
2024-12-02doc_nested_refdefs: new lint for suspicious list syntax (#13707)Jason Newcomb-0/+1
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
2024-12-02Drop uplifted `clippy::fn_address_comparisons`Urgau-1/+0
2024-12-01Add new `literal_string_with_formatting_args` lint (#13410)Fridtjof Stoldt-0/+1
Fixes #10195. changelog: Added new [`literal_string_with_formatting_args`] `pedantic` lint [#13410](https://github.com/rust-lang/rust-clippy/pull/13410)
2024-11-28Merge commit 'ff4a26d442bead94a4c96fb1de967374bc4fbd8e' into ↵Philipp Krones-0/+1
clippy-subtree-update
2024-11-27doc_nested_refdefs: new lint for suspicious refdef syntaxMichael Howell-0/+1
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. ```