Commit graph

1733 commits

Author SHA1 Message Date
Scott Gerring
8fe39b276f Change unnecessary_iter_cloned to use multipart_suggestion 2024-12-17 18:14:34 +01:00
Jason Newcomb
0f9cc8d58b
Don't trigger filter_map_identity with an iterator from an empty array (#13826)
fix #12653

changelog: [`filter_map_identity`]: don't lint for creating an iterator
from an empty array
2024-12-17 13:34:04 +00:00
lapla-cogito
1a23b5b517
correct suggestion for unnecessary_sort_by in no_std 2024-12-16 18:07:47 +09:00
Philipp Krones
12edfb82e5 Merge remote-tracking branch 'upstream/master' into rustup 2024-12-15 16:48:56 +01:00
Catherine Flores
62407104fb
allow needless_option_take to report for more cases (#13684)
changelog:
```
changelog: [`needless_option_take`]: now lints for all temporary expressions of type  Option<T>.
```

fixes #13671

In general, needless_option_take should report whenever take() is called
on a temporary value, not just when the temporary value is created by
as_ref().

Also, we stop emitting machine applicable fixes in these cases, since
sometimes the intention of the user is to actually clear the original
option, in cases such as `option.as_mut().take()`.
2024-12-14 19:50:55 +00:00
lapla-cogito
bd078ad1b5
don't lint for creating an iterator from an empty array in filter_map_identity lint 2024-12-14 22:49:49 +09:00
Michael Goulet
f3a8d4c715 Rename ty_def_id so people will stop using it by accident 2024-12-13 16:36:38 +00:00
Eric
b8cd51313e allow needless_option_take to report for more cases
In general, needless_option_take should report whenever
take() is called on a temporary value, not just when the
temporary value is created by as_ref()
2024-12-11 18:53:11 -08:00
lapla-cogito
d5059d8c1d
remove unnecessary notations 2024-12-10 00:00:51 +09:00
Scott Gerring
dcc4025405 chore: use multipart_suggestions for str_splitn 2024-12-06 16:04:21 +01:00
BD103
4907940a55 fix: various typos 2024-12-05 11:11:15 -05:00
Samuel Tardieu
ab5d55c996 Add more receivers to useless_conversion
- `ControlFlow::map_break()`
- `ControlFlow::map_continue()`
- `Iterator::map()`
2024-12-02 16:26:51 +01:00
lcnr
b330d9637a remove Ty::is_copy_modulo_regions 2024-12-02 13:57:56 +01:00
Samuel Tardieu
9a692ec8cd Add more cases to the useless_conversion lint
The new cases are `x.map(f)` and `x.map_err(f)` when `f` is `Into::into`
or `From::from` with the same input and output types.
2024-11-30 21:57:16 +01:00
Philipp Krones
d58b911e01 Merge commit 'ff4a26d442' into clippy-subtree-update 2024-11-28 19:38:59 +01:00
Philipp Krones
b24360aa87
Merge remote-tracking branch 'upstream/master' into rustup 2024-11-28 18:56:49 +01:00
Samuel Tardieu
6dcac6e2bf unnecessary_map_or: fix version for lint addition 2024-11-26 11:12:07 +01:00
Samuel Tardieu
425346a1bc Use a better message for unnecessary_map_or lint
Suggested by @smoelius.
2024-11-19 21:44:29 +01:00
lcnr
809b420e16 move fn is_item_raw to TypingEnv 2024-11-19 18:06:20 +01:00
lcnr
bb93c23c08 use TypingEnv when no infcx is available
the behavior of the type system not only depends on the current
assumptions, but also the currentnphase of the compiler. This is
mostly necessary as we need to decide whether and how to reveal
opaque types. We track this via the `TypingMode`.
2024-11-18 10:38:56 +01:00
Samuel Tardieu
de03a05bc8 unnecessary_map_or: lint .map_or(true, …) as well 2024-11-16 00:12:41 +01:00
Samuel Tardieu
ca963b653e Simplify instances of Option::map_or(true, …) in Clippy sources 2024-11-16 00:12:41 +01:00
Philipp Krones
5c1811ab94
Rename all clippy_config::msrvs -> clippy_utils::msrvs 2024-11-15 19:38:09 +01:00
Philipp Krones
1ceaa90413 Merge commit '786fbd6d68' into clippy-subtree-update 2024-11-14 19:35:26 +01:00
Jacherr
89210d7c5a new lint unnecessary_map_or 2024-11-12 23:00:26 +00:00
Philipp Krones
6ced8c33c0 Merge commit 'f712eb5cdc' into clippy-subtree-update 2024-11-07 22:37:01 +01:00
Philipp Krones
b816d4ee4f
Merge remote-tracking branch 'upstream/master' into rustup 2024-11-07 17:22:32 +01:00
bors
e8b78e2f66 Auto merge of #13630 - samueltardieu:push-qrnxuykslnsl, r=y21
Use match ergonomics compatible with editions 2021 and 2024

This PR contains the minimal changes needed to make Clippy match ergonomics work with both Rust 2021 and Rust 2024.

changelog: none
2024-11-01 20:23:33 +00:00
bors
9f89421036 Auto merge of #132301 - compiler-errors:adjust, r=lcnr
Remove region from adjustments

It's not necessary to store this region, because it's only used in THIR and MemCat/ExprUse, both of which already basically only deal with erased regions anyways.
2024-10-31 10:17:49 +00:00
Samuel Tardieu
0c1ef98454 Use match ergonomics compatible with editions 2021 and 2024 2024-10-30 11:22:17 +01:00
Robert Spencer
acc3842d43 Add new map_with_unused_argument_over_ranges lint
This lint checks for code that looks like
```rust
  let something : Vec<_> = (0..100).map(|_| {
    1 + 2 + 3
  }).collect();
```
which is more clear as
```rust
  let something : Vec<_> = std::iter::repeat_with(|| {
    1 + 2 + 3
  }).take(100).collect();
```
or
```rust
  let something : Vec<_> =
      std::iter::repeat_n(1 + 2 + 3, 100)
      .collect();
```

That is, a map over a range which does nothing with the parameter
passed to it is simply a function (or closure) being called `n`
times and could be more semantically expressed using `take`.
2024-10-29 21:32:00 +00:00
lcnr
8d190cc411 update tools 2024-10-29 17:01:24 +01:00
Samuel Tardieu
91a1d16a81 Add new lint: map_all_any_identity 2024-10-29 11:59:15 +01:00
Michael Goulet
353868aa64 Remove region from adjustments 2024-10-29 01:34:06 +00:00
Samuel Tardieu
62c4daf358 New lint needless_as_bytes 2024-10-28 09:19:17 +01:00
bors
73bad368f2 Auto merge of #13548 - wowinter13:unnecessary_filter_map_filter_map_some, r=llogiq
fix: remove unnecessary filter_map usages

fixes https://github.com/rust-lang/rust-clippy/issues/12556

(Fixed version of https://github.com/rust-lang/rust-clippy/pull/12766)

changelog: [unnecessary_filter_map]: filter map improvements
2024-10-27 22:27:49 +00:00
bors
6bcd0b9b42 Auto merge of #13558 - alex-semenyuk:const_is_empty_fix, r=dswij
Don't trigger `const_is_empty` for inline const assertions

Close #13106

Considered case was described [here](https://github.com/rust-lang/rust-clippy/pull/13114#issuecomment-2266629991)

changelog: [`const_is_empty`]: skip const_is_empty for inline const assertions
2024-10-24 13:55:52 +00:00
Michael Goulet
69b088626c Fix tests 2024-10-19 18:07:35 +00:00
bors
f2f0175eb2 Auto merge of #13543 - GnomedDev:symbol-comparisons, r=y21
Add internal lint to check for slow symbol comparisons

See the conversation on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Checking.20a.20Symbol.20is.20equal.20to.20a.20string.20literal).

changelog: none
2024-10-18 23:20:38 +00:00
Philipp Krones
91a458f451 Hotfix TRAIT_METHODS static->const 2024-10-18 14:54:06 +02:00
Philipp Krones
fea5e77da1 Merge commit 'a109190d70' into clippy-subtree-update 2024-10-18 13:44:06 +02:00
Alexey Semenyuk
8555922351 Don't trigger const_is_empty for inline const assertions 2024-10-17 22:36:26 +05:00
wowinter13
ad002ea99f fix: linter 2024-10-16 01:49:15 +02:00
wowinter13
40cb24f23c fix: simplify suggestion 2024-10-16 01:42:43 +02:00
Anastasis Georgoulas
48636259df Correct typo in lint description 2024-10-15 22:47:04 +01:00
wowinter13
11162d1b48 fix: remove unnecessary unfilter_map usages 2024-10-15 00:18:50 +02:00
GnomedDev
dedc380df9
Apply fixes from lint 2024-10-13 21:03:38 +01:00
bors
236751d093 Auto merge of #13540 - GnomedDev:create-dir-single-arg, r=y21
Check MethodCall/Call arg count earlier or at all

This gets rid of a bunch of possible panic spots, as well as bailing out earlier for optimisation reasons.

I started doing this because I saw that a significant amount of time was being spent in the `create_dir` restriction lint when running clippy with `perf`, but this also helps with robustness.

changelog: none
2024-10-13 13:34:48 +00:00
GnomedDev
ef1db3f502 Check MethodCall/Call arg count earlier or at all 2024-10-13 11:24:47 +01:00
Manish Goregaokar
42723dc9df Mark unnecessary_first_then_check and byte_char_slices as Applicable 2024-10-11 12:20:07 -07:00