]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agolintheck: show output (and compiler errors!) when compiling clippy for lintcheck
Matthias Krüger [Fri, 19 Feb 2021 20:52:34 +0000 (21:52 +0100)]
lintheck: show output (and compiler errors!) when compiling clippy for lintcheck

3 years agolintcheck: tweak some comments
Matthias Krüger [Fri, 19 Feb 2021 20:48:52 +0000 (21:48 +0100)]
lintcheck: tweak some comments

3 years agolintcheck: parallelize
Matthias Krüger [Thu, 18 Feb 2021 18:09:12 +0000 (19:09 +0100)]
lintcheck: parallelize

Use rayon to figure out the threadcount and half that for core count.
For each core, create a target dir that is used.
Otherwise, when running multiple clippys with the same target-dir, cargo would lock the dir and prevent parallelism.
This way we can run multiple clippys at the same time (on root crates) but we sacrifice cache-hits (when we already cargo-checked crate-deps).

3 years agoAuto merge of #6763 - flip1995:fix_lintcheck, r=matthiaskrgr
bors [Thu, 18 Feb 2021 22:15:42 +0000 (22:15 +0000)]
Auto merge of #6763 - flip1995:fix_lintcheck, r=matthiaskrgr

Fix lintcheck by excluding checked crates from workspace

r? `@matthiaskrgr`  cc `@camsteffen`

So `exclude` doesn't work with glob patterns, but it turns out that it works with `starts_with`.

changelog: none

3 years agoFix lintcheck by excluding checked crates from workspace
flip1995 [Thu, 18 Feb 2021 22:07:19 +0000 (23:07 +0100)]
Fix lintcheck by excluding checked crates from workspace

3 years agoAuto merge of #6759 - Y-Nak:fix-fp-of-result_unit_err, r=llogiq
bors [Thu, 18 Feb 2021 21:39:29 +0000 (21:39 +0000)]
Auto merge of #6759 - Y-Nak:fix-fp-of-result_unit_err, r=llogiq

Fix FP of result_unit_err when using type aliases

fixes #6546

changelog: none

3 years agoFix FP of result_unit_err when using type aliases
Yoshitomo Nakanishi [Thu, 18 Feb 2021 09:35:25 +0000 (18:35 +0900)]
Fix FP of result_unit_err when using type aliases

3 years agoAuto merge of #6750 - flip1995:lintcheck_options, r=matthiaskrgr
bors [Wed, 17 Feb 2021 12:53:31 +0000 (12:53 +0000)]
Auto merge of #6750 - flip1995:lintcheck_options, r=matthiaskrgr

Lintcheck and an options for command line options

Make it possible to add command line options to the clippy invocation of the lintcheck-tool

changelog: none

r? `@matthiaskrgr`

I found that this will be really helpful if we use a separate repository and want to maintain a all-lints-passing list of crates. See my early experimentation here: https://github.com/flip1995/clippy-lintcheck

```
git submodule update --init
cargo run -- --mode=all
```

Will run the lintcheck tool on all the specified crates in `config/` in that repository.

3 years agolintcheck: Add a note that -Wclippy::all is enabled by default
flip1995 [Wed, 17 Feb 2021 07:34:23 +0000 (08:34 +0100)]
lintcheck: Add a note that -Wclippy::all is enabled by default

3 years agoReformat clippy_dev README
flip1995 [Tue, 16 Feb 2021 17:09:34 +0000 (18:09 +0100)]
Reformat clippy_dev README

3 years agoAuto merge of #6749 - camsteffen:test-all, r=Manishearth
bors [Tue, 16 Feb 2021 17:03:03 +0000 (17:03 +0000)]
Auto merge of #6749 - camsteffen:test-all, r=Manishearth

Test workspace at once

changelog: none

Follow-up to #6733

3 years agoTest workspace at once
Cameron Steffen [Tue, 16 Feb 2021 16:39:24 +0000 (10:39 -0600)]
Test workspace at once

