Commit graph

22451 commits

Author SHA1 Message Date
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
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
bendn
6e64338a49 Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etc 2025-04-24 13:14:36 +07:00
Timo
34f81f96e9
style: pull one more if into the let-chain (#14669)
`cargo dev fmt` seems to not work for some reason (possibly because of
all the comments in the let-chain), so I formatted it manually -- I hope
it's right

changelog: none
2025-04-23 19:59:20 +00:00
Manish Goregaokar
dc695f53cd
Reword needless_question_mark diagnostics and docs (#14682)
Fixes https://github.com/rust-lang/rust-clippy/issues/14675 by making it
clearer that the constructor needs to be removed as well
Also fixes https://github.com/rust-lang/rust-clippy/issues/8392

changelog: none
2025-04-23 19:57:48 +00:00
Alex Macleod
7c5312bdab Reword needless_question_mark diagnostics and docs 2025-04-23 19:07:27 +00:00
Philipp Krones
dd5948ccc2 Clippy: Fix doc issue 2025-04-23 10:51:22 +02:00
Manish Goregaokar
aa27ae3fee
remove non-existent pathspec from pre-commit hook (#14671)
it was added back in 6035e050e8, at which
time there were some files matching it, e.g.

6035e050e8/clippy_lints/src/lib.deprecated.rs

fixes rust-lang/rust-clippy#14670

changelog: none
2025-04-22 22:53:31 +00:00
Ada Alakbarova
2304a9cb76
remove non-existent pathspec from pre-commit hook
it was added back in 6035e050e8, at which
time there were some files matching it, e.g.
6035e050e8/clippy_lints/src/lib.deprecated.rs
2025-04-23 00:47:43 +02:00
Ada Alakbarova
bf713a0e78
style: pull one more if into the let-chain 2025-04-22 23:51:42 +02:00
Philipp Krones
ff428d91c2 Merge commit '0621446356' into clippy-subtree-update 2025-04-22 18:24:43 +02:00
Alex Macleod
2422f0b9ac
Restrict the cases where ptr_eq triggers (#14526)
`ptr_eq` was recently enhanced to lint on more cases of raw pointers
comparison:

- lint on all raw pointer comparison, by proposing to use
`[core|std]::ptr::eq(lhs, rhs)` instead of `lhs == rhs`;
- removing one symetric `as usize` on each size if needed
- peeling any level of `as *[const|mut] _` if the remaining expression
can still be coerced into the original one (i.e., is a ref or raw
pointer to the same type as before)

The current change restricts the lint to the cases where at least one
level of symetric `as usize`, or any conversion to a raw pointer, could
be removed. For example, a direct comparaison of two raw pointers will
not trigger the lint anymore.

changelog: [`ptr_eq`]: do not lint when comparing two raw pointers
directly with no casts involved

Fixes rust-lang/rust-clippy#14525
2025-04-22 16:05:34 +00:00
Philipp Krones
0621446356
Rustup (#14667)
Out of cycle sync, as the sync to Rust failed again and resolving
conflicts there is awkward.

r? @ghost

changelog: none
2025-04-22 14:01:53 +00:00
Philipp Krones
bdc432759d
Bump nightly version -> 2025-04-22 2025-04-22 15:56:20 +02:00
Philipp Krones
ac477dbde5
Merge remote-tracking branch 'upstream/master' into rustup 2025-04-22 15:55:19 +02:00
Jason Newcomb
c3fb102a41
Consider side effects when rewriting iterator behaviors (#14490)
Closes #9191
Closes #14444
Closes #8055

Adds a new helper to partly check for side effects by recursively
checking if the iterator type contains closures with mutable captures.

changelog: [`double_ended_iterator_last`] fix FP when iter has side
effects
changelog: [`needless_collect`] fix lint not consider side effects
2025-04-22 13:21:54 +00:00
yanglsh
a50e043d32 Expand mutable capture check for is_iter_with_side_effects() 2025-04-22 20:55:07 +08:00
Jason Newcomb
aeb6ac9a0b
Fix question_mark suggesting when type is behind Deref include parentheses (#14655)
Close rust-lang/rust-clippy#14615

changelog: [`question_mark`]: when type is behind Deref include
parentheses
2025-04-22 01:58:56 +00:00
Alexey Semenyuk
7a4d523200 Fix question_mark suggesting when type is behind Deref include parentheses 2025-04-21 22:25:36 +05:00
Timo
083ea7e6c4
manual_ok_err: don't lint subpatterns (#14661)
Fixes https://github.com/rust-lang/rust-clippy/issues/14660

changelog: none
2025-04-21 14:47:02 +00:00
Timo
cc00c77607
Replace interning of string literals with preinterned symbols (#14650)
On
8ddf3676d1
it's a slight improvement

```
$ hyperfine -w 2 -r 100 -p 'touch src/cargo/lib.rs' 'cargo +master clippy' 'cargo +preintern clippy'
Benchmark 1: cargo +master clippy
  Time (mean ± σ):      6.908 s ±  0.063 s    [User: 6.134 s, System: 0.690 s]
  Range (min … max):    6.757 s …  7.045 s    100 runs

Benchmark 2: cargo +preintern clippy
  Time (mean ± σ):      6.815 s ±  0.065 s    [User: 6.039 s, System: 0.692 s]
  Range (min … max):    6.653 s …  6.968 s    100 runs

Summary
  cargo +preintern clippy ran
    1.01 ± 0.01 times faster than cargo +master clippy
```

Part 1 of removing `Symbol <-> str` conversions

changelog: none
2025-04-21 14:38:52 +00:00
dswij
f829f8cd5b
Make borrow_as_ptr flag implicit casts as well (#14408)
While I like replacing `&x` by `&raw const x` and `&mut x` by `&raw mut
x`, I'm less sure I like the suggested reborrows such as `&raw const
*p`. There was one in Clippy sources, see the PR diff.

@RalfJung, any opinion on this?

Fix #14406

changelog: [`borrow_as_ptr`]: lint implicit casts as well
2025-04-21 12:38:11 +00:00
Alejandra González
48430c2970
iter_kv_map: recognize references on maps as well (#14596)
Fix rust-lang/rust-clippy#14595

changelog: [`iter_kv_map`]: recognize references on maps as well
2025-04-21 01:44:34 +00:00
Alex Macleod
8843067aec manual_ok_err: don't lint subpatterns 2025-04-20 22:52:40 +00:00
Alex Macleod
077475f1a5
ptr_cast_constness: show snippet from the right context (#14622)
changelog: [`ptr_cast_constness`]: do not replace suggestion by content
of macro

Fixes rust-lang/rust-clippy#14621
2025-04-20 17:18:52 +00:00
yanglsh
c6d76bb69d fix: needless_collect does not consider side effects 2025-04-19 16:45:58 +08:00
yanglsh
86a10f01d1 fix: double_ended_iterator_last FP when iter has side effects 2025-04-19 16:45:58 +08:00
Alex Macleod
b52bd96713 Replace interning of string literals with preinterned symbols 2025-04-18 22:44:16 +00:00
Timo
781fdab9a9
Move internal lints to their own crate (#13223)
This makes it so switching the internal feature on/off no longer
rebuilds `clippy_lints`.

r? @flip1995

changelog: none
2025-04-18 12:04:08 +00:00