Commit graph

21833 commits

Author SHA1 Message Date
alexey semenyuk
e297c84703
Remove Known problems section for vec_box 2025-02-19 18:23:47 +05:00
Catherine Flores
d8ecde0e43
fix: map_entry FP on struct member (#14151)
fixes #13934

I modified the part for checking if the map is used so that it can check
field and index exprs.

changelog: [`map_entry`]: fix FP on struct member
2025-02-19 09:07:34 +00:00
Catherine Flores
975a813c5a
.last() to .next_back() requires a mutable receiver (#14140)
In the case where `iter` is a `DoubleEndedIterator`, replacing a call to
`iter.last()` (which consumes `iter`) by `iter.next_back()` (which
requires a mutable reference to `iter`) cannot be done when `iter` is a
non-mutable binding which is not a mutable reference. When possible, a
local immutable binding is made into a mutable one.

Also, the applicability is switched to `MaybeIncorrect` and a note is
added to the output when the element types have a significant drop,
because the drop order will potentially be modified because
`.next_back()` does not consume the iterator nor the elements before the
last one.

Fix #14139

changelog: [`double_ended_iterator_last`]: do not trigger on
non-reference immutable receiver, and warn about possible drop order
change
2025-02-19 09:05:46 +00:00
Philipp Krones
6872e94f11
update rustfix link in docs (#14248)
Since `rustfix` was moved to `@rust-lang/cargo`, the old link may be
confusing for readers.

changelog: none

r? flip1995
2025-02-19 09:02:00 +00:00
Samuel Tardieu
dcd643a652 double_ended_iterator_last: note when drop order is changed
`iter.last()` will drop all elements of `iter` in order, while
`iter.next_back()` will drop the non-last elements of `iter` when
`iter` goes out of scope since `.next_back()` does not consume its
argument.

When the transformation proposed by `double_ended_iterator_last` would
concern an iterator whose element type has a significant drop, a note is
added to warn about the possible drop order change, and the suggestion
is switched from `MachineApplicable` to `MaybeIncorrect`.
2025-02-19 09:26:39 +01:00
yanglsh
e2cdfed0ea fix: map_entry FP on struct member 2025-02-19 16:25:18 +08:00
Alejandra González
48fffe7db3
add a preferred fix for cast_possible_wrap description (#14225)
close #9250

changelog: none
2025-02-18 23:47:57 +00:00
lapla-cogito
939429a8b9
update rustfix link 2025-02-19 05:50:45 +09:00
Alejandra González
f49b4bc165
remove an unneeded #![feature] (#14245)
It seems as if `#![feature(binary_heap_into_iter_sorted)]` is not
required anymore.

changelog: none
2025-02-18 15:02:26 +00:00
Samuel Tardieu
45f7a60d31 .last() to .next_back() requires a mutable receiver
In the case where `iter` is a `DoubleEndedIterator`, replacing a call to
`iter.last()` (which consumes `iter`) by `iter.next_back()` (which
requires a mutable reference to `iter`) cannot be done when `iter`
Is not a mutable binding or a mutable reference.

When `iter` is a local binding, it can be made mutable by fixing its
definition site.
2025-02-18 13:51:01 +01:00
cyrgani
758ec1d332 remove an unneeded #![feature] 2025-02-18 11:04:53 +01:00
Alejandra González
e2d9b9a32a
fix: needless_option_as_deref FP in trait (#14210)
fixes #14148

Another case of #13077 and #8646

changelog: [`needless_option_as_deref`]: fix FP in trait
2025-02-17 23:33:46 +00:00
Manish Goregaokar
437014b951
Update mention of ref_to_mut to invalid_reference_casting (#14241)
This lint was renamed in 50da77521e.

While I'm here convert the list of separate lints into a proper list for
ease of use.

changelog: none
2025-02-17 18:11:42 +00:00
Manish Goregaokar
5e4d1660cd
manual_ok_err: blockify the replacement of an else if … (#14240)
If the part being replaced is an `if` expression following an `else`,
the replacement expression must be blockified.

Fix #14239

changelog: [`manual_ok_err`]: fix replacement expression if it follows
an `else`
2025-02-17 18:11:35 +00:00
Tamir Duberstein
01085cb16a
Update mention of ref_to_mut to invalid_reference_casting
This lint was renamed in 50da77521e.

While I'm here convert the list of separate lints into a proper list for
ease of use and clarify which lints are in clippy and which are in rustc.
2025-02-17 10:45:27 -05:00
Samuel Tardieu
66d19d84ae manual_ok_err: blockify the replacement of an else if …
If the part being replaced is an `if` expression following an `else`,
the replacement expression must be blockified.
2025-02-17 15:49:44 +01:00
Philipp Krones
735bed7aa5
Add cargo dev setup toolchain --standalone (#14230)
Allows creating a toolchain that's independent of the local build, for
example to make two separate toolchains with slight differences without
requiring two checkouts of clippy

changelog: none
2025-02-17 10:18:16 +00:00
Philipp Krones
1750411084
Add --allow-no-vcs to cargo dev dogfood --fix (#14227)
Some developers might prefer to use alternate VCS, such as Jujutsu,
which are not detected by `cargo fix`. This forwards the
`--allow-no-vcs` command line argument to `cargo fix`.

changelog: none
2025-02-17 10:13:25 +00:00
Alex Macleod
0f20a12ad4
ui_test annotation cleanup (#14232)
Cleans up some changes from
https://github.com/rust-lang/rust-clippy/pull/11421

I searched for any `.stderr` files where the number of errors changed
and reverted + manually added the annotations for them

Also fixes `tests/ui/asm_syntax_not_x86.rs`

r? @flip1995

changelog: none
2025-02-16 17:00:23 +00:00
Alex Macleod
d03ae8ba6b ui_test annotation cleanup 2025-02-16 16:51:35 +00:00
Alex Macleod
058ae80a55 Add cargo dev setup toolchain --standalone 2025-02-16 14:43:18 +00:00
Samuel Tardieu
6dd477ad5a Add --allow-no-vcs to cargo dev dogfood --fix
Some developers might prefer to use alternate VCS, such as Jujutsu, which
are not detected by `cargo fix`. This forwards the `--allow-no-vcs`
command line argument to `cargo fix`.
2025-02-16 13:06:03 +01:00
lapla-cogito
a12d5a0285
add suggestion example for cast_possible_wrap 2025-02-16 14:22:18 +09:00
Manish Goregaokar
8cef0b6809
new lint: manual_contains (#13817)
close #13353

Using `contains()` for slices are more efficient than using
`iter().any()`.

changelog: [`manual_contains`]: new lint
2025-02-15 21:37:05 +00:00
lapla-cogito
1c0e120d8b
apply manual_contains to Clippy sources 2025-02-16 06:22:03 +09:00
lapla-cogito
fd17bfe57d
add manual_contains lint 2025-02-16 06:21:57 +09:00
Samuel Tardieu
510d3b69fc Use clippy_utils::is_mutable() in unnecessary_struct_initialization 2025-02-15 15:56:41 +01:00
Samuel Tardieu
e0a62acc88 Add clippy_utils::is_mutable() 2025-02-15 15:56:41 +01:00
Philipp Krones
a8b17827c6
Make UI test annotations mandatory (#11421)
Follow-up of https://github.com/rust-lang/rust-clippy/pull/11249.

changelog: make UI tests annotations mandatory
2025-02-15 14:46:45 +00:00
Guillaume Gomez
847bd6707d f 2025-02-15 15:41:30 +01:00
Guillaume Gomez
2c0c661e56 Better handle 32bit/64bit-specific ui tests 2025-02-15 15:40:12 +01:00
Guillaume Gomez
8ae4e7f76d Fix tests/ui/transmute_32bit.rs annotations 2025-02-15 15:03:54 +01:00
Samuel Tardieu
0fcc2dba92 Fix 32 bits tests 2025-02-15 14:51:48 +01:00
Guillaume Gomez
211f79d84e Fix tests/ui-toml/absolute_paths/absolute_paths_2015.rs test 2025-02-15 14:05:59 +01:00
Guillaume Gomez
cc915cced8 Add missing ui annotations to new ui tests 2025-02-15 13:44:26 +01:00
Guillaume Gomez
a50953c1b9 Disable mandatory annotations for ui-internals tests for now until we find a solution for tests/ui-internal/custom_ice_message.rs 2025-02-15 13:38:43 +01:00
Guillaume Gomez
0841f6e9dc Don't make ui test annotations madatory for ui-cargo 2025-02-15 13:38:43 +01:00
Guillaume Gomez
3053bad40a Update ui-toml tests 2025-02-15 13:38:43 +01:00
Guillaume Gomez
a2c890fa0f Make fmt (weirdly) happy 2025-02-15 13:38:43 +01:00
Guillaume Gomez
1f94d55a18 Fix new tests updates 2025-02-15 13:38:42 +01:00
Guillaume Gomez
8a2dae63c3 Make if_let_mutex test pass on both 2021 and 2024 editions 2025-02-15 13:38:18 +01:00
Guillaume Gomez
d5ebe50505 Add manual annotations 2025-02-15 13:38:18 +01:00
Guillaume Gomez
0a990758fb Handle compilation error in builtin_type_shadow.rs 2025-02-15 13:38:18 +01:00
Guillaume Gomez
10184ecbe1 Allowed clippy::tests/ui/attrs.2.fixed in tests/ui/attr.rs because when adding annotations, it doesn't work anymore 2025-02-15 13:38:18 +01:00
Guillaume Gomez
f666fd6417 Update UI tests 2025-02-15 13:38:16 +01:00
Guillaume Gomez
95c6866dd4 Make UI tests annotations mandatory 2025-02-15 13:37:00 +01:00
Timo
379c8f4bfb
Clarify example for macro_use (#14220)
Clarify example for macro_use

changelog: none
2025-02-15 10:22:11 +00:00
alexey semenyuk
133882920b
Add example for macro_use 2025-02-15 14:47:18 +05:00
Jason Newcomb
0dd5c4ddeb
Fix used_underscore_items lint uses of foreign functions (#14205)
Fixed #14156

changelog: none
2025-02-15 02:46:49 +00:00
Jason Newcomb
4e899e16f9
unnecessary_map_or: do not consume the comparison value if it does not implement Copy (#14207)
Fix #14201

changelog: [`unnecessary_map_or`]: do not consume the comparison value
if it does not implement `Copy`
2025-02-15 02:45:59 +00:00