3 years agoAdd workspace to manifest
Cameron Steffen [Fri, 12 Feb 2021 22:34:42 +0000 (16:34 -0600)]
Add workspace to manifest

3 years agolintcheck: Slight improvements to the error reporting
flip1995 [Tue, 16 Feb 2021 15:58:00 +0000 (16:58 +0100)]
lintcheck: Slight improvements to the error reporting

3 years agoAdd command line options option to lintcheck crates config
flip1995 [Tue, 16 Feb 2021 12:38:01 +0000 (13:38 +0100)]
Add command line options option to lintcheck crates config

3 years agoAuto merge of #6662 - Y-Nak:default-numeric-fallback, r=flip1995
bors [Tue, 16 Feb 2021 09:58:49 +0000 (09:58 +0000)]
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`

3 years agoChange to span_lint_and_sugg from span_lint_and_help
Yoshitomo Nakanishi [Tue, 16 Feb 2021 09:07:09 +0000 (18:07 +0900)]
Change to span_lint_and_sugg from span_lint_and_help

3 years agoAuto merge of #6744 - matthiaskrgr:lintcheck, r=flip1995
bors [Tue, 16 Feb 2021 08:20:17 +0000 (08:20 +0000)]
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 :sweat_smile: )
* 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

3 years agoHandle struct ctor case
Yoshitomo Nakanishi [Tue, 16 Feb 2021 02:20:51 +0000 (11:20 +0900)]
Handle struct ctor case

3 years agolintcheck: update logs
Matthias Krüger [Mon, 15 Feb 2021 22:25:06 +0000 (23:25 +0100)]
lintcheck: update logs

3 years agolintcheck: filter out messages that come from cargo-metadata errors or contain absolu...
Matthias Krüger [Mon, 15 Feb 2021 22:13:41 +0000 (23:13 +0100)]
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.

3 years agolintcheck: print warnings if we can't check out or clone a git repo
Matthias Krüger [Mon, 15 Feb 2021 21:46:58 +0000 (22:46 +0100)]
lintcheck: print warnings if we can't check out or clone a git repo

3 years agolintcheck: fix bug in downloade_and_extract() for git sources: we need to execute...
Matthias Krüger [Mon, 15 Feb 2021 21:36:49 +0000 (22:36 +0100)]
lintcheck: fix bug in downloade_and_extract() for git sources: we need to execute "git checkout xy" inside the repo dir!

3 years agolintcheck: put some code into a gather_stats() function
Matthias Krüger [Sun, 14 Feb 2021 17:59:32 +0000 (18:59 +0100)]
lintcheck: put some code into a gather_stats() function

3 years agolintcheck: rename a few symbols, add documentation to functions
Matthias Krüger [Sun, 14 Feb 2021 17:51:53 +0000 (18:51 +0100)]
lintcheck: rename a few symbols, add documentation to functions

3 years agolintcheck: rename struct field
Matthias Krüger [Sun, 14 Feb 2021 17:37:08 +0000 (18:37 +0100)]
lintcheck: rename struct field

3 years agoAuto merge of #6743 - rust-lang:update-compiletest, r=Manishearth
bors [Mon, 15 Feb 2021 19:18:41 +0000 (19:18 +0000)]
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

3 years agoUpgrade compiletest-rs to 0.6 and tester to 0.9
Philipp Hansch [Mon, 15 Feb 2021 06:36:25 +0000 (07:36 +0100)]
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.

3 years agoAdd more tests for default_numeric_fallback
Yoshitomo Nakanishi [Mon, 15 Feb 2021 14:33:27 +0000 (23:33 +0900)]
Add more tests for default_numeric_fallback

3 years agoAdd fn_sig_opt to get fn signature from HirId
Yoshitomo Nakanishi [Mon, 15 Feb 2021 13:40:28 +0000 (22:40 +0900)]
Add fn_sig_opt to get fn signature from HirId

3 years agoAdd some restrictions to default_numeric_fallback to avoid FNs
Yoshitomo Nakanishi [Mon, 15 Feb 2021 05:22:31 +0000 (14:22 +0900)]
Add some restrictions to default_numeric_fallback to avoid FNs

3 years agoAuto merge of #6741 - ThibsG:BlockInIfConditions1141, r=flip1995
bors [Sun, 14 Feb 2021 15:55:12 +0000 (15:55 +0000)]
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

3 years agoDo not lint when the closure is called using an iterator
ThibsG [Sun, 14 Feb 2021 15:21:12 +0000 (16:21 +0100)]
Do not lint when the closure is called using an iterator

3 years agoAuto merge of #6701 - camsteffen:collapsible-if, r=flip1995
bors [Sun, 14 Feb 2021 14:43:35 +0000 (14:43 +0000)]
Auto merge of #6701 - camsteffen:collapsible-if, r=flip1995

Fix collapsible_if with attributes

changelog: Fix collapsible_if FP with attributes

Fixes #6593

3 years agoAuto merge of #6697 - camsteffen:vec-init-push-fp, r=flip1995
bors [Sun, 14 Feb 2021 14:27:13 +0000 (14:27 +0000)]
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

3 years agoAuto merge of #6736 - Y-Nak:reproducer-for-use_self-ice, r=flip1995
bors [Sat, 13 Feb 2021 18:59:59 +0000 (18:59 +0000)]
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

3 years agoAdd minimal reproducer for ICE in #6179
Yoshitomo Nakanishi [Sat, 13 Feb 2021 13:12:59 +0000 (22:12 +0900)]
Add minimal reproducer for ICE in #6179

3 years agoAuto merge of #6735 - matthiaskrgr:lintcheck, r=flip1995
bors [Sat, 13 Feb 2021 16:03:07 +0000 (16:03 +0000)]
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.

3 years agoUse title case in clippy_dev README
Philipp Krones [Sat, 13 Feb 2021 15:55:01 +0000 (16:55 +0100)]
Use title case in clippy_dev README

3 years agoAuto merge of #6738 - xFrednet:0000-update-labels-in-template-files, r=flip1995
bors [Sat, 13 Feb 2021 15:51:14 +0000 (15:51 +0000)]
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

3 years agoUpdated labels in template files
xFrednet [Sat, 13 Feb 2021 15:45:34 +0000 (16:45 +0100)]
Updated labels in template files

For context: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Label.20cleanup/near/224083870

3 years agolintcheck: explain sources.toml configuration
Matthias Krüger [Fri, 12 Feb 2021 23:50:13 +0000 (00:50 +0100)]
lintcheck: explain sources.toml configuration

3 years agolintcheck: env var LINTCHECK_TOML can be used to override toml file location (has...
Matthias Krüger [Fri, 12 Feb 2021 23:39:19 +0000 (00:39 +0100)]
lintcheck: env var LINTCHECK_TOML can be used to override toml file location (has precedence over --crates-toml flag)

3 years agoAuto merge of #6700 - daxpedda:panics-doc-unreachable, r=llogiq
bors [Fri, 12 Feb 2021 20:48:05 +0000 (20:48 +0000)]
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)

3 years agoAuto merge of #6179 - flip1995:rewrite_use_self, r=phansch
bors [Fri, 12 Feb 2021 06:09:07 +0000 (06:09 +0000)]
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.

3 years agoAuto merge of #6719 - flip1995:changelog, r=xFrednet,flip1995
bors [Thu, 11 Feb 2021 16:06:07 +0000 (16:06 +0000)]
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

3 years agoUpdate changelog for 1.51
flip1995 [Thu, 11 Feb 2021 14:59:38 +0000 (15:59 +0100)]
Update changelog for 1.51

3 years agoAuto merge of #6720 - flip1995:backport_remerge, r=flip1995
bors [Thu, 11 Feb 2021 15:10:42 +0000 (15:10 +0000)]
Auto merge of #6720 - flip1995:backport_remerge, r=flip1995

Backport remerge

changelog: none

r? `@ghost`

3 years agoMerge remote-tracking branch 'upstream/beta' into backport_remerge
flip1995 [Thu, 11 Feb 2021 15:09:12 +0000 (16:09 +0100)]
Merge remote-tracking branch 'upstream/beta' into backport_remerge

3 years agoAuto merge of #6718 - flip1995:rustup, r=flip1995
bors [Thu, 11 Feb 2021 13:38:47 +0000 (13:38 +0000)]
Auto merge of #6718 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoBump nightly version -> 2021-02-11
flip1995 [Thu, 11 Feb 2021 13:37:13 +0000 (14:37 +0100)]
Bump nightly version -> 2021-02-11

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 11 Feb 2021 13:36:52 +0000 (14:36 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoAuto merge of #6708 - matthiaskrgr:lintcheck, r=flip1995
bors [Thu, 11 Feb 2021 09:46:42 +0000 (09:46 +0000)]
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

3 years agolintcheck: collect ICEs
Matthias Krüger [Wed, 10 Feb 2021 11:50:36 +0000 (12:50 +0100)]
lintcheck: collect ICEs

3 years agolintcheck: add support for path sources
Matthias Krüger [Wed, 10 Feb 2021 10:32:10 +0000 (11:32 +0100)]
lintcheck: add support for path sources

3 years agostart a clippy-dev readme and some rough info on how to use lintcheck
Matthias Krüger [Tue, 9 Feb 2021 15:58:39 +0000 (16:58 +0100)]
start a clippy-dev readme and some rough info on how to use lintcheck

3 years agolintcheck: make the log file be ${source-file}-logs.txt
Matthias Krüger [Tue, 9 Feb 2021 15:27:56 +0000 (16:27 +0100)]
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

3 years agolintcheck toml: explain why tokei is commented out
Matthias Krüger [Tue, 9 Feb 2021 15:10:07 +0000 (16:10 +0100)]
lintcheck toml: explain why tokei is commented out

3 years agoAuto merge of #6650 - daxpedda:cargo-common-metadata-publish, r=flip1995
bors [Thu, 11 Feb 2021 09:34:44 +0000 (09:34 +0000)]
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

3 years agoAdd test for checking a combination of unreachable and panic.
daxpedda [Wed, 10 Feb 2021 19:55:31 +0000 (20:55 +0100)]
Add test for checking a combination of unreachable and panic.

3 years agoAuto merge of #6657 - ThibsG:FromIterParens, r=llogiq
bors [Wed, 10 Feb 2021 19:37:27 +0000 (19:37 +0000)]
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

3 years agoAuto merge of #6714 - alpaca-tc:fixed_tiny_typo, r=flip1995
bors [Wed, 10 Feb 2021 15:56:05 +0000 (15:56 +0000)]
Auto merge of #6714 - alpaca-tc:fixed_tiny_typo, r=flip1995

Fix typo

changelog: none

3 years agoFix typo
alpaca-tc [Wed, 10 Feb 2021 15:45:28 +0000 (00:45 +0900)]
Fix typo

3 years agoAuto merge of #6695 - TaKO8Ki:add-bytes-nth, r=phansch
bors [Wed, 10 Feb 2021 13:54:33 +0000 (13:54 +0000)]
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`

