about summary refs log tree commit diff
path: root/clippy_lints/src/methods
AgeCommit message (Collapse)AuthorLines
2024-07-25Merge commit '37f4fbb92913586b73a35772efd00eccd1cbbe13' into ↵Philipp Krones-132/+175
clippy-subtree-update
2024-07-24Auto merge of #12830 - blyxyas:more-controlflow, r=y21,xFredNetbors-17/+15
Use ControlFlow in more places Now, instead of manually using variables in visitors to signify that a visit is "done" and that the visitor should stop traversing. We use the trait type "Result" to signify this (in relevant places). I'll schedule a perf run, I don't think it will be much of a difference, but every bit of performance is welcomed :) changelog: Improve performance, less memory use in visitors Fixes #12829 r? `@y21`
2024-07-24Replace local variables signifying "done" or "loop break", use ControlFlow ↵blyxyas-17/+15
#12830
2024-07-23Make `BindInsteadOfMap` a structAlex Macleod-48/+68
Makes it codegen once instead of three times
2024-07-22Make restriction lint's use `span_lint_and_then` (m -> m)xFrednet-4/+9
2024-07-19Avoid ref when using format!Yuri Astrakhan-2/+2
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
2024-07-17Refactor for using config values:Jason Newcomb-16/+10
* Construct lint passes by taking `Conf` by reference. * Use `HashSet` configs in less places * Move some `check_crate` code into the pass constructor when possible.
2024-07-17Remove duplicated peel_middle_ty_refsLzu Tao-10/+9
TODO: Should we move `ty::peel_mid_ty_refs_is_mutable` to super module too?
2024-07-13make [`or_fun_call`] and [`unwrap_or_default`] recursive.J-ZhengLi-46/+64
2024-07-12[`unwrap_or_default`]: skip warning when calling inside of suggested ↵J-ZhengLi-5/+18
method's implementation
2024-07-11Merge commit 'b794b8e08c16517a941dc598bb1483e8e12a8592' into ↵Philipp Krones-21/+88
clippy-subtree-update
2024-07-11Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-22/+90
2024-07-10Auto merge of #12984 - bitfield:fix_doc_nits_c, r=Alexendoobors-4/+3
Fix doc nits More tender love and polish for the documentation and suggestion texts: adding formatting, links, full stops, tweaking wording for readability, changing 'which' to 'that' where appropriate, and other standard copyediting changes. changelog: Docs [ `await_holding_lock` ]: fix doc nits changelog: Docs [ `await_holding_refcell_ref` ]: fix doc nits changelog: Docs [ `await_holding_invalid_type` ]: fix doc nits changelog: Docs [ `cast_precision_loss` ]: fix doc nits changelog: Docs [ `cast_sign_loss` ]: fix doc nits changelog: Docs [ `cast_possible_truncation` ]: fix doc nits changelog: Docs [ `cast_possible_wrap` ]: fix doc nits changelog: Docs [ `cast_lossless` ]: fix doc nits changelog: Docs [ `unnecessary_cast` ]: fix doc nits changelog: Docs [ `cast_ptr_alignment` ]: fix doc nits changelog: Docs [ `fn_to_numeric_cast` ]: fix doc nits changelog: Docs [ `fn_to_numeric_cast_with_truncation` ]: fix doc nits changelog: Docs [ `fn_to_numeric_cast_any` ]: fix doc nits changelog: Docs [ `char_lit_as_u8` ]: fix doc nits changelog: Docs [ `ptr_as_ptr` ]: fix doc nits changelog: Docs [ `ptr_cast_constness` ]: fix doc nits changelog: Docs [ `as_ptr_cast_mut` ]: fix doc nits changelog: Docs [ `little_endian_bytes` ]: fix doc nits changelog: Docs [ `big_endian_bytes` ]: fix doc nits changelog: Docs [ `bind_instead_of_map` ]: fix doc nits changelog: Docs [ `same_name_method` ]: fix doc nits
2024-07-07resolve code review commentsJohn Arundel-2/+1
2024-07-05Auto merge of #13049 - Jarcho:is_in_test, r=Alexendoobors-2/+2
Remove `is_in_test_module_or_function` Uses are replaced with `is_in_test` for consistency with other lints and to simplify the implementation of the lints. This means the module name is no longer checked, but that was a horrible hack from a time when late passes couldn't see `#[cfg(..)]` attributes. changelog: none
2024-07-05Use `is_in_test` in more places.Jason Newcomb-2/+2
2024-07-05Auto merge of #11656 - y21:unnecessary_string_from_utf8, r=Jarchobors-3/+67
[`unnecessary_to_owned`]: catch `to_owned` on byte slice to create temporary `&str` Closes #11648 Detects the pattern `&String::from_utf8(bytes.to_vec()).unwrap()` and suggests `core::str::from_utf8(bytes).unwrap()`, which avoids the unnecessary intermediate allocation. I decided to put this in the existing `unnecessary_to_owned` lint (rather than creating a new lint) for a few reasons: - we get to use some of its logic (for example, recognizing any of the functions in the `to_owned` family, e.g. `to_vec`) - the actual inefficient operation that can be avoided here is the call to `.to_vec()`, so this is in a way similar to the other cases caught by `unnecessary_to_owned`, just through a bunch of type conversions - we can make this more "generic" later and catch other cases, so imo it's best not to tie this lint specifically to the `String` type changelog: [`unnecessary_to_owned`]: catch `&String::from_utf8(bytes.to_vec()).unwrap()` and suggest `core::str::from_utf8(bytes).unwrap()`
2024-07-01`manual_inspect`: fix `clippy::version` from 1.78.0 to 1.81.0Miguel Ojeda-1/+1
Although `manual_inspect`'s PR started some months ago, the lint is only available in the current nightly (1.81.0), rather than 1.78.0. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-06-29Rollup merge of #127045 - compiler-errors:explicit, r=oli-obkMatthias Krüger-1/+1
Rename `super_predicates_of` and similar queries to `explicit_*` to note that they're not elaborated Rename: * `super_predicates_of` -> `explicit_super_predicates_of` * `implied_predicates_of` -> `explicit_implied_predicates_of` * `supertraits_containing_assoc_item` -> `explicit_supertraits_containing_assoc_item` This makes it clearer that, unlike (for example) [`TyCtxt::super_traits_of`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.super_traits_of), we don't automatically elaborate this set of predicates. r? ``@lcnr`` or ``@oli-obk`` or someone from t-types idc
2024-06-28Add error message to manual_inspect lintPhilipp Krones-11/+15
2024-06-27Merge commit '68a799aea9b65e2444fbecfe32217ce7d5a3604f' into ↵Philipp Krones-0/+382
clippy-subtree-update
2024-06-27Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-1/+384
2024-06-27Make queries more explicitMichael Goulet-1/+1
2024-06-24Split out IntoIterator and non-Iterator constructors for ↵Michael Goulet-2/+2
AliasTy/AliasTerm/TraitRef/projection
2024-06-23Fix doc nitsJohn Arundel-4/+4
2024-06-21Add new `Span` utils to avoid both allocating andJason Newcomb-13/+18
compressing/decompressing spans.
2024-06-20feat: unnecessary_min_max lintvohoanglong0107-0/+120
2024-06-20[`unnecessary_to_owned`]: catch to_owned from byte slice to stringy21-3/+67
2024-06-16Add lint `manual_inspect`Jason Newcomb-0/+257
2024-06-13Merge commit '3e5a02b13b1244545454752c6629b767522a44b1' into ↵Philipp Krones-192/+265
clippy-subtree-update
2024-06-13Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-193/+267
2024-06-11Add lint to check manual pattern char comparison and merge its code with ↵AurelienFT-151/+5
single_char_pattern lint
2024-06-11Auto merge of #12915 - belyakov-am:lint/single_char_add_str, r=xFrednetbors-2/+81
Handle single chars with `to_string()` for `single_char_add_str` Add support for single chars / literals with `to_string()` call for `push_str()` and `insert_str()`. changelog: [`single_char_add_str`]: handle single chars with `to_string()` call Closes #12775
2024-06-09Fix dogfood testArtem Belyakov-2/+2
2024-06-09Handle single chars with `to_string()` for `single_char_add_str`Artem Belyakov-2/+81
2024-06-07Auto merge of #12851 - samueltardieu:issue12846, r=y21bors-11/+1
Add required parentheses around method receiver Fix #12846 changelog: [`needless_bool`]: Add missing parentheses around method receiver
2024-06-07Auto merge of #12889 - xFrednet:changelog-1-79, r=flip1995,dswijbors-1/+1
Changelog for Clippy 1.79 🎓 Two cat ears from waffle, A tail and a dress, That's our Jyn, The magnificent cat ~ =^.^= --- ### The cat of this release is: *Jyn* submitted by `@jyn514:` <img height=600 src="https://github.com/rust-lang/rust-clippy/assets/17087237/2f902dea-9ad5-4ad2-b281-1f152b7ad7c7" alt="The cat(s) of this Clippy release" /> Cats for the next release can be nominated in the comments :D --- changelog: none
2024-06-07Auto merge of #12822 - Alexendoo:for-each-expr, r=dswijbors-8/+8
Make `for_each_expr` visit closures by default, rename the old version `for_each_expr_without_closures` A lot of the time `for_each_expr` is picked when closures should be visited so I think it makes sense for this to be the default with the alternative available for when you don't need to visit them. The first commit renames `for_each_expr` to `for_each_expr_without_closures` and `for_each_expr_with_closures` to `for_each_expr` The second commit switches a few uses that I caught over to include closures to fix a few bugs changelog: none
2024-06-06Move `is_receiver_of_method_call` to `clippy_utils` for reuseSamuel Tardieu-11/+1
2024-06-05Update version attribute for 1.79 lintsxFrednet-1/+1
2024-06-04Fix false positive for `needless_character_iteration` lintGuillaume Gomez-6/+23
2024-06-03Align Term methods with GenericArg methodsMichael Goulet-1/+1
2024-06-03Auto merge of #12815 - GuillaumeGomez:add-needless_character_iteration, ↵bors-18/+151
r=xFrednet Add `needless_character_iteration` lint Fixes #4817. r? `@xFrednet` changelog: Add `needless_character_iteration` lint
2024-05-30Auto merge of #125764 - flip1995:clippy-subtree-update, r=Manishearthbors-26/+74
Clippy subtree update r? `@Manishearth`
2024-05-30Merge commit 'c9139bd546d9cd69df817faeab62c5f9b1a51337' into ↵Philipp Krones-26/+74
clippy-subtree-update
2024-05-30Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-27/+76
2024-05-29Make `body_owned_by` return the body directly.Oli Scherer-2/+2
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-27Auto merge of #12823 - schvv31n:fix-iter-on-empty-collections, r=y21bors-1/+46
Suppress `iter_on_empty_collections` if the iterator's concrete type is relied upon changelog: fixed #12807
2024-05-27Auto merge of #12843 - mdm:fix-unnecessary-to-owned-println-interaction, r=y21bors-15/+17
Fix `unnecessary_to_owned` interaction with macro expansion fixes #12821 In the case of an unnecessary `.iter().cloned()`, the lint `unnecessary_to_owned` might suggest to remove the `&` from references without checking if such references are inside a macro expansion. This can lead to unexpected behavior or even broken code if the lint suggestion is applied blindly. See issue #12821 for an example. This PR checks if such references are inside macro expansions and skips this part of the lint suggestion in these cases. changelog: [`unnecessary_to_owned`]: Don't suggest to remove `&` inside macro expansion
2024-05-27Add `needless_character_iteration` lintGuillaume Gomez-18/+151