Commit graph

22214 commits

Author SHA1 Message Date
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
Nicholas Nethercote
835e6a694b Move methods from Map to TyCtxt, part 2.
Continuing the work started in #136466.

Every method gains a `hir_` prefix, though for the ones that already
have a `par_` or `try_par_` prefix I added the `hir_` after that.
2025-02-18 10:17:44 +11:00
Michael Howell
6321ac79e1 needless_collect: look through assignments, not just declarations 2025-02-17 13:06:57 -07: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
Fridtjof Stoldt
822e45b186
"Typo Catch Check" passed by @flip1995
This was *totally* intentional to check if this would get caught :P

Co-authored-by: Philipp Krones <hello@philkrones.com>
2025-02-17 11:55: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
Matthias Krüger
42114c9633 Rollup merge of #137101 - GrigorenkoPV:str-inherent-lint, r=Urgau
`invalid_from_utf8[_unchecked]`: also lint inherent methods

Addressing https://github.com/rust-lang/rust/issues/131114#issuecomment-2646663535

Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
2025-02-17 06:37:38 +01:00
Nicholas Nethercote
91481e3bcf Overhaul the intravisit::Map trait.
First of all, note that `Map` has three different relevant meanings.
- The `intravisit::Map` trait.
- The `map::Map` struct.
- The `NestedFilter::Map` associated type.

The `intravisit::Map` trait is impl'd twice.
- For `!`, where the methods are all unreachable.
- For `map::Map`, which gets HIR stuff from the `TyCtxt`.

As part of getting rid of `map::Map`, this commit changes `impl
intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's
fairly straightforward except various things are renamed, because the
existing names would no longer have made sense.

- `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named
  because it gets some HIR stuff from a `TyCtxt`.
- `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`,
  because it's always `!` or `TyCtxt`.
- `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`.

I deliberately made the new trait and associated type names different to
avoid the old `type Map: Map` situation, which I found confusing. We now
have `type MaybeTyCtxt: HirTyCtxt`.
2025-02-17 13:21:35 +11:00
Nicholas Nethercote
8cf9eea5b3 Move some Map methods onto TyCtxt.
The end goal is to eliminate `Map` altogether.

I added a `hir_` prefix to all of them, that seemed simplest. The
exceptions are `module_items` which became `hir_module_free_items` because
there was already a `hir_module_items`, and `items` which became
`hir_free_items` for consistency with `hir_module_free_items`.
2025-02-17 13:21:02 +11: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
Pavel Grigorenko
f68f0b3e11 clippy: string_from_utf8_as_bytes: also detect inherent from_utf8 2025-02-16 16:34:51 +03:00
xFrednet
3e63720232
Changelog for Clippy 1.85 🦜 2025-02-16 13:40:11 +01:00
xFrednet
ef7e9fe704
Update version attribute for 1.85 clippy lints 2025-02-16 13:38:59 +01: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
lapla-cogito
91548d0fe3
prevent useless_asref from suggesting .clone() on types without the Clone trait 2025-02-16 05:59:53 +09:00
Samuel Tardieu
287a9421d3 comparison_chain: stylepedantic
The `comparison_chain` lint might suggest code which seems less natural
to beginners.

[Discussion](https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/demote.20some.20lints.20to.20.60pedantic.60)
2025-02-15 16:24:38 +01:00
Samuel Tardieu
01d7a324dc manual_strip: use existing identifier instead of placeholder
When the manually stripped entity receives a name as the first use
through a simple `let` statement, this name can be used in the generated
`if let Some(…)` expression instead of a placeholder.
2025-02-15 16:03:11 +01:00
Samuel Tardieu
44aa75fd2a manual_slice_fill: initializer must not reference the iterator
```rust
let mut tmp = vec![1, 2, 3];
for b in &mut tmp {
    *b = !*b;
}
```

must not suggest the invalid `tmp.fill(!*b)`.
2025-02-15 15:56:41 +01:00
Samuel Tardieu
510d3b69fc Use clippy_utils::is_mutable() in unnecessary_struct_initialization 2025-02-15 15:56:41 +01:00
Samuel Tardieu
35ad69c124 Cleanup: remove useless span_is_local() calls in manual_slice_fill
In both instances, `!assign_val.span.from_expansion()` – which is more
restrictive than `span_is_local(assign_val.span)` – has been required
already.
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