Commit graph

22008 commits

Author SHA1 Message Date
Guillaume Gomez
21601fd042 Improve string_to_string lint in case it is in a map call 2025-03-12 19:59:27 +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
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
Catherine Flores
81643e297c
unnecessary_to_owned: don't call iter() on a temporary object (#14243)
fix #14242

changelog: [`unnecessary_to_owned`]: don't call `iter` on a temporary
object
2025-03-05 23:17:32 +00:00
lapla-cogito
06f797d3f7
don't call iter() on a temporary object in unnecessary_to_owned 2025-03-06 07:55:01 +09:00
lapla-cogito
27e69a80f5
apply is_expr_temporary_value to Clippy source 2025-03-06 07:54:54 +09:00
lapla-cogito
2fda4f6bb8
add is_expr_temporary_value helper function 2025-03-06 07:54:48 +09:00
Catherine Flores
231bf457ba
Make struct_field_names check private fields of public structs. (#14076)
Currently, If a struct is `pub` and its field is private, and
`avoid-breaking-exported-api = true` (default), then
`struct_field_names` will not lint the field, even though changing the
field’s name is not a breaking change. This is because the
breaking-exported-api condition was checking the visibility of the
struct, not its fields (perhaps because the same code was used for
enums). With this change, Clippy will check the field’s effective
visibility only.

Note: This change is large because some functions were moved into an
`impl` to be able to access more configuration. Consider viewing the
diff with whitespace ignored.

changelog: [`struct_field_names`]: also check private fields of public
structs
2025-03-05 22:38:15 +00:00
Catherine Flores
06e75900f7
Refactor function after adding a new diagnostic item (#14306)
The `has_eligible_receiver()` function had been adapted *a minima* when
the `sym::ControlFlow` diagnostic item has been added to rustc. This
refactors the function content to make its meaning clearer.

changelog: none
2025-03-05 22:35:00 +00:00
Catherine Flores
ad633bedd6
Use size_of from the prelude instead of imported (#14355)
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.

These functions were added to all preludes in Rust 1.80.

changelog: none
2025-03-05 21:57:30 +00:00
Alex Macleod
8108bd8d43
Remove Known problems section for vec_box (#14252)
Remove Known problems section for `vec_box` since
[issue](https://github.com/rust-lang/rust-clippy/issues/3530#issuecomment-446058452)
> Vec<Box<T: Sized>> makes sense if T is a large type

can be handled

> The lint already checks that the type's size is lower than a threshold
to avoid linting on large types.

changelog: none
2025-03-05 13:41:31 +00:00
Thalia Archibald
e8cd3d4752 Use size_of from the prelude instead of imported
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the
prelude instead of importing or qualifying them.

These functions were added to all preludes in Rust 1.80.
2025-03-05 00:37:40 -08:00
llogiq
9538e5bcd0
Walk back to the root context to compute the span (#14349)
Since the error kind (`io::ErrorKind::other`) is in the root context,
the error message must be found in the root context as well to compute
the correct span to remove.

Fix #14346

changelog: [`io_error_other`]: fix non-applicable suggestion

r? @llogiq
2025-03-05 05:52:19 +00:00
Kevin Reid
8c73b76fb2 Move check_variant() code into a method of ItemNameRepetitions too. 2025-03-04 10:49:13 -08:00
Kevin Reid
2067375697 Make struct_field_names lint on private fields of public structs.
Currently, If a struct is `pub` and its field is private, and
`avoid-breaking-exported-api = true` (default), then `struct_field_names`
will not lint the field, even though changing the field’s name is not a
breaking change. This is because the breaking-exported-api condition was
checking the visibility of the struct, not its fields (perhaps because
the same code was used for enums). With this change, Clippy will check
 the field’s effective visibility only.

Note: This change is large because some functions were moved into an
`impl` to be able to access more configuration. Consider viewing the
diff with whitespace ignored.
2025-03-04 10:49:13 -08:00
Catherine Flores
2440f51696
don't trigger unnecessary_debug_formatting in tests (#14347)
close #14345

changelog: [`unnecessary_debug_formatting`]: don't lint in tests
2025-03-04 16:35:09 +00:00
Alex Macleod
dd8cf052c2
better help for mixed_case_hex_literals (#14235)
It can be error-prone for developers to manually change literals with
mixed uppercase and lowercase letters into consistently all-lowercase or
all-uppercase literals. Therefore, this lint rule should suggest
alternative literals.

changelog: [`mixed_case_hex_literals`]: add alternative suggestions
2025-03-04 14:10:44 +00:00
Samuel Tardieu
9275ae994b Walk back to the root context to compute the span
Since the error kind (`io::ErrorKind::other`) is in the root context,
the error message must be found in the root context as well to compute
the correct span to remove.
2025-03-04 12:00:38 +01:00
decryphe
5df68878bf Make alphabetic ordering in module item groups configurable (new default: off)
From feedback to this lint after its inclusion in clippy 1.82, this has
turned out to be the most requested improvement. With this improvement,
it is possible to make the lint check 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.
2025-03-04 09:50:47 +01:00
decryphe
9f0d819ced Create helper function to suggest a candidate in case of a typo 2025-03-04 09:50:47 +01:00
lapla-cogito
e6a4cf63ad
don't trigger unnecessary_debug_formatting in tests 2025-03-04 17:46:15 +09:00
lapla-cogito
e587a5d0f0
better help for mixed_case_hex_literals 2025-03-04 17:43:14 +09:00
Philipp Krones
cdc1d9d87a
Lint more cases with ptr_eq (#14339)
This PR:

- lints more case of raw pointer comparisons
- do not omit the named function to raw pointer conversion before
suggesting
- trigger the `ptr_eq` lint only if `cmp_null` doesn't trigger first, as
this is a more specialized version
- lints against `!=` in addition to `==`

The `ptr_eq` code has been moved from under `operators` to `ptr.rs`, in
order to benefit from factorization.

Fix #14337

changelog: [`ptr_eq`]: handle more cases
2025-03-04 08:15:00 +00:00
Philipp Krones
b4b7c7b057
Use the latest nightly rust to run linkcheck (#14348)
changelog: none
2025-03-04 07:55:17 +00:00
Samuel Tardieu
414136239b Use the latest nightly rust to run linkcheck 2025-03-04 08:50:26 +01:00
lapla-cogito
d63d56aeb0
add macos-latest as a CI target 2025-03-03 22:31:36 +09:00
yanglsh
68679f295f fix: manual_let_else missing binding mode 2025-03-03 13:02:44 +08:00