3 years agoAuto merge of #6687 - ehuss:stabilize-wrapper, r=flip1995
bors [Wed, 10 Feb 2021 13:27:53 +0000 (13:27 +0000)]
Auto merge of #6687 - ehuss:stabilize-wrapper, r=flip1995

Stabilize workspace wrapper.

This fixes it so that `cargo clippy` doesn't share the same cache artifacts as `cargo check`. The Cargo side was stabilized a while ago (https://github.com/rust-lang/cargo/pull/8976), so this should be ready to go. I'm not aware of any blockers or concerns.

Closes #4612

---

changelog: `cargo clippy` no longer shares the same build cache as `cargo check`.

3 years agoUse TyS::same_type
Cameron Steffen [Wed, 10 Feb 2021 01:42:32 +0000 (19:42 -0600)]
Use TyS::same_type

3 years agoMove "types to lint" to the item stack
Cameron Steffen [Wed, 10 Feb 2021 01:39:38 +0000 (19:39 -0600)]
Move "types to lint" to the item stack

3 years agoFix qpath_res call
Cameron Steffen [Wed, 10 Feb 2021 01:38:40 +0000 (19:38 -0600)]
Fix qpath_res call

3 years agoDon't trigger use_self in macros
flip1995 [Sun, 17 Jan 2021 18:09:24 +0000 (19:09 +0100)]
Don't trigger use_self in macros

