Commit Graph

10686 Commits

Author SHA1 Message Date
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
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
bors
9c0ae2a5ab 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`.
2021-02-10 13:27:53 +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
bb40db7adc
Update test files 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
5996ae1cfc add some test cases 2021-02-10 16:15:29 +09: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
bors
0e371b8923 Auto merge of #6698 - camsteffen:path-to-local, r=phansch
More path-to-local fixes

changelog: Fix some detections of variable usage in closures
2021-02-10 06:17:37 +00:00
bors
08b4d50601 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
2021-02-09 16:50:35 +00:00
Philipp Krones
03737e2247
Remove rustfmt from rust-toolchain file
We use latest nightly rustfmt in our tests anyway
2021-02-09 17:44:36 +01:00
ThibsG
b932587c5d Add better turbofish extractor 2021-02-09 17:43:49 +01:00
bors
03a0dd599d Auto merge of #6704 - rust-lang:flip1995-patch-1, r=phansch
Rename "good first issue" back to "good-first-issue"

changelog: none
2021-02-09 15:47:30 +00:00
Philipp Krones
775ce47b06
Rename "good first issue" back to "good-first-issue" 2021-02-09 10:29:00 +01:00
Ömer Sinan Ağacan
34b373d309 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 "*".
2021-02-09 11:39:20 +03:00
daxpedda
6c73f989e2
Fix missing_panics_doc warning on unreachable!. 2021-02-08 17:25:10 +01:00
Cameron Steffen
37555f8f73 Use path_to_local_id 2021-02-08 09:50:13 -06:00
Cameron Steffen
5db48a382a Refactor out UnusedSelfVisitor 2021-02-08 08:56:33 -06:00
Cameron Steffen
1d30422945 Enhance LocalUsedVisitor to check closure bodies 2021-02-08 08:56:33 -06:00
bors
4bbd7e46ee 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
2021-02-08 06:02:29 +00:00
David Tolnay
fd35517bd4
Downgrade trivial_regex to nursery 2021-02-07 16:54:09 -08:00
bors
de35c297bf 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.
2021-02-07 19:04:00 +00:00
Takayuki Maeda
1c3033d5cf add a new lint bytes_nth 2021-02-08 01:34:59 +09:00
Matthias Krüger
6f3eeac83c lintcheck: add a cmdline option --crates-toml <TOML PATH> to override crate sources file to use.
Fixes #6691
2021-02-07 16:14:43 +01:00
bors
c1ce78f0b2 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
2021-02-07 13:25:00 +00:00
bors
83b7b16330 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
2021-02-07 11:15:44 +00:00