Pierre-Andre Gagnon
a78271b861
Changed fn body suggestion msg
2021-02-18 17:32:55 -05:00
Dylan DPC
6e12a2f9e2
Rollup merge of #82215 - TaKO8Ki:replace-if-let-while-let, r=varkor
...
Replace if-let and while-let with `if let` and `while let`
This pull request replaces if-let and while-let with `if let` and `while let`.
closes https://github.com/rust-lang/rust/issues/82205
2021-02-18 16:57:37 +01:00
Vadim Petrochenkov
b185fa3ae2
ast: Keep expansion status for out-of-line module items
...
Also remove `ast::Mod` which is mostly redundant now
2021-02-18 13:07:49 +03:00
Yoshitomo Nakanishi
a87fa0e350
Fix FP of result_unit_err when using type aliases
2021-02-18 18:49:26 +09:00
bors
a149f61244
Auto merge of #81993 - flip1995:clippyup, r=Manishearth
...
Update Clippy
Biweekly Clippy update
r? `@Manishearth`
2021-02-17 22:37:42 +00:00
Pierre-Andre Gagnon
6165cccf7e
Added detailled suggs for new case
2021-02-17 16:41:50 -05:00
Cameron Steffen
9ad6e263c9
Fix match_same_arms with SpanlessEq changes
2021-02-17 10:47:26 -06:00
Cameron Steffen
742922a41a
Make expr_fallback FnMut
2021-02-17 10:47:26 -06:00
Cameron Steffen
4ac14f9e63
Teach SpanlessEq binding IDs
2021-02-17 10:47:26 -06:00
Takayuki Maeda
2d60a6113d
replace if-let and while-let with if let
and while let
2021-02-17 19:26:38 +09:00
bors
e2753f9a7b
Auto merge of #6662 - Y-Nak:default-numeric-fallback, r=flip1995
...
New lint: default_numeric_fallback
fixes #6064
r? `@flip1995`
As we discussed in [here](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20.236064/near/224647188 ) and [here](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20clippy.236064/near/224746333 ), I start implementing this lint from the strictest version.
In this PR, I'll allow the below two cases to pass the lint to reduce FPs.
1. Appearances of unsuffixed numeric literals in `Local` if `Local` has a type annotation, for example:
```rust
// Good.
let x: i32 = 1;
// Also good.
let x: (i32, i32) = if cond {
(1, 2)
} else {
(2, 3)
};
```
2. Appearances of unsuffixed numeric literals in args of `Call` or `MethodCall` if corresponding arguments of their signature have concrete types, for example:
```rust
fn foo_mono(x: i32) -> i32 {
x
}
fn foo_poly<T>(t: T) -> t {
t
}
// Good.
let x = foo_mono(13);
// Still bad.
let x: i32 = foo_poly(13);
```
changelog: Added restriction lint: `default_numeric_fallback`
2021-02-16 09:58:49 +00:00
Yoshitomo Nakanishi
9b0c1ebc18
Change to span_lint_and_sugg from span_lint_and_help
2021-02-16 18:07:09 +09:00
Yoshitomo Nakanishi
1f8ee3cc19
Handle struct ctor case
2021-02-16 11:20:51 +09:00
Camille GILLOT
dbe7609414
Only store a LocalDefId in hir::ImplItem.
2021-02-15 19:32:29 +01:00
Camille GILLOT
fc9bc33bba
Only store a LocalDefId in hir::TraitItem.
2021-02-15 19:32:28 +01:00
Camille GILLOT
2dc65397ee
Only store a LocalDefId in hir::Item.
...
Items are guaranteed to be HIR owner.
2021-02-15 19:32:10 +01:00
Camille GILLOT
5b68fc16ed
Use ItemId as a strongly typed index.
2021-02-15 19:24:58 +01:00
Yoshitomo Nakanishi
fb91c76586
Add more tests for default_numeric_fallback
2021-02-15 23:33:27 +09:00
Yoshitomo Nakanishi
0198ac7bdd
Add fn_sig_opt to get fn signature from HirId
2021-02-15 23:29:18 +09:00
Yoshitomo Nakanishi
93796b2346
Add some restrictions to default_numeric_fallback to avoid FNs
2021-02-15 14:43:37 +09:00
bors
2f19f5f0d7
Auto merge of #6741 - ThibsG:BlockInIfConditions1141, r=flip1995
...
Do not lint when the closure is called using an iterator
Fix FP when the closure is used in an iterator for `blocks_in_if_conditions` lint
FIxes : #1141
changelog: none
2021-02-14 15:55:12 +00:00
ThibsG
12025506d6
Do not lint when the closure is called using an iterator
2021-02-14 16:21:12 +01:00
bors
9c3b43efdd
Auto merge of #6701 - camsteffen:collapsible-if, r=flip1995
...
Fix collapsible_if with attributes
changelog: Fix collapsible_if FP with attributes
Fixes #6593
2021-02-14 14:43:35 +00:00
bors
eb80ac4e72
Auto merge of #6697 - camsteffen:vec-init-push-fp, r=flip1995
...
Fix vec_init_then_push false positives
changelog: Fix vec_init_then_push false positives
Fixes #6615
2021-02-14 14:27:13 +00:00
bors
ce0a47ab8c
Auto merge of #81238 - RalfJung:copy-intrinsics, r=m-ou-se
...
directly expose copy and copy_nonoverlapping intrinsics
This effectively un-does https://github.com/rust-lang/rust/pull/57997 . That should help with `ptr::read` codegen in debug builds (and any other of these low-level functions that bottoms out at `copy`/`copy_nonoverlapping`), where the wrapper function will not get inlined. See the discussion in https://github.com/rust-lang/rust/pull/80290 and https://github.com/rust-lang/rust/issues/81163 .
Cc `@bjorn3` `@therealprof`
2021-02-13 20:30:07 +00:00
Mara Bos
dd91987533
Fix clippy's path to the copy intrinsics.
2021-02-13 18:58:54 +01:00
boolean_coercion
d36fe85569
Made parens addition smarter and added tests with bless
2021-02-13 00:33:08 +02:00
bors
047f3e16bf
Auto merge of #6700 - daxpedda:panics-doc-unreachable, r=llogiq
...
Fix missing_panics_doc warning on `unreachable!`.
Fixes #6699 .
Are there any other test-cases I should cover?
changelog: [`missing_panics_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc ): No longer lints on [`unreachable!`](https://doc.rust-lang.org/std/macro.unreachable.html )
2021-02-12 20:48:05 +00:00
boolean_coercion
642efabfbb
Fixed typos and updated to matches! where applicable
2021-02-12 11:54:22 +02:00
boolean_coercion
9194c11d69
Fixed doctests that shouldn't have been compiled
2021-02-12 11:54:22 +02:00
boolean_coercion
d1a627ab3b
Ran bless and rustfmt
2021-02-12 11:54:22 +02:00
boolean_coercion
0b31b470ad
Changed applicability to MaybeIncorrect because of surrounding braces
2021-02-12 11:54:22 +02:00
boolean_coercion
a389c02461
from_str_radix_10 should be done
2021-02-12 11:54:22 +02:00
boolean_coercion
64729390a1
Implemented majority of from_str_radix_10
2021-02-12 11:54:22 +02:00
boolean_coercion
b80ac2af9c
Added boilerplate
2021-02-12 11:54:22 +02:00
bors
605e9ba3d7
Auto merge of #6179 - flip1995:rewrite_use_self, r=phansch
...
Rework use_self impl based on ty::Ty comparison #3410 | Take 2
This builds on top of #5531
I already reviewed and approved the commits by `@montrivo.` So only the review of my commits should be necessary.
I would also appreciate your review `@montrivo,` since you are familiar with the challenges here.
Fixes #3410 and Fixes #4143 (same problem)
Fixes #2843
Fixes #3859
Fixes #4734 and fixes #6221
Fixes #4305
Fixes #5078 (even at expression level now 🎉 )
Fixes #3881 and Fixes #4887 (same problem)
Fixes #3909
Not yet: #4140 (test added)
All the credit for the fixes goes to `@montrivo.` I only refactored and copy and pasted his code.
changelog: rewrite [`use_self`] lint and fix multiple (8) FPs. One to go.
2021-02-12 06:09:07 +00:00
flip1995
8b9f4a0d34
Merge commit '70c0f90453701e7d6d9b99aaa1fc6a765937b736' into clippyup
2021-02-11 15:04:38 +01:00
flip1995
00f9981f5c
Merge remote-tracking branch 'upstream/master' into rustup
2021-02-11 14:36:52 +01:00
bors
beb49bad26
Auto merge of #6650 - daxpedda:cargo-common-metadata-publish, r=flip1995
...
Fix cargo_common_metadata warning on `publish = false`.
I believe `cargo_common_metadata` shouldn't trigger when `publish = false`, not sure if everybody agrees.
Made some tests to handle all edge-cases.
Fixes #6649 .
changelog: [`cargo_common_metadata`](https://rust-lang.github.io/rust-clippy/master/index.html#cargo_common_metadata ): No longer lints if [`publish = false`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-publish-field ) is defined in the manifest
2021-02-11 09:34:44 +00:00
bors
3784cdf98e
Auto merge of #6657 - ThibsG:FromIterParens, r=llogiq
...
Fix suggestions that need parens in `from_iter_instead_of_collect` lint
Fixes broken suggestions that need parens (i.e.: range)
Fixes : #6648
changelog: none
2021-02-10 19:37:27 +00:00
alpaca-tc
94b8f23baf
Fix typo
2021-02-11 00:45:28 +09:00
bors
b5e4389f53
Auto merge of #6695 - TaKO8Ki:add-bytes-nth, r=phansch
...
New lint: `bytes_nth`
This pull request adds a new lint named `bytes_nth`.
---
closes: https://github.com/rust-lang/rust-clippy/issues/6391
changelog: Added a new lint: `bytes_nth`
2021-02-10 13:54:33 +00:00
Cameron Steffen
52f98d832d
Use TyS::same_type
2021-02-10 11:58:21 +01:00
Cameron Steffen
7f61ddd5b8
Move "types to lint" to the item stack
2021-02-10 11:58:20 +01:00
Cameron Steffen
7e1c1c1541
Fix qpath_res call
2021-02-10 11:58:20 +01:00
flip1995
da65d8166f
Don't trigger use_self in macros
2021-02-10 11:57:28 +01:00
flip1995
ae2dd671f5
Rewrite use_self lint one more time
...
This rewrite gets rid of complicated visitors, by using the lint infrastructure as much as possible
2021-02-10 11:57:28 +01:00
Tim Nielens
fc334fb8f4
use_self - fix issue with hir_ty_to_ty
2021-02-10 11:57:28 +01:00
Tim Nielens
347b01eb1f
rework use_self impl based on ty::Ty comparison
2021-02-10 11:57:27 +01:00
Takayuki Maeda
932cc085e6
Update clippy_lints/src/methods/bytes_nth.rs
...
Co-authored-by: Phil Hansch <dev@phansch.net>
2021-02-10 15:49:07 +09:00