Commit graph

15728 commits

Author SHA1 Message Date
Samuel Tardieu
af39a8a4a8 Identify more cases of useless into_iter() calls
If the type of the result of a call to `IntoIterator::into_iter()`
and the type of the receiver are the same, then the receiver
implements `Iterator` and `into_iter()` is the identity function.

The call to `into_iter()` may be removed in all but two cases:

- If the receiver implements `Copy`, `into_iter()` will produce
  a copy of the receiver and cannot be removed. For example,
  `x.into_iter().next()` will not advance `x` while `x.next()` will.
- If the receiver is an immutable local variable and the call to
  `into_iter()` appears in a larger expression, removing the call to
  `into_iter()` might cause mutability issues. For example, if `x`
  is an immutable local variable, `x.into_iter().next()` will
  compile while `x.next()` will not as `next()` receives
  `&mut self`.
2022-12-17 16:20:43 +01:00
bors
38fce1235a Auto merge of #10022 - Jarcho:issue_10019, r=giraffate
Don't lint `implicit_clone` when the type doesn't implement clone

fixes #10019
changelog: `implicit_clone`: Don't lint when the type doesn't implement clone
2022-12-02 07:17:13 +00:00
bors
56d5657880 Auto merge of #9962 - mdgaziur:master, r=dswij
Fix #9958

This PR fixes #9958. In order to fix the issue, the lint will now peel reference operators and enclose the expression with parentheses when necessary.

changelog: [`comparison_to_empty`]: Peel deref operators in suggestions when necessary
2022-12-02 05:49:26 +00:00
bors
b43c9f7638 Auto merge of #9982 - Jarcho:issue_9935, r=flip1995
Don't lint `from_over_into` for opaque types

fixes #9935

This is stalled until the next sync. The impl in question can't be written on the pinned nightly.

changelog: Don't lint `from_over_into` for opaque types
2022-12-02 04:31:55 +00:00
Jason Newcomb
ab8c6beb85 Don't lint implicit_clone when the type doesn't implement clone 2022-12-01 23:05:53 -05:00
bors
fec00573a5 Auto merge of #10013 - Jarcho:issue_9886, r=Manishearth
Don't lint `manual_assert` in `else if`

fixes #9886
changelog: `manual_assert`: Don't lint in `else if`
2022-12-01 22:49:40 +00:00
Jason Newcomb
47fb67fa08 Don't lint manual_assert in else if 2022-12-01 17:37:18 -05:00
bors
e16a8b93ba Auto merge of #10008 - Jarcho:issue_9882, r=Manishearth
Treat custom enum discriminant values as constants

fixes #9882
changelog: All lints: Don't lint in enum discriminant values when the suggestion won't work in a const context
2022-12-01 22:37:15 +00:00
bors
be0eb20fff Auto merge of #10006 - Jarcho:issue_9890, r=Manishearth
Don't suggest removing `mut` from references in `redundant_static_lifetimes`

fixes #9890
changelog: `redundant_static_lifetimes`: Don't suggest removing `mut` from references
2022-12-01 22:25:38 +00:00
bors
53e1b45137 Auto merge of #9966 - alex-semenyuk:manual_let_else_paren, r=xFrednet
Fix manual_let_else produces a wrong suggestion with or-patterns

