Commit graph

9093 commits

Author SHA1 Message Date
Takayuki Nakata
0117ea2b01
Refactoring: use inner function 2020-09-10 18:05:04 +02:00
Takayuki Nakata
1778a1ec46
Restrict same_item_push to suppress false positives
It emits a lint when the pushed item is a literal, a constant and an immutable binding that are initialized with those.
2020-09-10 18:05:01 +02:00
bors
09bd400243 Auto merge of #5891 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

Sync back rust-lang/rust#75098

changelog: none
2020-08-11 12:32:10 +00:00
flip1995
9311c11d7c
Fix sync fallout 2020-08-11 14:21:27 +02:00
Dylan DPC
9e73d33680 Rollup merge of #75098 - Ryan1729:clippy-pointer-cast-lint-experiment, r=oli-obk
Clippy pointer cast lint experiment

This PR is an experiment about exposing more parts of `rustc_typeck` for use in `clippy`. In particular, the code that checks where a cast is valid or not was exposed, which necessitated exposing [`FnCtxt`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/struct.FnCtxt.html), and figuring out how to create an instance of that type inside `clippy`.

This was prompted by [this clippy issue](https://github.com/rust-lang/rust-clippy/issues/2064).

r? @oli-obk
2020-08-11 01:56:30 +02:00
bors
cc5bfd473c Auto merge of #5888 - matthiaskrgr:lints, r=yaahc
make a bunch of lints texts adhere to rustc dev guide

According to the rustc-dev guide: "The text should be matter of fact and avoid capitalization and periods, unless multiple sentences are needed"

changelog: make some lint output adhere to the rustc-dev guide
2020-08-10 22:40:42 +00:00
Matthias Krüger
6d0b5e24df update test stderr 2020-08-11 00:27:55 +02:00
bors
16831891da Auto merge of #5889 - ebroto:5886_or_fun_call_const_0_args, r=Manishearth
Avoid or_fun_call for const_fn with no args

Based on #5682 by @lzutao

This avoids a subset of false positives, specifically those related to `const fn`s that take no arguments.
For the rest, a much more involved fix would be needed, see https://github.com/rust-lang/rust-clippy/pull/5682#issuecomment-638681210.

So this does *not* solve #5658

changelog: Avoid triggering [`or_fun_call`] with `const fn`s that take no arguments.

Fixes #5886
2020-08-10 22:12:38 +00:00
Matthias Krüger
f59ec1945f run cargo dev update-lints 2020-08-10 23:57:08 +02:00
Matthias Krüger
1b46e485b2 Update clippy_lints/src/unwrap.rs
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-08-10 23:57:08 +02:00
Matthias Krüger
c514ff0c93 Update clippy_lints/src/neg_cmp_op_on_partial_ord.rs
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-08-10 23:57:08 +02:00
Matthias Krüger
dabf989195 neg-cmp-op-on-partial-ord: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
178da9b2ef neg-multiply: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
e519bb3c85 overflow-check-conditional: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
9178363574 path-buf-push-overwrite: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
81f77a411e range-zip-with-len: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
3e1e0c9bdb redundant-static-lifetimes: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
5d69ca5e11 also change "deprecated-attribute" message 2020-08-10 23:49:06 +02:00
Matthias Krüger
fe37ddbd11 suspicious-arithmetic-impl: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
7954c22a99 unknown: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
b36a6c9594 ref_in_deref: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
4418ff122f unneeded-field-pattern: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
2792260636 empty-liner-after-outer-attr: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
0db5cb1393 drop_bounds: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
590b91d8d4 double-parens: make lint adhere to lint message convention and do minor refactoring 2020-08-10 23:49:06 +02:00
Matthias Krüger
ba7a01a6a8 double-comparisons: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
6b0a6a70f8 default-trait-access: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
3d592b5154 cmp_null: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
8679dd375b unnecessary_unwrap, panicking_unwrap: make lints adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
9b7ab1d38b checked-conversions: make lint adhere to lint message convention 2020-08-10 23:48:57 +02:00
Eduardo Broto
5d66bd7bb3 Avoid or_fun_call for const_fn with no args 2020-08-10 23:38:58 +02:00
Matthias Krüger
40416c0fa8 naive_bytecount: make lint adhere to lint message convention 2020-08-10 20:55:23 +02:00
Matthias Krüger
fd379a889e builtin-type-shadow: make lint adhere to lint message convention 2020-08-10 20:55:23 +02:00
Matthias Krüger
0876f17d77 bool-comparison: make lint adhere to lint message convention 2020-08-10 20:55:23 +02:00
Matthias Krüger
e57aafe33f too-many-lines: make lint adhere to lint message convention 2020-08-10 20:55:23 +02:00
bors
4113453202 Auto merge of #5887 - robojumper:patch-1, r=flip1995
Fix CHANGELOG's commit range links

Two most recent links linked to the wrong range

changelog: none
2020-08-10 17:51:37 +00:00
robojumper
82c816ee02
Fix CHANGELOG's commit range links
Two most recent links linked to the wrong range

changelog: none
2020-08-10 17:45:04 +02:00
bors
c576bedc41 Auto merge of #5883 - flip1995:rollup-x9mftxe, r=flip1995
Rollup of 5 pull requests

Successful merges:

 - #5825 (Add the new lint `same_item_push`)
 - #5869 (New lint against `Self` as an arbitrary self type)
 - #5870 (enable #[allow(clippy::unsafe_derive_deserialize)])
 - #5871 (Lint .min(x).max(y) with x < y)
 - #5874 (Make the docs clearer for new contributors)

Failed merges:

r? @ghost

changelog: rollup
2020-08-10 13:02:53 +00:00
Philipp Krones
7f6897c7a3
Rollup merge of #5874 - camelid:patch-1, r=flip1995
Make the docs clearer for new contributors

It confused me before, so I made it extra obvious that you need to run
a script to set up your toolchain before you can build Clippy.

I also added a note so that new contributors aren't confused when
Clippy doesn't build as a result of a change in rustc's internals.

changelog: make `CONTRIBUTING.md` clearer for new contributors
2020-08-10 14:56:30 +02:00
Philipp Krones
ee8db50e13
Rollup merge of #5871 - wiomoc:feature/methodcall-minmax, r=flip1995
Lint .min(x).max(y) with x < y

Fixes  #5854

changelog: Also lint `ord.min(a).max(b)`, where `a < b` in [`min_max`] lint
2020-08-10 14:56:29 +02:00
Philipp Krones
08ab29bed1
Rollup merge of #5870 - ebroto:5789_allow_unsafe_derive_deserialize, r=flip1995
enable #[allow(clippy::unsafe_derive_deserialize)]

Before this change this lint could not be allowed as the code we are checking is automatically generated.

changelog: Enable using the `allow` attribute on top of an ADT linted by [`unsafe_derive_deserialize`].

Fixes: #5789
2020-08-10 14:56:27 +02:00
Philipp Krones
8ee57eed79
Rollup merge of #5869 - wiomoc:feature/implicit-self, r=ebroto,flip1995
New lint against `Self` as an arbitrary self type

Fixes #5861

changelog: * [`needless_arbitrary_self_type`] [#5869](https://github.com/rust-lang/rust-clippy/pull/5869)
2020-08-10 14:56:26 +02:00
Philipp Krones
9da5b6d1d0
Rollup merge of #5825 - giraffate:same_item_push, r=Manishearth
Add the new lint `same_item_push`

changelog: Add the new lint `same_item_push`

Fixed #4078. As I said in https://github.com/rust-lang/rust-clippy/issues/4078#issuecomment-658184195, I referrerd to https://github.com/rust-lang/rust-clippy/pull/4647.
2020-08-10 14:56:25 +02:00
bors
7228368953 Auto merge of #5882 - dima74:ra_setup-prevent-compile-rustc, r=Manishearth
Prevent compile parts of rustc when using `cargo dev ra-setup`

Currently after running `cargo dev ra-setup` the following lines are added to `Cargo.toml`:

```toml
[target]
rustc_data_structures = { path = ".../rust/src/librustc_data_structures" }
rustc_driver = { path = ".../rust/src/librustc_driver" }
rustc_errors = { path = ".../rust/src/librustc_errors" }
rustc_interface = { path = ".../rust/src/librustc_interface" }
rustc_middle = { path = ".../rust/src/librustc_middle" }
```

This pull request adds dependencies for `rustc` crates under `cfg(NOT_A_PLATFORM)`, thus preventing them from compiling together with clippy:

```toml
[target.'cfg(NOT_A_PLATFORM)'.dependencies]
rustc_data_structures = { path = ".../rust/src/librustc_data_structures" }
rustc_driver = { path = ".../rust/src/librustc_driver" }
rustc_errors = { path = ".../rust/src/librustc_errors" }
rustc_interface = { path = ".../rust/src/librustc_interface" }
rustc_middle = { path = ".../rust/src/librustc_middle" }
```

---

This approach was [originally proposed for IntelliJ Rust](https://github.com/intellij-rust/intellij-rust/issues/1618#issuecomment-459098749), and looks like it works for rust-analyzer too.

changelog: none
2020-08-09 19:18:01 +00:00
Dmitry Murzin
6af969379e
Prevent compile parts of rustc when using cargo dev ra-setup 2020-08-09 22:21:09 +05:00
Ryan1729
873e5f5c19 add allow unused_unsafe and allow dead_code 2020-08-09 00:39:14 -06:00
Ryan1729
bc8d32d36b fix unary minus on usize and unused variable errors in .fixed file 2020-08-09 00:28:56 -06:00
Ryan1729
84db238fa1 add a test example of where transmutes_expressible_as_ptr_casts should not suggest anything 2020-08-09 00:15:56 -06:00
Ryan1729
a1ca12581a update stderr for transmutes_expressible_as_ptr_casts 2020-08-08 21:03:41 -06:00
bors
70c46de012 Auto merge of #5877 - ebroto:5872_loops_ice, r=Manishearth
Fix ICE in `loops` module

changelog: Fix ICE related to `needless_collect` when a call to `iter()` was not present.

I went for restoring the old suggestion of `next().is_some()` over `get(0).is_some()` given that `iter()` is not necessarily present (could be e.g. `into_iter()` or `iter_mut()`)  and that the old suggestion could change semantics, e.g. a call to `filter()` could be present between `iter()` and the collect part.

Fixes #5872
2020-08-08 18:44:48 +00:00