about summary refs log tree commit diff
path: root/clippy_lints/src
AgeCommit message (Collapse)AuthorLines
2024-12-31better suggestion for slow_vector_initializationlapla-cogito-9/+13
2024-12-30Use the full lifetime name in suggestions (#13907)Manish Goregaokar-2/+5
Using `lifetime.ident.name` in suggestions will not output the raw modifier. For example, `'r#struct` will be rendered as `'struct` which would be incorrect. Fix #13899 changelog: [`needless_arbitrary_self_type`]: use the raw lifetime name in suggestions
2024-12-30Fix parentheses when replacing `matches!(…, None)` with `.is_none()` (#13906)Timo-3/+5
Proper parentheses need to be added to some expressions in receiver position. Fix #13902 changelog: [`redundant_pattern_matching`]: use proper parentheses when suggesting replacing `matches!(…, None)` by `.is_none()`
2024-12-30Correctly handle `char` pathsGuillaume Gomez-0/+1
2024-12-30Use the full lifetime name in suggestionsSamuel Tardieu-2/+5
Using `lifetime.ident.name` in suggestions will not output the raw modifier. For example, `'r#struct` will be rendered as `'struct` which would be incorrect.
2024-12-29Fix parentheses when replacing `matches!(…, None)` with `.is_none()`Samuel Tardieu-3/+5
2024-12-29Do not remove identity mapping if mandatory mutability would be lostSamuel Tardieu-2/+13
Removing `.map(identity)` may result in invalid code if the receiver of `map()` is an immutable binding, and the result of `map()` is used as the receiver of a method call expecting a mutable reference.
2024-12-29Move more def paths into `clippy_utils::paths`Guillaume Gomez-2/+4
2024-12-29Do not remove required parentheses in `borrow_as_ptr` suggestion (#13884)Alejandra González-18/+18
Also, simplify boolean shortcut expression, and ensure that applicability is properly applied, as it was ignored and `MachineApplicable` was always used. changelog: [`borrow_as_ptr`]: do not remove required parentheses in autofix suggestion Close #13882
2024-12-29`borrow_interior_mutable_const` ICE into FN (#13877)Fridtjof Stoldt-5/+6
This PR just makes sure that we exit the function before getting an ICE and adds a regression test. Related to #12979. We would need to keep researching the issue, but as the ICEing code isn't that complicated, getting a hotfix into nightly is urgent. changelog:[`borrow_interior_mutable_const`] Fix ICE #12979
2024-12-29Do not remove required parentheses in `borrow_as_ptr` suggestionSamuel Tardieu-18/+18
Also, simplify boolean expression, and ensure that proper applicability is used.
2024-12-29Move `format_push_string` and `format_collect` to pedanticSamuel Moelius-3/+4
2024-12-29use the correct `ParamEnv` when checking future's output type (#13863)dswij-2/+9
Fixes #13862 `missing_headers::check` is sometimes called from outside of a body (specifically, from `check_attributes`, where the LateContext's ParamEnv is not yet properly initialized for that item). Using that empty ParamEnv for trait solving things from within the body can then lead to various ICEs, like the linked issue where we have a const generic parameter `DMA_INST` without a `ConstArgHasType` bound in the ParamEnv so the const parameter has no type, which is normally not supposed to happen. We have the item's DefId so we can just get its ParamEnv/TypingEnv from there, and using that one for trait solving should be safe. changelog: none
2024-12-29Examples fixes for regex (#13874)dswij-0/+10
Examples fixes for regex changelog: none
2024-12-29Do not trigger `trailing_empty_array` in tests (#13844)llogiq-2/+5
Close #13837 changelog: [`trailing_empty_array`]: do not trigger on tests
2024-12-28borrow_interior_mutable_const ICE into FNblyxyas-5/+6
Convert the ICE reported in #12979 into a false negative. We prefer a false negative to a ICE (because the ICE could still affect the user even when not activating the lint).
2024-12-28[`needless_continue`]: lint if the last stmt in for/while/loop is ↵lengyijun-28/+101
`continue`, recursively fixes: #4077
2024-12-27Make `inconsistent_struct_constructor` "all fields are shorthand" ↵Timo-79/+136
requirement configurable (#13737) Fixes #11846. This PR has three commits: - The first commit adds an `initializer-suggestions` configuration to control suggestion applicability when initializers are present. The following are the options: - "none": do not suggest - "maybe-incorrect": suggest, but do not apply suggestions with `--fix` - "machine-applicable": suggest and apply suggestions with `--fix` - The second commit fixes suggestions to handle field attributes (problem [noticed by @samueltardieu](https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1859261645)). - The third commit adds `initializer-suggestions = "machine-applicable"` to Clippy's `clippy.toml` and applies the suggestions. (Nothing seems to break.) --- changelog: make `inconsistent_struct_constructor` "all fields are shorthand" requirement configurable
2024-12-27remove description of known problems in `match_same_arms` that have already ↵Fridtjof Stoldt-5/+0
been resolved (#13873) The "known problems" pointed out in the `match_same_arms` lint seem to have already been resolved. changelog: none
2024-12-27correct suggestion for `manual_div_ceil` lint (#13864)Fridtjof Stoldt-3/+35
fix #13843 The `manual_div_ceil` lint makes incorrect suggestion when type suffixes need to be made explicit in the suggested code. changelog: [`manual_div_ceil`]: suggested code now includes appropriate type suffixes where necessary
2024-12-27don't suggest to use cloned for Cow in unnecessary_to_ownedlapla-cogito-0/+3
2024-12-26Make "all fields are shorthand" requirement configurableSamuel Moelius-79/+136
Handle field attributes in suggestions Fix adjacent code Address review comments https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1861352124 Address all review comments but one This comment is not yet addressed: https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1874544907 `initializer_suggestions` -> `lint_inconsistent_struct_field_initializers`
2024-12-26Merge commit '609cd310be44677ae31d452a17b0f8207e1abfe1' into ↵Philipp Krones-402/+1188
clippy-subtree-update
2024-12-26Merge remote-tracking branch 'upstream/master' into rustupPhilipp Krones-407/+1190
2024-12-24auto-fix `if_not_else` (#13809)llogiq-3/+51
fix #13411 The `if_not_else` lint can be fixed automatically, but the issue above reports that there is no implementation to do so. Therefore, this PR implements it. ---- changelog: [`if_not_else`]: make suggestions for modified code
2024-12-24Examples fixes for regexalexey semenyuk-0/+10
2024-12-24remove known problems section from match_same_armslapla-cogito-5/+0
2024-12-23chore: multipart suggestions for let_unit_value lint (#13754)Alejandra González-11/+24
This should address #13099 for the let_unit test. changelog: [let_unit]: Updated let_unit to use multipart_suggestions where appropriate
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-1/+2
2024-12-23correct suggestion for manual_div_ceil lintlapla-cogito-3/+35
2024-12-21use the correct `ParamEnv` when checking future's return type in ↵y21-2/+9
`missing_errors_doc`
2024-12-19Add allow-indexing-slicing-in-tests option (#13854)llogiq-1/+12
Close #13842 changelog: [`indexing_slicing`]: add allow-indexing-slicing-in-tests option to be able ignore at test
2024-12-20Add allow-indexing-slicing-in-tests optionAlexey Semenyuk-1/+12
2024-12-19Auto merge of #133961 - lcnr:borrowck-cleanup, r=jackh726bors-1/+1
cleanup region handling: add `LateParamRegionKind` The second commit is to enable a split between `BoundRegionKind` and `LateParamRegionKind`, by avoiding `BoundRegionKind` where it isn't necessary. The third comment then adds `LateParamRegionKind` to avoid having the same late-param region for separate bound regions. This fixes #124021. r? `@compiler-errors`
2024-12-18Use two structs rather than a const genericSamuel Moelius-12/+13
2024-12-18introduce `LateParamRegionKind`lcnr-1/+1
2024-12-18Rollup merge of #134161 - nnethercote:overhaul-token-cursors, r=spastorino许杰友 Jieyou Xu (Joe)-4/+4
Overhaul token cursors Some nice cleanups here. r? `````@davidtwco`````
2024-12-17chore: starting to fix unnecessary_iter_cloned (#13848)Alejandra González-8/+8
This will address https://github.com/rust-lang/rust-clippy/issues/13099 for the unnecessary_iter_cloned test. changelog: [unnecessary_iter_cloned]: unnecessary_iter_cloned manual_assert to use multipart_suggestions where appropriate
2024-12-18Rename `RefTokenTreeCursor`.Nicholas Nethercote-4/+4
Because `TokenStreamIter` is a much better name for a `TokenStream` iterator. Also rename the `TokenStream::trees` method as `TokenStream::iter`, and some local variables.
2024-12-18Simplify `RefTokenTreeCursor::look_ahead`.Nicholas Nethercote-1/+1
It's only ever used with a lookahead of 0, so this commit removes the lookahead and renames it `peek`.
2024-12-17Do not mark attributes with unknown namespace as useless (#13766)Philipp Krones-18/+25
Fixes #13764 changelog: [`useless_attribute`]: do not trigger on attributes with unknown namespace
2024-12-17Change unnecessary_iter_cloned to use multipart_suggestionScott Gerring-8/+8
2024-12-17Don't trigger `filter_map_identity` with an iterator from an empty array ↵Jason Newcomb-0/+10
(#13826) fix #12653 changelog: [`filter_map_identity`]: don't lint for creating an iterator from an empty array
2024-12-17Do not trigger trailing_empty_array in testsAlexey Semenyuk-2/+5
2024-12-16rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structuresJonathan Dönszelmann-7/+9
2024-12-16Correctly handle string indices in `literal_string_with_formatting_arg` (#13841)Philipp Krones-1/+10
Fixes https://github.com/rust-lang/rust-clippy/issues/13838. r? @klensy changelog: Correctly handle string indices in `literal_string_with_formatting_arg`
2024-12-16Correctly handle string indices in `literal_string_with_formatting_arg`Guillaume Gomez-1/+10
2024-12-16correct suggestion for `unnecessary_sort_by` in `no_std` (#13836)llogiq-3/+5
fix #11524 In a `no_std` environment, we can use `core::cmp::Reverse` instead of `std::cmp::Reverse`. ---- changelog: [`unnecessary_sort_by`]: correct suggestion in `no_std`
2024-12-16correct suggestion for unnecessary_sort_by in no_stdlapla-cogito-3/+5
2024-12-16Do not suggest using `Error` in `no_std` before Rust 1.81 (#13834)llogiq-12/+28
changelog: [`result_unit_err`]: do not suggest using `Error` in `no_std` mode before Rust 1.81 Fix #9767