Commit graph

22039 commits

Author SHA1 Message Date
Alejandra González
ea30a09fe1
Leave assignments for now (#14428)
I love this project but I (again) don't have the time nor energy at the
moment. Will go through my current assignments over time and still
review occasionally.

PS: sorry about the branch on upstream!
changelog: none
2025-03-18 12:29:56 +00:00
Philipp Krones
a07e887e24
Improve string_to_string lint in case it is in a map call (#14396)
Fixes https://github.com/rust-lang/rust-clippy/issues/14175.

There are two "big" cases to handle: `.map(|x| x.to_string())` and
`.map(String::to_string)`. If the closure has more than one expression,
we should not suggest `.cloned()`.

changelog: Improve `string_to_string` lint in case it is in a map call

r? @samueltardieu
2025-03-18 10:29:10 +00:00
Guillaume Gomez
269b913bfd Better handle blocks with just one expression 2025-03-18 11:09:20 +01:00
Catherine Flores
b057ba4622
Leave assignments for now
I love this project but I (again) don't have the time nor energy at the moment. Will go through my current assignments over time and still review occasionally.
2025-03-17 22:34:44 -05:00
Alejandra González
4800557857
question_mark: avoid incorrect suggestion when ref binding used (#14158)
changelog: [`question_mark`]: avoid incorrect suggestion when `ref`
binding used

Fixes #13417
2025-03-16 23:25:26 +00:00
Alex Macleod
775a5c2712
fix incorrect suggestions related to parentheses in needless_return (#14094)
close #12157

`needless_return` sometimes makes incorrect suggestions by omitting
necessary enclosing parentheses. This PR resolves the issue by using
`clippy_utils::sugg::Sugg`.

changelog: [`needless_return`]: now makes correct suggestions which
require enclosing parentheses
2025-03-16 15:03:14 +00:00
Fridtjof Stoldt
1617a2e519
Remove @xFrednet from docs 👋 (#14415)
Cleaning up the last few loose ends. To everyone reading this: I hope
you have a beautiful day!

changelog: none

r? @ghost
2025-03-16 14:52:51 +00:00
Fridtjof Stoldt
3c7dfacf44
new lint: doc_comment_double_space_linebreaks (#12876)
Fixes https://github.com/rust-lang/rust-clippy/issues/12163

I decided to initially make this a restriction lint because it felt a
bit niche and opinionated to be a warn-by-default style lint. It may be
appropriate as a style lint if the standard or convention *is* to use
`\` as doc comment linebreaks - not sure if they are!

The wording on the help message could be improved, as well as the name
of the lint itself since it's a bit wordy - suggestions welcome.

This lint works on both `///` and `//!` doc comments.

changelog: new lint: `doc_comment_double_space_linebreaks`
2025-03-16 14:44:02 +00:00
xFrednet
9845b100ec
Remove @xFrednet from docs 👋 2025-03-16 15:19:49 +01:00
Michael Howell
4e9caa3985 question_mark: suggest as_ref/as_mut if ref binding is used 2025-03-15 15:59:24 -07:00
Alex Macleod
5c031d1f6a
Fix from_over_into lint suggesting invalid code (#14409)
fixes [#112502](https://github.com/rust-lang/rust/issues/112502)

changelog: [`from_over_into`]: fix invalid code suggestion when self
parameter has type annotation
2025-03-15 01:31:30 +00:00
KonaeAkira
9c897a20ae Simplify implementation 2025-03-15 00:37:44 +01:00
KonaeAkira
4a324c9dff Fix from_over_into lint suggesting invalid code 2025-03-15 00:05:32 +01:00
KonaeAkira
da910b14e2 Add failing from_over_into test case 2025-03-15 00:00:01 +01:00
Philipp Krones
f85331f4d1
Explain is_from_proc_macro and proc_macros auxiliary crate in the book (#14398)
This comes up every now and then in PRs, so I think it would be good if
we had an explanation in a central place that we can link to.

changelog: none
2025-03-13 14:23:13 +00:00
Alex Macleod
c07fd4824a
Update copyright year (#14399)
Update copyright year

changelog: none
2025-03-13 13:36:31 +00:00
Guillaume Gomez
0e4b6c8124 Make string_to_string emit a suggestion when cloned can be used 2025-03-13 11:46:02 +01:00
Catherine Flores
18061e2c42
incompatible_msrv: lint function calls with any argument count (#14216)
The lint for function calls was previously restricted to functions
taking exactly one argument. This was not documented.

Generalizing the lint to an arbitrary number of arguments in the
function call requires special casing some macro expansions from the
standard library. Macros such as `panic!()` or `assert_eq!()` exist
since Rust 1.0.0, but modern stdlib expand those macros into calls to
functions introduced in later Rust versions. While it is desirable to
lint code inside macros, using MSRV-incompatible functions coming from
`core` in macro expansions has been special-cased to not trigger this
lint.

Also, code coming from compiler desugaring may contain function calls
(for example, `a..=b` is now desugared into `RangeInclusive::new(a, b)`.
Those should not be linted either as the compiler is allowed to use
unstable function calls.

Fix #14212

changelog: [`incompatible_msrv`]: lint function calls with any argument
count
2025-03-13 04:11:42 +00:00
Alexey Semenyuk
559f23e1f2 Update copyright year 2025-03-13 02:01:16 +05:00
Guillaume Gomez
0ffc6cf097 Add ui test for string_to_string in map calls 2025-03-12 19:59:27 +01:00
Guillaume Gomez
21601fd042 Improve string_to_string lint in case it is in a map call 2025-03-12 19:59:27 +01:00
y21
44094e5148 explain is_from_proc_macro in the book 2025-03-12 18:25:25 +01:00
Philipp Krones
72540726b1
needless_pass_by_value: reference the innermost Option content (#14392)
If types such as `Option<Option<String>>` are not used by value, then
`Option<Option<&String>>` will be suggested, instead of
`Option<&Option<String>>`.

changelog: [`needless_pass_by_value`]: suggest using a reference on the
innermost `Option` content

fix #14375
2025-03-12 16:07:47 +00:00
Samuel Tardieu
417d4e6210 needless_pass_by_value: make verbose suggestion
This reduces the number of snippet manipulations, and shows the new
reference in context.
2025-03-12 13:50:04 +01:00
Philipp Krones
0730678e26
Make annotations mandatory for internal ui tests (#14393)
Last part of https://github.com/rust-lang/rust-clippy/pull/11421.

Now all ui tests require annotations.

The change in `ui_test` is to add `ICE:` errors.

changelog: Make internals ui tests annotations mandatory

r? @flip1995
2025-03-12 11:01:24 +00:00
Guillaume Gomez
092a20ec11 Update lint_message_convention test to allow clippy "help" message 2025-03-12 11:41:26 +01:00
Guillaume Gomez
ec8c0b3755 Make annotations mandatory for internal ui tests 2025-03-12 11:32:40 +01:00
Guillaume Gomez
e4d3b0a072 Update produce_ice so its error can be checked in ui tests 2025-03-12 11:32:27 +01:00
Guillaume Gomez
cfc743226e Update ui_test version to 0.29.2 2025-03-12 11:29:54 +01:00
Samuel Tardieu
35e6057e71 needless_pass_by_value: reference the innermost Option content
If types such as `Option<Option<String>>` are not used by value, then
`Option<Option<&String>>` will be suggested, instead of
`Option<&Option<String>>`.
2025-03-12 06:57:25 +01:00
Alex Macleod
714c64c7a1
fix: unnecessary_safety_comment FP on desugared assign (#14371)
Closes #13039

changelog: [`unnecessary_safety_comment`]: fix FP on desugared assign
2025-03-12 02:27:43 +00:00
Philipp Krones
8f280ff813
Add missing tests annotations for ui-internal (#14388)
Follow-up of https://github.com/rust-lang/rust-clippy/pull/11421.

I can't yet make the annotations mandatory because there is an issue
with `tests/ui-internal/custom_ice_message.rs`: the error message is not
emitted as JSON, meaning that we can't match it with `ui_test`. I need
to check if it's a bug in rustc or if `ui_test` needs to handle this
case somehow.

changelog: Add missing tests annotations for `ui-internal`

r? @flip1995
2025-03-11 16:10:14 +00:00
Guillaume Gomez
cb9682b628 Add missing tests annotations for ui-internal 2025-03-11 16:35:11 +01:00
Philipp Krones
a5bc316445
add macos-latest as a CI target (#14342)
r? flip1995

changelog: none
2025-03-11 13:35:56 +00:00
Philipp Krones
a25cbd50ca
Improve needless_pass_by_value suggestion (#13880)
Fixes https://github.com/rust-lang/rust-clippy/issues/13744.

A simple check to check if the type is an `Option` allows to improve the
suggestion.

changelog: Improve `needless_pass_by_value` suggestion
2025-03-10 15:48:43 +00:00
yanglsh
97275d523c fix: unnecessary_safety_comment FP on desugared assign 2025-03-10 12:36:37 +08:00
Timo
819f3c7c67
arbitrary_source_item_ordering: Make alphabetic ordering in module item groups optional (#13718)
From feedback to the `arbitrary_source_item_ordering` lint after its
inclusion in clippy 1.82, making alphabetic ordering within module item
groups has turned out to be the most requested improvement. With this
improvement, it is possible to make the lint perform certain top-level
structural checks on modules (e.g. use statements and module inclusions
at the top), but still leaving everything else up to the developer.

Implements parts of the suggestions from #13675. A catch-all-group is
still to be implemented.

changelog: [`arbitrary_source_item_ordering`]: Make alphabetic ordering
in module item groups optional (off by default)
2025-03-09 20:25:30 +00:00
Manish Goregaokar
3d775b3963
docs: Add documentation to json.rs module (#14383)
Add top-level documentation comments to improve code readability and
maintainability in the json.rs module.
- Add module-level documentation describing JSON serialization and diff
functionality
- Document LintJson struct
- Add function-level documentation to explain purpose and behavior
- Document missing constants and structs

changelog: none
2025-03-09 17:41:43 +00:00
Alex Macleod
7bae269e3a
fix broken theme CSS links in the website (#14379)
Currently, some parts of the
[website](https://rust-lang.github.io/rust-clippy/master/index.html)'s
CSS are not being applied. This seems to be due to a broken link to the
originally referenced CSS. I suspect
https://github.com/rust-lang/mdBook/pull/1368.

changelog: none
2025-03-09 14:33:57 +00:00
Turtel216
184feee826 Fix key function description 2025-03-09 16:29:07 +02:00
Turtel216
8dd65e4098 Add documentation to json.rs module 2025-03-09 16:03:12 +02:00
lapla-cogito
ab21f716fc
fix broken CSS links 2025-03-09 21:01:59 +09:00
Manish Goregaokar
1b628853fa
don't trigger blocks_in_conditions when the condition contains a return (#14338)
fixes #9911

changelog: [`blocks_in_conditions`]: don't trigger the lint when the
condition contains a `return`
2025-03-09 00:07:14 +00:00
Guillaume Gomez
c8e47f9a72 Update needless_pass_by_value stderr 2025-03-08 21:14:11 +01:00
Guillaume Gomez
79013f813d Improve needless_pass_by_value suggestion 2025-03-08 21:08:04 +01:00
lapla-cogito
243e0ee274
don't trigger blocks_in_conditions when the condition contains a return 2025-03-08 16:57:06 +09:00
dswij
f83c94cb3a
fix: manual_let_else missing binding mode (#14204)
fixes #13768

The existing implemention forgets to handle the binding mode (i.e. `ref`
and `ref mut`), so I just modified it to cover these cases.

changelog: [`manual_let_else`]: fix missing binding mode
2025-03-08 05:15:11 +00:00
dswij
19930f95f5
rename the MSRV alias MANUAL_DIV_CEIL to DIV_CEIL (#14329)
I renamed the MSRV alias `MANUAL_DIV_CEIL` to `DIV_CEIL` in #14263, as
MSRV aliases should represent their capability rather than the lint
name. However, it seems this change was mistakenly overwritten in
#14022.

changelog: none
2025-03-08 05:14:11 +00:00
Alejandra González
cee9abf10c
docs: update rationale for excessive-bools (#14351)
Adds the reasoning to the docs for this rule on why enums are generally
better for representing state machines than structs with many bool
fields.

changelog: [struct_excessive_bools]: Improve documentation
2025-03-06 18:54:55 +00:00
Tom
cc6127bce8 docs: update rationale for excessive-bools
Adds the reasoning to the docs for this rule on why enums are generally better for representing state machines than structs with  many bool fields.
2025-03-06 17:30:16 +00:00