Commit Graph

22310 Commits

Author SHA1 Message Date
Samuel Tardieu ec105bab2f fix: redundant_clone FP in overlapping lifetime (#14237)
fixes #13900

changelog: [`redundant_clone`]: fix FP in overlapping lifetime
2025-04-11 15:47:20 +00:00
yanglsh 07d8a9d331 fix: redundant_clone FP in overlapping lifetime 2025-04-11 23:42:26 +08:00
Alex Macleod ac4c69f423 implicit_return: better handling of asynchronous code (#14446)
Blocks created by desugaring will not contain an explicit `return`. Do
not suggest to add it when the user has no control over the desugared
code.

Also, ensure that in a `xxx.await` expression, the suggested `return` is
emitted before the whole expression, not before the `await` keyword.

Fix #14411

changelog: [`implicit_return`]: fix proposed `return` position in the
presence of asynchronous code
2025-04-11 13:39:03 +00:00
Alex Macleod fad1bfc568 Reinstate checking of tokio-rustls in lintcheck (#14591)
`cmake` has been pinned to version 3.31.6 in Ubuntu runner images.
Reference: https://github.com/actions/runner-images/pull/11933

changelog: none
2025-04-11 11:34:20 +00:00
Philipp Krones 7e60c1fafb Assign PR touching triagebot.toml to Philipp (#14590)
`triagebot.toml` is related to the repo behavior wrt interactions, and
must be kept inline with what is done in the CI.

changelog: none

r? @flip1995
2025-04-11 08:54:23 +00:00
Philipp Krones 8418338d26 Enable no mentions in commits of triagebot (#14576)
This PR enables the no-mentions in commits handler in triagebot.

Documentation pending at
https://github.com/rust-lang/rust-forge/pull/827

Original motivation in https://github.com/rust-lang/rust/issues/137990.

changelog: add `[no-mentions]` in `triagebot.toml`
2025-04-11 08:52:56 +00:00
Samuel Tardieu c67df0530a arbitrary_source_item_ordering should ignore test modules (#14585)
Close rust-lang/rust-clippy#14570

The test is provided
[here](https://github.com/rust-lang/rust-clippy/blob/master/tests/ui-toml/arbitrary_source_item_ordering/ordering_good_var_1.rs#L171)
but it's passed without `//@compile-flags: --test`

changelog: [`arbitrary_source_item_ordering`]: should ignore test
modules
2025-04-11 08:48:20 +00:00
Alexey Semenyuk e1bd4e4b6c arbitrary_source_item_ordering should ignore test modules 2025-04-11 13:42:21 +05:00
Samuel Tardieu 2c021ca19a Reinstate checking of tokio-rustls in lintcheck
`cmake` has been pinned to version 3.31.6 in Ubuntu runner images.
Reference: https://github.com/actions/runner-images/pull/11933
2025-04-11 10:41:36 +02:00
Samuel Tardieu fa5e855397 Assign PR touching triagebot.toml to Philipp
`triagebot.toml` is related to the repo behavior wrt interactions, and
must be kept inline with what is done in the CI.
2025-04-11 10:20:50 +02:00
Samuel Tardieu 0cd5b6261a Avoid some uses of empty identifiers (#14580)
This contributes towards
https://github.com/rust-lang/rust/issues/137978.

changelog: none
2025-04-11 06:59:38 +00:00
Samuel Tardieu 0286d46952 Fix a help message of empty_line_after_doc_comments for cases where the following item is nameless (#14584)
Fixes rust-lang/rust-clippy#14515.

changelog: [`empty_line_after_doc_comments`]: Fix a help message for
cases where the following item is nameless.
2025-04-10 18:12:45 +00:00
León Orell Valerian Liehr 15fd2ab73e Fix a help message of empty_line_after_doc_comments for cases where the following item is nameless 2025-04-10 18:24:45 +02:00
Nicholas Nethercote 3690f3b37f Avoid an Ident::empty usage.
By moving a couple of identifier checks earlier, we no longer need to
use an empty identifier for the `impl` case.

changelog: none
2025-04-10 16:49:18 +10:00
Nicholas Nethercote 822b931652 Avoid a kw::Empty usage.
`Option<Symbol>` is a much nicer and idiomatic way of representing "no
name" using empty symbols. And it works naturally for the item ordering
checking because `None < Some(_)` just like the empty string compares
less than all non-empty strings.

changelog: none
2025-04-10 16:46:46 +10:00
Samuel Tardieu 529bb5f253 Correctly handle bracketed type in default_constructed_unit_struct (#14367)
There were two bugs here. Let's assume `T` is a singleton type
implementing `Default` and that `f()` takes a `T`:

- `f(<T>::default())` cannot be replaced by `f(<T)` as it was (incorrect
spans – this is tricky because the type relative path uses a base span
covering only `T`, not `<T>`) (third commit)
- The argument of `f(<_>::default())` is inferred correctly, but cannot
be replaced by `<_>` or `_`, as this cannot be used to infer an instance
of a singleton type (first commit).

The second commit offers better error messages by pointing at the whole
expression.

Fix #12654

changelog: [`default_constructed_unit_struct`]: do not suggest incorrect
fix when using a type surrounded by brackets
2025-04-10 05:51:39 +00:00
Samuel Tardieu 0aa0d074cd Remove brackets around type name when it is no longer a prefix
When `<T>::default()` is replaced by `T` when `T` is a singleton,
the brackets around the type name can be removed.
2025-04-10 07:46:45 +02:00
Urgau 723f5b1761 Enable no mentions in commits of triagebot 2025-04-09 20:18:36 +02:00
Philipp Krones e0e2a93cf2 Enable GitHub review synchronization with S-waiting-on-* labels (#14567)
changelog: none

r? @flip1995
2025-04-09 15:31:57 +00:00
Manish Goregaokar 630ac0ca72 Accept self.cmp(other).into() as canonical PartialOrd impl (#14573)
`non_canonical_partial_ord_impl` will now recognize two forms of
canonical implementations: `Some(self.cmp(other))` and
`self.cmp(other).into()`.

changelog: [`non_canonical_partial_ord_impl`]: recognize
`self.cmp(other).into()` as a canonical implementation of
`PartialOrd::partial_cmp()`.

Fixes rust-lang/rust-clippy#13640
2025-04-09 15:23:17 +00:00
Alex Macleod 1cfc95c573 fix: map_entry: don't emit lint before checks have been performed (#14568)
Fixes rust-lang/rust-clippy#14449, introduced in #14314

changelog: [`map_entry`]: fix a false positive where the lint would
trigger without any insert calls present
2025-04-09 12:14:18 +00:00
Samuel Tardieu e463309f4a add manual_abs_diff lint (#14482)
changelog: [`manual_abs_diff`]: Initial implementation

Hey, first time writing a new lint for clippy, hope I got it right. I
think it's pretty self-explanatory!
Added a few `fixme` test cases, where the lint can be improved to catch
more (probably rare) patterns, but opening a PR with this initial
implementation to make sure I'm on the right track, and that this lint
is acceptable at all.

😁
2025-04-09 10:29:48 +00:00
Samuel Tardieu 0fe33171e4 Accept self.cmp(other).into() as canonical PartialOrd impl
`non_canonical_partial_ord_impl` will now recognize two forms of
canonical implementations: `Some(self.cmp(other))` and
`self.cmp(other).into()`.
2025-04-09 10:47:41 +02:00
Samuel Tardieu a7280e0374 Use explicit return instead of empty block to bail out from lint
No change in functionality.
2025-04-09 10:47:41 +02:00
Maja Kądziołka 189b0761c8 fix: map_entry: don't emit lint before checks have been performed
Fixes #14449, introduced in #14314
2025-04-09 04:36:14 +02:00
Samuel Tardieu eed88e4430 Enable GitHub review synchronization with S-waiting-on-* labels
Straight from triagebot's documentation, this should allow the bot to
set and remove the `S-waiting-on-author` and `S-waiting-on-review`
labels when a PR author requests a review, or when a review is done with
changes requested.
2025-04-09 00:20:32 +02:00
Alejandra González 97bb063958 Add doc for the clippy_lints::methods::derefs_to_slice() helper (#14564)
changelog: none
2025-04-08 15:32:11 +00:00
Samuel Tardieu 1a1ad5e54f fix: iter_cloned_collect FP with custom From/IntoIterator impl (#14473)
Closes #9119

changelog: [`iter_cloned_collect`]: fix FP with custom
`From`/`IntoIterator` impl
2025-04-08 13:46:46 +00:00
Alex Macleod 634c1c885f Ensure that peeling does not recurse into macros (#14527)
We do not want to remove casts done inside macros. Also, when printing
the suggestion, take it from the same context as the origin expression
(the root context).

Problems found while working on #14526, but should be merged even if
#14526 is not.

changelog: none
2025-04-08 12:52:36 +00:00
yanglsh ee36124011 fix: iter_cloned_collect FP with custom From/IntoIterator impl 2025-04-08 20:38:43 +08:00
Samuel Tardieu f5122ae4fd Add doc for the clippy_lints::methods::derefs_to_slice() helper 2025-04-08 09:56:45 +02:00
Alejandra González f74d7ce813 Enable canonicalization of issue links in triagebot (#14563)
This PR enables to the canonicalization of issue links in triagebot.

Documentation pending at
https://github.com/rust-lang/rust-forge/pull/825

changelog: add `[canonicalize-issue-links]` in `triagebot.toml`
2025-04-07 17:09:57 +00:00
Urgau 8b9165cc76 Enable canonicalization of issue links in triagebot.toml 2025-04-07 18:56:03 +02:00
Samuel Tardieu cf9cffa114 Fixes for missing_asserts_for_indexing (#14108)
This PR fixes issues with the `missing_asserts_for_indexing` lint.
- false positive when the first index is the highest(or equal) value in
a list of indexes:
```rust
pub fn foo(slice: &[i32]) -> i32{
	slice[1] * slice[0]
}
```
- false negative when an assert statement if found after the indexing
operation.
```rust
pub fn bar(slice: &[i32]) -> i32 {
	let product = slice[0] * slice[1];
	assert!(slice.len() > 1);
	product
}
```

examples: https://godbolt.org/z/s7Y47vKdE

closes: #14079

changelog: [`missing_asserts_for_indexing`]: ignore asserts found after
indexing, and do not require asserts if the first index is highest.
2025-04-06 10:42:29 +00:00
Timo a5a033d029 Update versions of 1.86 lints (#14540)
r? @y21

Completely forgot about the version update during CHANGELOG creation. I
have to re-learn how to do all that.

changelog: none
2025-04-03 20:49:26 +00:00
Philipp Krones a23e8d3537 Update versions of 1.86 lints 2025-04-03 22:20:33 +02:00
Philipp Krones 7bb54d91be Rustup (#14539)
r? @ghost

changelog: none
2025-04-03 20:12:28 +00:00
Timo a2251a8f1a Changelog for Clippy 1.86 🐧 (#14538)
Violets are red,
Roses are blue,
We miss our penguin,
This is hard to do.

---

Penguin of the release

![image](https://github.com/user-attachments/assets/4c8031fd-1ce7-4b78-af3e-4af26f07bcf1)

This is not a cat. But nominations are open in the comments for the next
release! 😻

---

changelog: none
2025-04-03 19:55:56 +00:00
Philipp Krones 944dfc749f Changelog for Clippy 1.86 2025-04-03 21:42:16 +02:00
Philipp Krones c97bd7463c Bump Clippy version -> 0.1.88 2025-04-03 21:32:37 +02:00
Philipp Krones c44191af48 Bump nightly version -> 2025-04-03 2025-04-03 21:31:56 +02:00
Philipp Krones ab7e525929 Merge remote-tracking branch 'upstream/master' into rustup 2025-04-03 21:31:02 +02:00
Philipp Krones 41d7e456c4 Update to new rinja version (askama) (#14530)
Askama maintenance was handed over to rinja maintainers so new `rinja`
release is actually `askama`. More information
[here](https://blog.guillaume-gomez.fr/articles/2025-03-19+Askama+and+Rinja+merge).

r? @flip1995

changelog: none
2025-04-03 17:52:59 +00:00
Guillaume Gomez 893a6a381e Update to new rinja version (askama) 2025-04-03 15:48:20 +02:00
Jason Newcomb 193e9f2c69 Don't use f16 and f128 directly in clippy_utils (#14528)
Not all host tools platforms support `f16`/`f128` builtins yet due to
LLVM assertion failures and miscompilations. Until them, Clippy should
avoid using `f16`/`f128` at runtime itself. See
https://github.com/rust-lang/rust/issues/137630.

cc @tgross35

changelog: none
2025-04-03 10:14:59 +00:00
Samuel Tardieu f9a1a1f487 Fix a typo in derive.rs comment (#14529)
changelog: none
2025-04-03 08:19:28 +00:00
Samuel Moelius 6f0f22cf28 Fix a typo in derive.rs comment
changelog: none
2025-04-03 04:14:23 -04:00
beetrees 416acd8cd9 Don't use f16 and f128 directly in clippy_utils 2025-04-03 02:00:27 +01:00
Samuel Tardieu db4bd96575 Ensure that peeling does not recurse into macros
We do not want to remove casts done inside macros. Also, when printing
the suggestion, take it from the same context as the origin expression
(the root context).
2025-04-03 01:38:53 +02:00
Yotam Ofek 52a3082056 add manual_abs_diff lint 2025-04-02 19:40:14 +00:00