Fix #9938
changelog: Sugg: [`manual_let_else`]: Suggestions for or-patterns now include required brackets.
[#9966](https://github.com/rust-lang/rust-clippy/pull/9966)
2022-12-01 22:11:01 +00:00
bors
3b8a10cfab Auto merge of #10012 - Jarcho:issue_9885, r=Alexendoo
Don't lint `string_lit_as_bytes` in match scrutinees

fixes #9885
changelog: `string_lit_as_bytes`: Don't lint in match scrutinees
2022-12-01 20:26:46 +00:00
Jason Newcomb
a21b5b25f6 Don't lint string_lit_as_bytes in match scrutinees 2022-12-01 14:52:41 -05:00
alex-semenyuk
05477ff8df Fix manual_let_else produces a wrong suggestion with or-patterns 2022-12-01 22:05:06 +03:00
Jason Newcomb
6ecdff07e5 Don't lint from_over_into for opaque types 2022-12-01 11:51:31 -05:00
bors
d822110d3b Auto merge of #10010 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2022-12-01 13:21:51 +00:00
Philipp Krones
4063712bf4
Bump nightly version -> 2022-12-01 2022-12-01 12:55:29 +01:00
Philipp Krones
11434f270f
Merge remote-tracking branch 'upstream/master' into rustup 2022-12-01 12:55:15 +01:00
bors
641ced4eb9 Auto merge of #10007 - Jarcho:issue_10005, r=giraffate
Fix ICE in `result_large_err` with uninhabited enums

fixes #10005
changelog: `result_large_err`: Fix ICE with uninhabited enums
2022-12-01 07:20:06 +00:00
Jason Newcomb
a1b15f13f7 Treat custom enum discriminant values as constants 2022-11-30 22:34:42 -05:00
Jason Newcomb
7ae5c81e9f Fix ICE in result large_err with uninhabited enums 2022-11-30 21:44:18 -05:00
Jason Newcomb
55096eab0f Don't suggest removing mut from references in redundant_static_lifetimes 2022-11-30 21:29:48 -05:00
bors
ee12b12be5 Auto merge of #9943 - dswij:pr-9940, r=Jarcho
manual_let_else: keep macro call on suggestion blocks

Closes #9940

changelog: [`manual_let_else`]: Do not expand macro calls on suggestions
2022-11-30 21:23:10 +00:00
bors
1cdb06d406 Auto merge of #10001 - Jarcho:issue_9866, r=llogiq
Fix ICE in `unused_rounding`

fixes #9866
changelog: `unused_rounding`: Fix ICE when using the `_` separator
2022-11-30 19:54:25 +00:00
bors
846c9b8170 Auto merge of #9996 - Jarcho:issue_9906, r=Alexendoo
Fix `unnecessary_cast` suggestion when taking a reference

fixes #9906
changelog: `unnecessary_cast`: Fix suggestion when taking a reference
2022-11-30 19:40:22 +00:00
bors
d7d098a7e6 Auto merge of #9997 - Jarcho:issue_9901, r=llogiq
Don't lint `explicit_auto_deref` when the initial type is neither a reference, nor a receiver

fixes #9901
fixes #9777
changelog: `explicit_auto_deref`: Don't lint when the initial value is neither a reference, nor a receiver
2022-11-30 19:29:40 +00:00
Jason Newcomb
c1b8bc66e9 Fix ICE in unused_rounding 2022-11-30 12:46:06 -05:00
bors
87963f03ba Auto merge of #9987 - Jarcho:issue_9957, r=flip1995
Don't cross contexts while building the suggestion for `redundant_closure_call`

fixes #9957

changelog: `redundant_closure_call`: Don't cross macro contexts while building the suggestion
2022-11-30 16:31:56 +00:00
Jason Newcomb
2d32b40359 Don't lint explicit_auto_deref when the initial type is neither a reference, nor a receiver 2022-11-30 11:23:01 -05:00
Jason Newcomb
73f4546d24 Fix unnecessary_cast suggestion when taking a reference 2022-11-30 10:55:48 -05:00
Jason Newcomb
e0eba9cafc Don't cross contexts while building the suggestion for redundant_closure_call 2022-11-30 10:53:27 -05:00
mdgaziur
7a0f0c0e8b
Fix #9958 2022-11-30 19:42:50 +06:00
bors
78589ffad2 Auto merge of #9989 - xFrednet:9986-move-safety-thingy, r=flip1995
Move `unnecessary_unsafety_doc` to `pedantic`

This lint was added in #9822. I like the idea, but also agree with #9986 as well. I think it should at least not be warn-by-default. This is one of these cases, where I'd like a group between pedantic and restriction. But I believe that users using `#![warn(clippy::pedantic)]` will know how to enable the lint if they disagree with it.

---

Since the lint is new:

changelog: none

r? `@flip1995` since I'd suggest back porting this, the original PR was merged 16 days ago.

Closes: #9986 (While it doesn't address everything, I believe that this is the best compromise)
2022-11-30 12:44:45 +00:00
xFrednet
cc43c3d25d
Move unnecessary_unsafety_doc to pedantic 2022-11-30 12:59:50 +01:00
bors
58100c014a Auto merge of #104905 - compiler-errors:normalization-changes, r=spastorino
Some initial normalization method changes

1. Rename `AtExt::normalize` to `QueryNormalizeExt::query_normalize` (using the `QueryNormalizer`)
2. Introduce `NormalizeExt::normalize` to replace `partially_normalize_associated_types_in` (using the `AssocTypeNormalizer`)
3. Rename `FnCtxt::normalize_associated_types_in` to `FnCtxt::normalize`
4. Remove some unused other normalization fns in `Inherited` and `FnCtxt`

Also includes one drive-by where we're no longer creating a `FnCtxt` inside of `check_fn`, but passing it in. This means we don't need such weird `FnCtxt` construction logic.

Stacked on top of #104835 for convenience.

r? types
2022-11-30 11:13:09 +00:00
dswij
c502dee41e Use snippet_with_context instead of _with_macro_callsite 2022-11-30 14:50:13 +08:00
bors
3cf2c17e53 Auto merge of #9985 - ehuss:triagebot-autolabel, r=xFrednet
Add S-waiting-on-review autolabel.

This adds the S-waiting-on-review autolabel feature for new PRs.  This was previously handled by highfive, but I neglected to include it in #9963.

changelog: none
2022-11-29 13:30:15 +00:00
Eric Huss
8759f33bb3 Add S-waiting-on-review autolabel. 2022-11-29 05:18:43 -08:00
bors
bfb973f1c7 Auto merge of #9975 - xFrednet:0000-refutable-slice-pedantic, r=llogiq
Move `index_refutable_slice` to `pedantic`

During the creation, I out this lint into the nursery group to let it run in the wild before moving it to a commonly used group. This move never happened until now, though. It should be safe, as Clippy and I have been using it for months and there are no open issues for is :)