3 years agoUpdate test files
flip1995 [Fri, 16 Oct 2020 11:26:02 +0000 (13:26 +0200)]
Update test files

3 years agoRewrite use_self lint one more time
flip1995 [Fri, 16 Oct 2020 11:25:38 +0000 (13:25 +0200)]
Rewrite use_self lint one more time

This rewrite gets rid of complicated visitors, by using the lint infrastructure as much as possible

3 years agouse_self - fix issue with `hir_ty_to_ty`
Tim Nielens [Fri, 9 Oct 2020 22:26:12 +0000 (00:26 +0200)]
use_self - fix issue with `hir_ty_to_ty`

3 years agorework use_self impl based on ty::Ty comparison
Tim Nielens [Sun, 26 Apr 2020 00:48:02 +0000 (02:48 +0200)]
rework use_self impl based on ty::Ty comparison

3 years agoadd some test cases
Takayuki Maeda [Wed, 10 Feb 2021 07:15:29 +0000 (16:15 +0900)]
add some test cases

3 years agoUpdate clippy_lints/src/methods/bytes_nth.rs
Takayuki Maeda [Wed, 10 Feb 2021 06:49:07 +0000 (15:49 +0900)]
Update clippy_lints/src/methods/bytes_nth.rs

Co-authored-by: Phil Hansch <dev@phansch.net>
3 years agoAuto merge of #6698 - camsteffen:path-to-local, r=phansch
bors [Wed, 10 Feb 2021 06:17:37 +0000 (06:17 +0000)]
Auto merge of #6698 - camsteffen:path-to-local, r=phansch

