about summary refs log tree commit diff
path: root/clippy_lints/src/methods
AgeCommit message (Collapse)AuthorLines
2024-05-27`unnecessary_to_owned` should not suggest to remove `&` in macro expansionMarc Dominik Migge-15/+17
2024-05-23For restriction lints, replace “Why is this bad?” with “Why restrict ↵Kevin Reid-10/+11
this?” The `restriction` group contains many lints which are not about necessarily “bad” things, but style choices — perhaps even style choices which contradict conventional Rust style — or are otherwise very situational. This results in silly wording like “Why is this bad? It isn't, but ...”, which I’ve seen confuse a newcomer at least once. To improve this situation, this commit replaces the “Why is this bad?” section heading with “Why restrict this?”, for most, but not all, restriction lints. I left alone the ones whose placement in the restriction group is more incidental. In order to make this make sense, I had to remove the “It isn't, but” texts from the contents of the sections. Sometimes further changes were needed, or there were obvious fixes to make, and I went ahead and made those changes without attempting to split them into another commit, even though many of them are not strictly necessary for the “Why restrict this?” project.
2024-05-21Added check for type unification with the iterschvv31n-3/+7
2024-05-20Accounted for possible extra layers before the consuming parent exprschvv31n-2/+2
2024-05-20fixed formattingschvv31n-5/+6
2024-05-20Lint on closure calls, suppress on callable constants callsschvv31n-8/+7
2024-05-19initial fixschvv31n-1/+42
2024-05-19Swap `for_each_expr` and `for_each_expr_with_closures`Alex Macleod-8/+8
2024-05-16Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-17/+81
2024-05-13split out AliasTy -> AliasTermMichael Goulet-1/+1
2024-05-12Propagate errors rather than using return_if_errMichael Goulet-2/+1
2024-05-12Make LateCtxt be a type info delegate for EUV for clippyMichael Goulet-6/+3
2024-05-11Auto merge of #12770 - notriddle:notriddle/doc-lazy-continuation, r=llogiqbors-4/+7
Add new lint `doc_lazy_continuation` changelog: [`doc_lazy_continuation`]: add lint that warns on so-called "lazy paragraph continuations" This is a follow-up for https://github.com/rust-lang/rust/pull/121659, since most cases of unintended block quotes are lazy continuations. The lint is designed to be more generally useful than that, though, because it will also catch unintended list items and unintended block quotes that didn't coincidentally hit a pulldown-cmark bug. The second commit is the result of running `cargo dev dogfood --fix`, and manually fixing anything that seems wrong. NOTE: this lint's suggestions should never change the parser's interpretation of the markdown, but in many cases, it seems that doc comments in clippy were written without regard for this feature of Markdown (which, I suppose, is why this lint should exist).
2024-05-08Simplify `use crate::rustc_foo::bar` occurrences.Nicholas Nethercote-1/+1
They can just be written as `use rustc_foo::bar`, which is far more standard. (I didn't even know that a `crate::` prefix was valid.)
2024-05-07Check inner caller for clone and judge whether they are mutablecocodery-2/+51
if immutbale -> lint delete redudant clone if mutable -> lint check whether clone is needed
2024-05-06Update doc comments to avoid lazy continuationsMichael Howell-4/+7
2024-05-03Auto merge of #12567 - Alexendoo:format-args-storage, r=flip1995bors-4/+18
Fix `FormatArgs` storage when `-Zthreads` > 1 Fixes #11886 The initial way I thought of was a little gross so I never opened a PR for it, I thought of a nicer way today that no longer involves any `thread_local`s or `static`s `rustc_data_strucutres::sync::{Lrc, OnceLock}` implement `DynSend` + `DynSync` so we can pass them to the lint passes that need the storage changelog: none r? `@flip1995`
2024-05-02Merge commit '20b085d500dfba5afe0869707bf357af3afe20be' into ↵Philipp Krones-24/+35
clippy-subtree-update
2024-05-02Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-25/+37
2024-05-02Auto merge of #12735 - xFrednet:changelog-1-78, r=dswijbors-2/+2
Changelog for Clippy 1.78 :magic_wand: Roses and Violets have colors, Red and Blue are the two, I'm getting to the end of my masters, what a cool goal to pursue --- ### The cat of this release is: *Shadow* submitted by `@benwh1:` <img height=500 src="https://github.com/rust-lang/rust-clippy/assets/32911992/c56af314-4644-482a-a08e-f32f4c7d7b22" alt="The cats of this Clippy release" /> Cats for the next release can be nominated in the comments :D --- changelog: none
2024-05-01Fix `FormatArgs` storage when `-Zthreads` > 1Alex Macleod-4/+18
2024-04-29Update version attribute for 1.78 lintsxFrednet-2/+2
2024-04-29suppress `readonly_write_lock` for underscore-prefixed bindingsy21-1/+6
2024-04-27Auto merge of #12624 - J-ZhengLi:issue12586, r=xFrednetbors-3/+2
fix [`large_stack_arrays`] linting in `vec` macro fixes: #12586 this PR also adds a wrapper function `matching_root_macro_call` to `clippy_utils::macros`, considering how often that same pattern appears in the codebase. (I'm always very indecisive towards naming, so, if anyone have better idea of how that function should be named, feel free to suggest it) --- changelog: fix [`large_stack_arrays`] linting in `vec` macro; add `matching_root_macro_call` to clippy_utils
2024-04-23chore: fix some typos in commentsforcedebug-1/+1
Signed-off-by: forcedebug <forcedebug@outlook.com>
2024-04-22Auto merge of #11852 - rust-lang:single-char-pattern-ascii-only, r=xFrednetbors-11/+20
reduce `single_char_pattern` to only lint on ascii chars This should mostly fix the `single_char_pattern` lint, because with a single byte, the optimizer will usually see through the char-to-string-expansion and single loop iteration. This fixes #11675 and #8111. Update: As per the meeting on November 28th, 2023, we voted to also downgrade the lint to pedantic. --- changelog: downgrade [`single_char_pattern`] to `pedantic`
2024-04-18Merge commit 'ca3b393750ee8d870bf3215dcf6509cafa5c0445' into ↵Philipp Krones-8/+31
clippy-subtree-update
2024-04-18Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-9/+33
2024-04-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-16/+16
2024-04-17fix [`large_stack_arrays`] linting in `vec` macro & add ↵J-ZhengLi-3/+2
`matching_root_macro_call` function in `clippy_utils`
2024-04-16Always use `ty::` qualifier for `TyKind` enum variants.Nicholas Nethercote-3/+3
Because that's the way it should be done.
2024-04-14Auto merge of #12094 - yuxqiu:search_is_some, r=xFrednet,ARandomDev99bors-7/+31
fix: incorrect suggestions when `.then` and `.then_some` is used fixes #11910 In the current implementation of `search_is_some`, if a `.is_none` call is followed by a `.then` or `.then_some` call, the generated `!` will incorrectly negate the values returned by the `then` and `.then_some` calls. To fix this, we need to add parentheses to the generated suggestions when appropriate. changelog: [`search_is_some`]: add parenthesis to suggestions when appropriate
2024-04-11downgrade to pedanticAndre Bogus-3/+5
2024-04-11reduce `single_char_pattern` to only lint on ascii charsAndre Bogus-10/+17
2024-04-08Fix markdown syntax in str_split_at_newline docsWilfred Hughes-1/+0
2024-04-08Stop exporting `TypeckRootCtxt` and `FnCtxt`.Oli Scherer-4/+1
While they have many convenient APIs, it is better to expose dedicated functions for them
2024-04-04Merge commit '9725c4a162502a02c1c67fdca6b797fe09b2b73c' into ↵Philipp Krones-165/+209
clippy-subtree-update
2024-04-04Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-166/+211
2024-04-01fix: fix ci errorsYuxiang Qiu-1/+1
2024-04-01fix: check if receiver's hir_id matches expr's hir_idYuxiang Qiu-1/+2
2024-04-01fix: incorrect suggestions when `.then` and `.then_some` is usedYuxiang Qiu-6/+29
2024-04-01fix fallout from previous commity21-76/+76
2024-03-31Auto merge of #12562 - m-rph:12501, r=y21bors-3/+15
Allow `filter_map_identity` when the closure is typed This extends the `filter_map_identity` lint to support typed closures. For untyped closures, we know that the program compiles, and therefore we can safely suggest using flatten. For typed closures, they may participate in type resolution. In this case we use `Applicability::MaybeIncorrect`. Details: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Should.20.60filter_map_identity.60.20lint.20when.20closures.20are.20typed.3F changelog: `filter_map_identity` will now suggest using flatten for typed closures. r? `@y21` && `@Centri3`
2024-03-30lint on any `Box<dyn _>`, but provide a suggestion for subtypes of `dyn Any`y21-42/+55
2024-03-30[`type_id_on_box`]: lint of `Any` subtraitsy21-12/+34
2024-03-27Implement `mut ref`/`mut ref mut`Jules Bertholet-4/+3
2024-03-26Inherited -> TypeckRootCtxtMichael Goulet-3/+3
2024-03-26:adjust applicability for typed identity closures in `filter_map_identity`Quinn Sinclair-1/+1
2024-03-25Allow `filter_map_identity` when the closure is typedQuinn Sinclair-3/+15
This extends the `filter_map_identity` lint to support typed closures. For untyped closures, we know that the program compiles, and therefore we can safely suggest using flatten. For typed closures, they may participate in type resolution. In this case we use `Applicability::MaybeIncorrect`. Details: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Should.20.60filter_map_identity.60.20lint.20when.20closures.20are.20typed.3F
2024-03-23Rollup merge of #122780 - GuillaumeGomez:rename-hir-local, r=oli-obkMatthias Krüger-10/+10
Rename `hir::Local` into `hir::LetStmt` Follow-up of #122776. As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F). I made this change into a separate PR because I'm less sure about this change as is. For example, we have `visit_local` and `LocalSource` items. Is it fine to keep these two as is (I supposed it is but I prefer to ask) or not? Having `Node::Local(LetStmt)` makes things more explicit but is it going too far? r? ```@oli-obk```