---

changelog: Move `index_refutable_slice` to `pedantic` (Now warn-by-default)
[#9975](https://github.com/rust-lang/rust-clippy/pull/9975)
2022-11-29 11:16:01 +00:00
bors
4cda21dc42 Auto merge of #9981 - Jarcho:issue_9954, r=flip1995
Don't lint `unnecessary_operation` in mixed macro contexts

fixes #9954

changelog: `unnecessary_operation`: Don't lint in mixed macro contexts.
2022-11-29 09:49:46 +00:00
bors
e9a8b8c2f3 Auto merge of #9980 - Jarcho:issue_9960, r=xFrednet
Don't lint `unnecessary_cast` in mixed macro context

fixes #9960

Time to start making a dent in this onslaught.

changelog: `unnecessary_cast`: Don't lint when the identifiers context differs from its binding's context for locals
2022-11-29 09:10:14 +00:00
Jason Newcomb
f44b7aa81e Don't lint unnecessary_cast in mixed macro context 2022-11-28 23:58:02 -05:00
Jason Newcomb
0893322e54 Don't lint unnecessary_operation in mixed macro contexts 2022-11-28 23:56:02 -05:00
xFrednet
6bbf16660b
Move index_refutable_slice to pedantic 2022-11-28 20:23:09 +01:00
Michael Goulet
a61e2a91f5 FnCtxt normalization stuff 2022-11-28 17:35:39 +00:00
Michael Goulet
82c07f09e5 partially_normalize_... -> At::normalize 2022-11-28 17:35:39 +00:00
bors
12074808c7 Auto merge of #9865 - nyurik:allow-mixed, r=xFrednet
Add allow-mixed-uninlined-format-args config

Implement `allow-mixed-uninlined-format-args` config param to change the behavior of the `uninlined_format_args` lint. Now it is a part of `style` per [Zulip chat](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.60uninlined_format_args.60.20category), and won't propose inlining in case of a mixed usage, e.g. `print!("{} {}", var, 1+2)`. If the user sets `allow-mixed-uninlined-format-args` config param to `false`, the lint would behave like it did before -- proposing to inline args even in the mixed case.

---

changelog: [`uninlined_format_args`]: Added a new config `allow-mixed-uninlined-format-args` to allow the lint, if only some arguments can be inlined
[#9865](https://github.com/rust-lang/rust-clippy/pull/9865)
changelog: Moved [`uninlined_format_args`] to `style` (Now warn-by-default)
[#9865](https://github.com/rust-lang/rust-clippy/pull/9865)
2022-11-28 17:22:36 +00:00
Matthias Krüger
0eaa0d3326 Rollup merge of #104804 - nnethercote:MetaItemLit, r=petrochenkov
Rename `ast::Lit` as `ast::MetaItemLit`.

And some other literal cleanups.

r? `@petrochenkov`
2022-11-28 17:25:46 +01:00
Esteban Küber
fc108d4b61 fix clippy tests 2022-11-28 00:41:31 -08:00
Nicholas Nethercote
5011c675ad Rename ast::Lit as ast::MetaItemLit. 2022-11-28 15:18:49 +11:00
bors
c8eba8e4a1 Auto merge of #9967 - koka831:fix/9416, r=llogiq
Remove blank lines when needless_return returns no value

fix https://github.com/rust-lang/rust-clippy/issues/9416

changelog: [`needless_return`] improve result format

r? `@llogiq`
2022-11-27 19:03:06 +00:00