More path-to-local fixes

changelog: Fix some detections of variable usage in closures

3 years agoAuto merge of #6709 - rust-lang:flip1995-patch-1, r=matthiaskrgr
bors [Tue, 9 Feb 2021 16:50:35 +0000 (16:50 +0000)]
Auto merge of #6709 - rust-lang:flip1995-patch-1, r=matthiaskrgr

Remove rustfmt from rust-toolchain file

We use latest nightly rustfmt in our tests anyway

r? `@matthiaskrgr`

changelog: none

3 years agoRemove rustfmt from rust-toolchain file
Philipp Krones [Tue, 9 Feb 2021 16:44:36 +0000 (17:44 +0100)]
Remove rustfmt from rust-toolchain file

We use latest nightly rustfmt in our tests anyway

3 years agoAdd better turbofish extractor
ThibsG [Tue, 9 Feb 2021 16:38:16 +0000 (17:38 +0100)]
Add better turbofish extractor

3 years agoAuto merge of #6704 - rust-lang:flip1995-patch-1, r=phansch
bors [Tue, 9 Feb 2021 15:47:30 +0000 (15:47 +0000)]
Auto merge of #6704 - rust-lang:flip1995-patch-1, r=phansch

Rename "good first issue" back to "good-first-issue"

changelog: none

3 years agoRename "good first issue" back to "good-first-issue"
Philipp Krones [Tue, 9 Feb 2021 09:29:00 +0000 (10:29 +0100)]
Rename "good first issue" back to "good-first-issue"

3 years agoRename HIR UnOp variants
Ömer Sinan Ağacan [Tue, 9 Feb 2021 08:15:53 +0000 (11:15 +0300)]
Rename HIR UnOp variants

This renames the variants in HIR UnOp from

    enum UnOp {
        UnDeref,
        UnNot,
        UnNeg,
    }

