Commit graph

10723 commits

Author SHA1 Message Date
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
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
bors
f28c54cd08 Auto merge of #6744 - matthiaskrgr:lintcheck, r=flip1995
more lintcheck updates

* do some refactoring and renaming here and there
* add comments to functions
* fix bug where git repos would not get checked out to the proper commits (cmd was not actually run in repo directory 😅 )
* print warnings if we can't clone or check out a git repo
* filter out noise from cargo-metadata errors and lint messages that contained absolute file paths (these would change with every pinned-nightly bump, polluting the logs)

changelog: more lintcheck refactoring and fixes for git crates
2021-02-16 08:20:17 +00:00
Yoshitomo Nakanishi
1f8ee3cc19 Handle struct ctor case 2021-02-16 11:20:51 +09:00
Matthias Krüger
a95c250372 lintcheck: update logs 2021-02-15 23:38:51 +01:00
Matthias Krüger
028692b46a lintcheck: filter out messages that come from cargo-metadata errors or contain absolute paths to rustc source files
The latter is especially annoying because the paths would change every time we bumped the pinned nightly version.
2021-02-15 23:38:50 +01:00
Matthias Krüger
8f1cceb6ff lintcheck: print warnings if we can't check out or clone a git repo 2021-02-15 22:48:33 +01:00
Matthias Krüger
f8dbcae9f4 lintcheck: fix bug in downloade_and_extract() for git sources: we need to execute "git checkout xy" inside the repo dir! 2021-02-15 22:48:32 +01:00
Matthias Krüger
214d821268 lintcheck: put some code into a gather_stats() function 2021-02-15 22:13:17 +01:00
Matthias Krüger
4856e5f8fc lintcheck: rename a few symbols, add documentation to functions 2021-02-15 22:13:17 +01:00
Matthias Krüger
1b74439871 lintcheck: rename struct field 2021-02-15 22:13:17 +01:00
bors
87c682a06e Auto merge of #6743 - rust-lang:update-compiletest, r=Manishearth
Upgrade compiletest-rs to 0.6 and tester to 0.9

These updates allow us to specify multiple testnames for `TESTNAME` by
providing a comma separated list of testnames.

The new version of compiletest-rs also includes `bless` support, but is
not enabled with this PR.

cc #5394

changelog: none
2021-02-15 19:18:41 +00:00
Philipp Hansch
7226291025
Upgrade compiletest-rs to 0.6 and tester to 0.9
These updates allow us to specify multiple testnames for `TESTNAME`.

The new version of compiletest-rs also includes `bless` support, but is
not enabled with this PR.
2021-02-15 20:13:44 +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
5f611ceef7 Auto merge of #6736 - Y-Nak:reproducer-for-use_self-ice, r=flip1995
Add a minimal reproducer for the ICE in #6179

This PR is an auxiliary PR for #6179, just add a minimal reproducer for the ICE discussed in #6179.
See #6179 for more details.

changelog: none
2021-02-13 18:59:59 +00:00
Yoshitomo Nakanishi
87109bb4f5 Add minimal reproducer for ICE in #6179 2021-02-14 01:20:30 +09:00
bors
51aefbdd91 Auto merge of #6735 - matthiaskrgr:lintcheck, r=flip1995
lintcheck: accept env var to set crates.toml file

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: lintcheck: accept  LINTCHECK_TOML env var to set list of crates to be checked.
2021-02-13 16:03:07 +00:00
Philipp Krones
0256103c10
Use title case in clippy_dev README 2021-02-13 16:55:01 +01:00
bors
0ce5eccd66 Auto merge of #6738 - xFrednet:0000-update-labels-in-template-files, r=flip1995
Update labels in template files

It seems like we forgot to update the GitHub templates when we decided to update the label names. This PR just adjusts the templates to use the new label names :)

Context: [Zulip discussion about renaming the labels](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Label.20cleanup/near/224083870)

---

changelog: none
2021-02-13 15:51:14 +00:00
xFrednet
8c5d301e1b Updated labels in template files
For context: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Label.20cleanup/near/224083870
2021-02-13 16:45:34 +01:00
Matthias Krüger
fedfbb9011 lintcheck: explain sources.toml configuration 2021-02-13 01:28:00 +01:00
Matthias Krüger
5bbb1bc20a lintcheck: env var LINTCHECK_TOML can be used to override toml file location (has precedence over --crates-toml flag) 2021-02-13 00:39:19 +01: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
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
bors
fa2c1d63a2 Auto merge of #6719 - flip1995:changelog, r=xFrednet,flip1995
Update changelog for 1.51

~~Don't merge yet. This is the last step of the release process.~~ Release process for 1.50 is done, this can now be merged.

[Rendered](https://github.com/flip1995/rust-clippy/blob/changelog/CHANGELOG.md)

changelog: none
2021-02-11 16:06:07 +00:00
flip1995
cc82e559f6
Update changelog for 1.51 2021-02-11 16:49:44 +01:00
bors
8117573bc1 Auto merge of #6720 - flip1995:backport_remerge, r=flip1995
Backport remerge

changelog: none

r? `@ghost`
2021-02-11 15:10:42 +00:00
flip1995
feeed17bba
Merge remote-tracking branch 'upstream/beta' into backport_remerge 2021-02-11 16:09:12 +01:00
bors
70c0f90453 Auto merge of #6718 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2021-02-11 13:38:47 +00:00
flip1995
4efc4541d2
Bump nightly version -> 2021-02-11 2021-02-11 14:37:13 +01:00
flip1995
00f9981f5c
Merge remote-tracking branch 'upstream/master' into rustup 2021-02-11 14:36:52 +01:00
bors
8dbcffed44 Auto merge of #6708 - matthiaskrgr:lintcheck, r=flip1995
some more lintcheck changes

* Explain why tokei is commented out in the lintcheck sources.
* If we specify a custom sources.toml, don't override the preexisting lintcheck logs, but rather start a new log with the filename depending on the sources.toml name.
* Start adding a readme.md to clippy_dev and add some information on how to use the lintcheck subcommand.
* Add support for path/local sources (I needed this for the next item which is: )
* Collect ICEs that happen while clippy checks crates

changelog: more lintcheck changes
2021-02-11 09:46:42 +00:00
Matthias Krüger
a6d493d52a lintcheck: collect ICEs 2021-02-11 10:43:06 +01:00
Matthias Krüger
5e29aa6fdf lintcheck: add support for path sources 2021-02-11 10:43:04 +01:00
Matthias Krüger
cfe154be8c start a clippy-dev readme and some rough info on how to use lintcheck 2021-02-11 10:41:31 +01:00
Matthias Krüger
c7241b6e5e lintcheck: make the log file be ${source-file}-logs.txt
this allows us to check multiple source.tomls and not worry about overriding our logfiles accidentally
2021-02-11 10:41:31 +01:00
Matthias Krüger
1025cd349d lintcheck toml: explain why tokei is commented out 2021-02-11 10:41:31 +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
daxpedda
37f978299e
Add test for checking a combination of unreachable and panic. 2021-02-10 20:55:31 +01: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
bors
a6d6b1b2ee Auto merge of #6714 - alpaca-tc:fixed_tiny_typo, r=flip1995
Fix typo

changelog: none
2021-02-10 15:56:05 +00:00
alpaca-tc
94b8f23baf Fix typo 2021-02-11 00:45:28 +09:00