about summary refs log tree commit diff
path: root/clippy_lints/src/methods
AgeCommit message (Collapse)AuthorLines
2024-09-03Auto merge of #13263 - y21:warn_manual_c_str_literals, r=Centri3bors-1/+1
move `manual_c_str_literals` to complexity IMO the suggestion to use `c""` literals over a hardcoded `\0` byte string literal has some fairly strong upsides (no need to manually null-terminate it and the compiler checks for intermediary null bytes) that this should just be enabled by default. It's also written slightly conservatively to only emit a warning when we can be reasonably confident that the lint is *actually* applicable (that is, lint on e.g. `b"foo\0".as_ptr()` but not `b"foo\0"`. The latter looks like a c-string but its type is `&[u8; _]`, and if it's used in a context where a byte slice is needed then you have no nice way to convert to it from a `c"foo"` literal of type `&CStr`). changelog: move [`manual_c_str_literals`] to complexity (now warn-by-default)
2024-09-01Auto merge of #13325 - alex-semenyuk:wrong_self_convention_doc_fix, r=y21bors-0/+11
Provide more clear example for `WRONG_SELF_CONVENTION` Provide more clear example for `WRONG_SELF_CONVENTION` changelog: none
2024-08-31Provide more clear example for WRONG_SELF_CONVENTIONalexey semenyuk-0/+11
2024-08-28Auto merge of #13235 - kyoto7250:fix_issue_13191, r=llogiqbors-21/+24
Use `is_diagnostic_item` for checking a def_id in `unnecessary_min_or_max`. close #13191 This PR fixes the false positives in `unnecessary_min_or_max `. We should use `is_diagnostic_item` for checking def_ids in this lint. ---- changelog: fix false positive in `unnecessary_min_or_max `.
2024-08-25Auto merge of #13091 - Alexendoo:empty-line-after-rewrite, r=dswijbors-1/+0
Rewrite `empty_line_after_doc_comments` and `empty_line_after_outer_attr`, move them from `nursery` to `suspicious` changelog: [`empty_line_after_doc_comments`], [`empty_line_after_outer_attr`]: rewrite and move them from `nursery` to `suspicious` They now lint when there's a comment between the last attr/doc comment and the empty line, to cover the case: ```rust /// Docs for `old_code // fn old_code() {} fn new_code() {} ``` When these lints or `suspicious_doc_comments` trigger we no longer trigger any other doc lint as a broad fix for #12917, reverts some of #13002 as the empty line lints cover it I ended up not doing https://github.com/rust-lang/rust-clippy/issues/12917#issuecomment-2161828859 as I don't think it's needed
2024-08-24Merge branch 'master' into rustupJason Newcomb-63/+72
2024-08-24Rewrite empty_line_after_doc_comments and empty_line_after_outer_attrAlex Macleod-1/+0
2024-08-24Auto merge of #13296 - Jarcho:get_src_display3, r=Alexendoobors-45/+55
Replace more uses of `snippet_opt`. Almost all calls are removed after this. changelog: none
2024-08-24Fix suggestion unwrap_or_elseAlexey Semenyuk-2/+2
2024-08-21Replace more uses of `snippet_opt`.Jason Newcomb-45/+55
2024-08-21Start removing `snippet_opt`Jason Newcomb-4/+4
2024-08-17Replace some iteration with `get_[type_]diagnostic_name`Alex Macleod-4/+5
2024-08-17Remove redundant doc commentsAlex Macleod-2/+0
2024-08-17Replace `span_suggestion_with_style` with `_verbose`Alex Macleod-2/+1
2024-08-12move `manual_c_str_literals` to complexityy21-1/+1
2024-08-12fix code blocks in doc comments inconsistently using 3 or 4 spaces of ↵Antoni Spaanderman-3/+3
indentation
2024-08-09Shrink `TyKind::FnPtr`.Nicholas Nethercote-1/+1
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.
2024-08-08Merge commit 'cb806113e0f83a8f9b47d35b453b676543bcc40e' into ↵Philipp Krones-112/+128
clippy-subtree-update
2024-08-08Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-113/+130
2024-08-09check the def_id with using diagnostic_item in unnecessary_min_or_max lintkyoto7250-21/+24
https://github.com/rust-lang/rust-clippy/issues/13191
2024-08-08Require `ConstEvalCtxt` to be constructed.Jason Newcomb-24/+23
2024-08-06Auto merge of #13145 - xFrednet:07797-restriction-and-then-why, r=Jarchobors-2/+5
Make restriction lint's use `span_lint_and_then` (q -> w) This migrates a few restriction lints to use `span_lint_and_then`. This change is motivated by https://github.com/rust-lang/rust-clippy/issues/7797. I've also cleaned up some lint message. Mostly minor stuff. For example: suggestions with a longer message than `"try"` now use `SuggestionStyle::ShowAlways` --- cc: https://github.com/rust-lang/rust-clippy/issues/7797 sister PR of: https://github.com/rust-lang/rust-clippy/pull/13136 changelog: none
2024-08-05Auto merge of #13136 - xFrednet:07797-restriction-and-then, r=blyxyasbors-31/+45
Make restriction lint's use `span_lint_and_then` (a -> e) This migrates a few restriction lints to use `span_lint_and_then`. This change is motivated by https://github.com/rust-lang/rust-clippy/issues/7797. I'm also interested if it will have an impact on performance. With some of these lints, like [`clippy::implicit_return`](https://rust-lang.github.io/rust-clippy/master/index.html#/implicit_return) I expect an impact, as it was previously creating a suggestion **for every implicit return** which is just wild. I've also cleaned up some lint message. Mostly minor stuff. For example: suggestions with a longer message than `"try"` now use `SuggestionStyle::ShowAlways` --- `@blyxyas` Could you benchmark this PR? I want to get all the numbers :3 --- This also crashed our new lintcheck CI with the following message: > Error: $GITHUB_STEP_SUMMARY upload aborted, supports content up to a size of 1024k, got 46731k. For more information see: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-markdown-summary Which is just wild. Like, I've [tested the first 20 lints](https://github.com/xFrednet/rust-clippy/actions/runs/10027528172) and got like four changes and then this. 50 MB of changed lint messages o.O. Looks like I'll create a separate PR to fix that step ^^ --- cc: https://github.com/rust-lang/rust-clippy/issues/7797 changelog: none r? `@blyxyas`
2024-08-04Auto merge of #13213 - Alexendoo:multispan-sugg, r=y21bors-13/+13
Remove `multispan_sugg[_with_applicability]` They're thin wrappers over the corresponding diag method so we should just use that instead changelog: none
2024-08-04Remove `multispan_sugg[_with_applicability]`Alex Macleod-13/+13
2024-08-03Add clarification for from_iter_instead_of_collectalexey semenyuk-1/+11
2024-08-03Migrating restriction lints to `span_lint_and_then` (e -> i)xFrednet-21/+32
2024-08-03Migrating restriction lints to `span_lint_and_then` (a -> d)xFrednet-10/+13
2024-08-03Auto merge of #13115 - tesuji:rm-dup-peels, r=dswijbors-10/+9
Remove duplicated `peel_middle_ty_refs` TODO: Should we move `ty::peel_mid_ty_refs_is_mutable` to super module too? changelog: none
2024-07-29Remove some miscellaneous `#[allow]`sAlex Macleod-19/+6
2024-07-27Make restriction lint's use `span_lint_and_then` (t -> w)xFrednet-2/+5
2024-07-26Auto merge of #13130 - nyurik:ref-lints, r=Centri3bors-2/+2
Avoid ref when using format! 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. See also https://github.com/rust-lang/rust/issues/112156 changelog: none
2024-07-26Auto merge of #13144 - xFrednet:07797-restriction-and-then-what, r=y21bors-4/+8
Make restriction lint's use `span_lint_and_then` (i -> p) This migrates a few restriction lints to use `span_lint_and_then`. This change is motivated by https://github.com/rust-lang/rust-clippy/issues/7797. I've also cleaned up some lint message. Mostly minor stuff. For example: suggestions with a longer message than `"try"` now use `SuggestionStyle::ShowAlways` --- cc: https://github.com/rust-lang/rust-clippy/issues/7797 brother PR of: https://github.com/rust-lang/rust-clippy/pull/13136 changelog: none
2024-07-26Make restriction lint's use `span_lint_and_then` (n -> p)xFrednet-1/+0
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