to

    enum UnOp {
        Deref,
        Not,
        Neg,
    }

Motivations:

- This is more consistent with the rest of the code base where most enum
  variants don't have a prefix.

- These variants are never used without the `UnOp` prefix so the extra
  `Un` prefix doesn't help with readability. E.g. we don't have any
  `UnDeref`s in the code, we only have `UnOp::UnDeref`.

- MIR `UnOp` type variants don't have a prefix so this is more
  consistent with MIR types.

- "un" prefix reads like "inverse" or "reverse", so as a beginner in
  rustc code base when I see "UnDeref" what comes to my mind is
  something like "&*" instead of just "*".

3 years agoFix collapsible_if false positive with attributes
Cameron Steffen [Mon, 8 Feb 2021 17:00:30 +0000 (11:00 -0600)]
Fix collapsible_if false positive with attributes

3 years agoSimplify if_chain
Cameron Steffen [Mon, 8 Feb 2021 16:51:40 +0000 (10:51 -0600)]
Simplify if_chain

3 years agoFix missing_panics_doc warning on `unreachable!`.
daxpedda [Mon, 8 Feb 2021 16:25:10 +0000 (17:25 +0100)]
Fix missing_panics_doc warning on `unreachable!`.

3 years agoUse path_to_local_id
Cameron Steffen [Mon, 8 Feb 2021 15:50:13 +0000 (09:50 -0600)]
Use path_to_local_id

3 years agoRefactor out UnusedSelfVisitor
Cameron Steffen [Wed, 3 Feb 2021 17:45:16 +0000 (11:45 -0600)]
Refactor out UnusedSelfVisitor

3 years agoEnhance LocalUsedVisitor to check closure bodies
Cameron Steffen [Wed, 3 Feb 2021 17:35:16 +0000 (11:35 -0600)]
Enhance LocalUsedVisitor to check closure bodies

3 years agoFix vec_init_then_push FP
Cameron Steffen [Fri, 5 Feb 2021 22:28:13 +0000 (16:28 -0600)]
Fix vec_init_then_push FP

3 years agoUse id instead of name
Cameron Steffen [Fri, 5 Feb 2021 22:27:23 +0000 (16:27 -0600)]
Use id instead of name

3 years agoAuto merge of #6696 - dtolnay-contrib:regex, r=Manishearth
bors [Mon, 8 Feb 2021 06:02:29 +0000 (06:02 +0000)]
Auto merge of #6696 - dtolnay-contrib:regex, r=Manishearth

Downgrade trivial_regex to nursery

See #6690. I think there is still value in a trivial_regex lint, but only if clippy can tell that the regex is only ever constructed and applied to a single input.

```rust
let regex = Regex::new("trivial_regex")?;
println!("{}", regex.is_match(s));
// `regex` never used again
```

---

changelog: remove `trivial_regex` from default set of enabled lints

3 years agoDowngrade trivial_regex to nursery
David Tolnay [Mon, 8 Feb 2021 00:54:09 +0000 (16:54 -0800)]
Downgrade trivial_regex to nursery

3 years agoAuto merge of #6694 - matthiaskrgr:lintcheck-cfg, r=Manishearth
bors [Sun, 7 Feb 2021 19:04:00 +0000 (19:04 +0000)]
Auto merge of #6694 - matthiaskrgr:lintcheck-cfg, r=Manishearth

lintcheck: add a cmdline option --crates-toml <TOML PATH> to override crate sources file to use.

Fixes #6691

changelog: lintcheck: add --crates-toml  cmdline option to override default crates.toml file.

3 years agoadd a new lint `bytes_nth`
Takayuki Maeda [Sun, 7 Feb 2021 16:34:59 +0000 (01:34 +0900)]
add a new lint `bytes_nth`

3 years agolintcheck: add a cmdline option --crates-toml <TOML PATH> to override crate sources...
Matthias Krüger [Sun, 7 Feb 2021 15:12:21 +0000 (16:12 +0100)]
lintcheck: add a cmdline option --crates-toml <TOML PATH> to override crate sources file to use.

