Commit graph

22479 commits

Author SHA1 Message Date
Alex Macleod
8c045221b5 Make let_with_type_underscore help message into a suggestion 2025-05-07 15:19:40 +00:00
Alex Macleod
cf6bebb343
Remove some unused #![feature]s (#14738)
Mostly `let_chains` now that it's stable on 2024

changelog: none
2025-05-06 14:12:20 +00:00
Alex Macleod
737d3b3363 Remove some unused #![feature]s 2025-05-06 14:07:39 +00:00
Alex Macleod
94aa0d9a75 Update clippy_lints_internal to 2024 edition 2025-05-06 14:07:14 +00:00
Samuel Tardieu
7fdded3e37
Fix collapsible_if FP on block stmt before expr (#14730)
Closes rust-lang/rust-clippy#14722

changelog: [`collapsible_if`] fix FP on block stmt before expr
2025-05-06 06:33:10 +00:00
yanglsh
e7acf5c9b9 fix: collapsible_if FP on block stmt before expr 2025-05-06 14:25:21 +08:00
Samuel Tardieu
50e0bf1b71
Gate collapsible_if let_chains lints on edition 2024 and MSRV (#14723)
The MSRV being for crates targeting 1.85-1.87 on edition 2024

This enables the lint for regular nightly users without the feature gate
enabled

r? @samueltardieu

Fixes https://github.com/rust-lang/rust-clippy/issues/14678

changelog: none
2025-05-06 05:40:37 +00:00
Alex Macleod
8c93668a71 Gate collapsible_if let_chains lints on edition 2024 and MSRV 2025-05-06 02:23:28 +00:00
Jason Newcomb
c1586e141f
Replace str path utils with new PathLookup type (#14705)
The `&[&str]` path based `clippy_utils` have been removed and replace
with a new type `PathLookup`:

-
[`match_trait_method`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_trait_method.html)
-
[`match_qpath`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_qpath.html)
-
[`match_path`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_path.html)
-
[`match_any_def_paths`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_any_def_paths.html)
-
[`match_def_path`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_def_path.html)
-
[`match_type`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/ty/fn.match_type.html)
-
[`get_trait_def_id`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.get_trait_def_id.html)

Internally `PathLookup` is a lazy call to `lookup_path` (the new name
for
[`def_path_res`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.def_path_res.html)
to distinguish it from
[`path_res`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.path_res.html))

The `invalid_paths` internal lint is removed, it could be reimplemented
but it feels redundant since every path should be covered by a test
anyway

### User facing changes

- `manual_saturating_arithmetic` now checks for `u32::MAX/MIN` instead
of only detecting the legacy numeric consts (`std::u32::MAX/MIN`),
`clippy::legacy_numeric_constants` will redirect usages of the legacy
versions to the new one

- `allow-invalid = true` now suppresses all invalid path warnings,
currently you can run into a warning that can't be ignored in some
situations, e.g. with `serde` without the `derive` feature

  ```
  warning: expected a macro, found a trait
   --> /home/gh-Alexendoo/temp/clippy.toml:2:5
    |
  2 |     { path = "serde::Serialize", allow-invalid = true },
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ```

- Re-exports of primitives types like `std::primitive::*` no longer work
in `disallowed-types`, this seems acceptable since it would be unusual
to deny a primitive this way rather than writing e.g. `usize`. Type
aliases such as `c_char` are unaffected

- A similar slight performance improvement to
https://github.com/rust-lang/rust-clippy/pull/14650
  ```bash
$ hyperfine -w 2 -p 'touch src/cargo/lib.rs' 'cargo +master clippy'
'cargo +lazy-paths clippy'
  ```
  ```
  Benchmark 1: cargo +master clippy
Time (mean ± σ): 6.829 s ± 0.064 s [User: 6.079 s, System: 0.673 s]
    Range (min … max):    6.705 s …  6.907 s    10 runs

  Benchmark 2: cargo +lazy-paths clippy
Time (mean ± σ): 6.765 s ± 0.064 s [User: 5.984 s, System: 0.698 s]
    Range (min … max):    6.636 s …  6.834 s    10 runs

  Summary
    cargo +lazy-paths clippy ran
      1.01 ± 0.01 times faster than cargo +master clippy
  ```

changelog: none
2025-05-05 21:46:40 +00:00
Jason Newcomb
f62f269658
Fix manual_unwrap_or_default FP on ref binding (#14731)
Closes rust-lang/rust-clippy#14716

changelog: [`manual_unwrap_or_default`] fix FP on ref binding
2025-05-05 21:45:13 +00:00
Samuel Tardieu
003fc6ce1c
Remove myself from users on vacation (#14737)
r? ghost
changelog: none
2025-05-05 17:08:45 +00:00
Samuel Tardieu
9d5bb00d92 Remove myself from users on vacation 2025-05-05 19:03:03 +02:00
Philipp Krones
f60d7f9fc2
Read PR body from event in clippy_changelog action (#14736)
Simplifies the implementation a bit, also makes the message an error
annotation

changelog: none
2025-05-05 15:55:12 +00:00
Alex Macleod
e21b936770 Read PR body from event in clippy_changelog action 2025-05-05 15:30:56 +00:00
Alejandra González
689e62b3b2
fix: unused_async FP on default impl (#14720)
Closes rust-lang/rust-clippy#14704

changelog: [`unused_async`] fix FP on default impl
2025-05-05 00:43:30 +00:00
Alex Macleod
f23772ce8c Move lookup_path and similar into clippy_utils::paths 2025-05-04 17:13:02 +00:00
Alex Macleod
b768fbe4bc Replace str path utils with new PathLookup type 2025-05-04 15:26:37 +00:00
Alex Macleod
ea13461967
Don't warn about unloaded crates (#14733)
Fixes
https://github.com/rust-lang/rust-clippy/pull/14397#issuecomment-2848328221

r? @samueltardieu

changelog: Don't warn about clippy.toml disallowed paths for crates that
were not loaded
2025-05-04 13:44:16 +00:00
Samuel Moelius
7b7a9a6ece Don't warn about unloaded crates
Fixes https://github.com/rust-lang/rust-clippy/pull/14397#issuecomment-2848328221
2025-05-04 09:22:29 -04:00
yanglsh
7106e21227 fix: manual_unwrap_or_default FP on ref binding 2025-05-03 23:38:52 +08:00
Manish Goregaokar
56f018286b
fix: manual_slice_fill FP on IndexMut overload (#14719)
Closes rust-lang/rust-clippy#14685

changelog: [`manual_slice_fill`] fix FP on `IndexMut` overload
2025-05-02 17:07:07 +00:00
Jason Newcomb
fb9508d7a0
Fix new_lint clippy command (#14642)
I'm working on https://github.com/rust-lang/rust-clippy/issues/14542 and
I decided to name the lint `unnecessary_map` originally. However when I
ran the command, I got:

```
thread 'main' panicked at clippy_dev/src/new_lint.rs:450:5:
Lint `unnecessary_map` already defined in `/home/imperio/rust/clippy/clippy_lints/src/methods/mod.rs`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

It's because there is already a `unnecessary_map_or`, which matches the
`.contains()` call. This PR strengthens this check.

changelog: Fix `new_lint` clippy command

r? @flip1995
2025-05-02 15:47:40 +00:00
yanglsh
33ea0b482c fix: manual_slice_fill FP on IndexMut overload 2025-05-02 15:09:00 +08:00
dswij
a53acefef7
Remove is_normalizable (#14717)
Supersedes rust-lang/rust-clippy#12550

`layout_of` no longer contains a `delay_bug` so there's no need for this
anymore.

changelog: None
2025-05-01 16:45:14 +00:00
Philipp Krones
03a5b6b976
Rustup (#14721)
r? @ghost

changelog: none
2025-05-01 07:55:48 +00:00
Philipp Krones
8a91bbfa91
Bump nightly version -> 2025-05-01 2025-05-01 09:50:54 +02:00
Philipp Krones
43797675c2
Merge remote-tracking branch 'upstream/master' into rustup 2025-05-01 09:50:42 +02:00
yanglsh
782c6065c4 fix: unused_async FP on default impl 2025-05-01 14:50:23 +08:00
Jason Newcomb
36c3617bb1 Remove is_normalizable. layout_of no longer contains a delay_bug. 2025-04-30 19:31:24 -04:00
Trevor Gross
6d589103e9 Rollup merge of #139909 - oli-obk:or-patterns, r=BoxyUwU
implement or-patterns for pattern types

These are necessary to represent `NonZeroI32`, as the range for that is `..0 | 1..`. The `rustc_scalar_layout_range_*` attributes avoided this by just implementing wraparound and having a single `1..=-1` range effectively. See https://rust-lang.zulipchat.com/#narrow/channel/481660-t-lang.2Fpattern-types/topic/.60or.20pattern.60.20representation.20in.20type.20system/with/504217694 for some background discussion

cc https://github.com/rust-lang/rust/issues/123646

r? `@BoxyUwU`
2025-04-29 12:28:22 -04:00
The Miri Cronjob Bot
d1722043a5 Merge from rustc 2025-04-29 06:23:41 +00:00
Manish Goregaokar
549107dbad
Fix zombie_processes FP inside closures (#14696)
Closes rust-lang/rust-clippy#14677

changelog: [`zombie_processes`] fix FP inside closures
2025-04-28 15:41:40 +00:00
Guillaume Gomez
92ba06357c Rollup merge of #140249 - BoxyUwU:remove_weak_alias_terminology, r=oli-obk
Remove `weak` alias terminology

I find the "weak" alias terminology to be quite confusing. It implies the existence of "strong" aliases (which do not exist) and I'm not really sure what about weak aliases is "weak". I much prefer "free alias" as the term. I think it's much more obvious what it means as "free function" is a well defined term that already exists in rust.

It's also a little confusing given "weak alias" is already a term in linker/codegen spaces which are part of the compiler too. Though I'm not particularly worried about that as it's usually very obvious if you're talking about the type system or not lol. I'm also currently trying to write documentation about aliases and it's somewhat awkward/confusing to be talking about *weak* aliases, when I'm not really sure what the basis for that as the term actually *is*.

I would also be happy to just find out there's a nice meaning behind calling them "weak" aliases :-)

r? `@oli-obk`

maybe we want a types MCP to decide on a specific naming here? or maybe we think its just too late to go back on this naming decision ^^'
2025-04-28 13:30:45 +02:00
Oli Scherer
bca637ce5d Add or-patterns to pattern types 2025-04-28 07:50:18 +00:00
Jason Newcomb
542762e8af
fix: unused_unit suggests wrongly when unit never type fallback (#14609)
Closes rust-lang/rust-clippy#14577.

Migrate this lint to late pass and avoids `unit_never_type_fallback`
since it is no longer permitted in Rust 2024.

changelog: [`unused_unit`] fix wrong suggestions when unit never type
fallback
2025-04-27 19:14:47 +00:00
Timo
0dd9722cdc
Replace some Symbol::as_str usage (#14679)
Follow up to https://github.com/rust-lang/rust-clippy/pull/14650

Replaces uses in the form `s.as_str() == "literal"`

r? @y21

changelog: none
2025-04-27 12:56:14 +00:00
yanglsh
5123ad5904 Fix zombie_processes FP inside closures 2025-04-27 16:28:06 +08:00
yanglsh
5d8fb77872 fix: unused_unit suggests wrongly when unit never type fallback 2025-04-27 15:02:49 +08:00
dswij
39a408664b
manual_div_ceil: fix suggestions when macro is involved (#14666)
here is my small fix

changelog: fix suggestion span to avoid showing macro name in
`.div_ceil()` suggestion

i changed this line
`let divisor_snippet = snippet_with_applicability(cx,
rhs.spansource_callsite(), "..", applicability);`
to this line
`let divisor_snippet = snippet_with_applicability(cx, rhs.span, "..",
applicability);`
to fix problem where this warning in macro expands like this
```rust
4  |         let _ = (x + 7) / 8;
   |                 ^^^^^^^^^^^ help: consider using `.div_ceil()`: `x.div_ceil(y!())`
```
[play it
yourself](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=397aa8cd2ffffb24a286fbddbc75446c)

as you can see here it looks like `x.div_ceil(y!())` and contains macro
signature
so i fixed this problem, i will look closely if there any more problems
like this and fix them in order

**Related issue**

fixes
[rust-lang/rust-clippy#14665](https://github.com/rust-lang/rust-clippy/issues/14665)
2025-04-27 03:13:19 +00:00
dswij
58cfdb72a8
fix: equatable_if_let suggests wrongly when involving reference (#14504)
Closes #8710

changelog: [`equatable_if_let`] fix wrong suggestions when involving
reference
2025-04-26 14:52:32 +00:00
Jason Newcomb
ff307bac14
fix: unnecessary_cast suggests extra brackets when in macro (#14643)
Closes rust-lang/rust-clippy#14640

changelog: [`unnecessary_cast`] fix extra brackets in suggestions when
in macro
2025-04-26 11:55:15 +00:00
yanglsh
ad69347912 fix: equatable_if_let suggests wrongly when involving reference 2025-04-26 15:51:40 +08:00
yanglsh
3f72ffa80e fix: unnecessary_cast suggests extra brackets when in macro 2025-04-26 15:09:04 +08:00
yuk1ty
148c9a1981 Fix error message for static references or mutable references 2025-04-26 14:48:30 +09:00
The Miri Cronjob Bot
8a9153d19c Merge from rustc 2025-04-25 05:01:33 +00:00
Alex Macleod
7b337f6e25 Replace some Symbol::as_str usage 2025-04-25 01:03:03 +00:00
Timo
91ed6060bb
Consistently refer to the ? operator (#14687)
Matches the `rustc` terminology

changelog: none
2025-04-24 22:04:05 +00:00
Kivooeo
fc12b5b6d8 fix-issue-14665 2025-04-25 01:39:35 +05:00
Alex Macleod
736be8bbb1 Consistently refer to the ? operator 2025-04-24 13:40:57 +00:00
Boxy
6ee75c4a6e Remove weak alias terminology 2025-04-24 11:59:20 +01:00