Fixes #6691

3 years agoAuto merge of #6686 - matthiaskrgr:lintcheck_git, r=flip1995
bors [Sun, 7 Feb 2021 13:25:00 +0000 (13:25 +0000)]
Auto merge of #6686 - matthiaskrgr:lintcheck_git, r=flip1995

lintcheck: support git sources

This adds support for git sources in `cargo dev-lintcheck`

You can add a git source to `clippy_dev/lintcheck_crates.toml` by having a `git_url` and a `git_hash` key instead of the `versions` array.
The repo will the be cloned and checked out to the requested commit before checking it with clippy.

Fixes https://github.com/rust-lang/rust-clippy/issues/6642

changelog: lintcheck: support git sources

3 years agoAuto merge of #6674 - phlip9:disallowed_functions, r=llogiq
bors [Sun, 7 Feb 2021 11:15:44 +0000 (11:15 +0000)]
Auto merge of #6674 - phlip9:disallowed_functions, r=llogiq

disallowed_methods: Support functions in addition to methods

## Context:

Hey all! I have a particular use case where I'd like to ban certain functions in a code base I work on. For example, I want to ban `Instant::now()` (among others) as we have a time service for mocking time in deterministic simulation tests. Obviously, it doesn't make sense to include a lint like this for all clippy users. Imagine my excitement when I spotted the new `disallowed_methods` lint in clippy--perfect! Unfortunately, after playing around with it for a bit, I was frustrated to realize that it didn't support functions like `Instant::now()`, so I've added support for them in this PR.

It might also make sense to rename the lint from `disallowed_methods` -> `disallowed_functions`, though I've held off from including that rename in this change, since I'm unsure of clippy's breaking change policy.

## Change

Support functions in addition to methods. In other words, support:

`disallowed_methods = ["alloc::vec::Vec::new"]` (a function) in addition to
`disallowed_methods = ["alloc::vec::Vec::leak"]` (a method).

Improve the documentation to clarify that users must specify the full qualified path for each disallowed function, which can be confusing for reexports. Include an example `clippy.toml`.

Simplify the actual lint pass so we can reuse `utils::fn_def_id`.

changelog: disallowed_method: Now supports functions in addition to methods

3 years agoAuto merge of #6685 - magurotuna:filter_map_identity, r=phansch
bors [Sun, 7 Feb 2021 09:55:32 +0000 (09:55 +0000)]
Auto merge of #6685 - magurotuna:filter_map_identity, r=phansch

Add new lint `filter_map_identity`

<!--
Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only includes internal changes, you can just write
`changelog: none`. Otherwise, please write a short comment
explaining your change.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- \[x] Followed [lint naming conventions][lint_naming]
- \[x] Added passing UI tests (including committed `.stderr` file)
- \[x] `cargo test` passes locally
- \[x] Executed `cargo dev update_lints`
- \[x] Added lint documentation
- \[x] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR.
-->

This commit adds a new lint named filter_map_identity.
This lint is the same as `flat_map_identity` except that it checks for the usage of `filter_map`.

---

Closes #6643

changelog: Added a new lint: `filter_map_identity`

3 years agoSimplify DefaultNumericFallback
Yoshitomo Nakanishi [Sun, 7 Feb 2021 09:00:08 +0000 (18:00 +0900)]
Simplify DefaultNumericFallback

3 years agoAuto merge of #6681 - 1c3t3a:1c3t3a-issue-6467, r=xFrednet,flip1995,phansch
bors [Sun, 7 Feb 2021 08:53:52 +0000 (08:53 +0000)]
Auto merge of #6681 - 1c3t3a:1c3t3a-issue-6467, r=xFrednet,flip1995,phansch

Adds a new lint that checks if there is a semicolon on the last block statement if it returns nothing

changelog: Added a new lint: `SEMICOLON_IF_NOTHING_RETURNED`
fixes #6467
Adds the `SEMICOLON_IF_NOTHING_RETURNED` lint and therefore closes #6467.