Commit Graph

8470 Commits

Author SHA1 Message Date
Philipp Hansch
eb7ad1c6cd
cargo dev fmt 2020-04-17 08:09:09 +02:00
Philipp Hansch
870ae36f85
Cleanup: Rename 'db' variable to 'diag' 2020-04-17 08:08:00 +02:00
Shotaro Yamada
f58bb5b234 question_mark: don't add as_ref() for a call expression 2020-04-17 13:09:02 +09:00
bors
8ae143fcd0 Auto merge of #5480 - sinkuu:unit_arg_app, r=flip1995
unit_arg suggestion is not really machine-applicable

This lint suggests replacing any code returining `()`-type with `()` literal, which can change the behavior. e.g. `Ok(do_something())` -> `OK(())`.

---

changelog: none
2020-04-17 01:40:59 +00:00
Shotaro Yamada
162cf261dc unit_arg suggestion may be incorrect 2020-04-17 10:26:58 +09:00
bors
eb9c15a6b3 Auto merge of #5479 - matthiaskrgr:readme_auto_fix, r=flip1995
readme: update to cargo clippy --fix command

changelog: none
2020-04-16 21:41:14 +00:00
bors
adf7c505e6 Auto merge of #5476 - ThibsG:FixMatchesInExternalMacros, r=flip1995
Do not lint in macros for match lints

Don't lint in macros for match lints, more precisely in `check_pat` and `check_local` where it was not the case.

changelog: none

fixes: #5362
2020-04-16 20:51:56 +00:00
bors
2f6b6ab8a1 Auto merge of #5475 - woshilapin:woshilapin-patch-1, r=flip1995
[fix] Minor typo in GH Actions 'clippy_dev'

changelog: minor: fixes file name in Github Actions workflow `clippy_dev.yml`

I was looking for something else and ended up on that typo, just thought I would fix it.
2020-04-16 20:29:19 +00:00
Matthias Krüger
65bc234c5c readme: update to cargo clippy --fix command 2020-04-16 22:19:11 +02:00
bors
c1c8bc6307 Auto merge of #5473 - Toxyxer:map-flatten-for-option, r=flip1995
Map flatten for option

Fixes #5175

changelog:
- Trigger the map_flatten lint when map is called on an option
- Add test for such case
2020-04-16 20:15:56 +00:00
bors
3704954bd1 Auto merge of #5474 - phansch:reenable-rustfmt, r=flip1995
Reenable rustfmt integration test

changelog: none
2020-04-16 19:39:28 +00:00
bors
da14f1e0ef Auto merge of #5478 - matthiaskrgr:apt_ci_debug_5477, r=phansch,flip1995
perform system upgrade fixes ci issue

Perhaps doing a system upgrade magically solves the problem?

changelog: none
2020-04-16 19:23:11 +00:00
Matthias Krüger
d181fde95e CI: performing system upgrade fixes broken apt deps on ubuntu 32bit
See #5477 for details
2020-04-16 21:03:59 +02:00
ThibsG
7fb94c2ac9 Do not lint in macros for match lints 2020-04-16 14:57:12 +02:00
Jean SIMARD
b5d62335a4
[fix] Minor typo in GH Actions 'clippy_dev' 2020-04-16 13:51:37 +02:00
Philipp Hansch
014c41547e
Reenable rustfmt integration test 2020-04-16 13:17:06 +02:00
Marcin Serwin
72a8fc24e6 Add test to map_flatten with an Option 2020-04-16 08:00:32 +02:00
Marcin Serwin
c20afbdfe0 Lint map_flatten if caller is an Option 2020-04-16 08:00:32 +02:00
bors
1765c5da90 Auto merge of #5363 - yaahc:clippy-fix, r=phansch,flip1995
add --fix support to `cargo-clippy`

Prior to this we had started work on integrating clippy as a subcommand directly into cargo in the form of `cargo clippy-preview` and `cargo fix --clippy`. In the course of that work it was decided that the best approach would be to strictly add the features clippy needed to cargo in order to insert `clippy-driver` only for workspace crates. This was accomplished by adding a `RUSTC_WORKSPACE_WRAPPER` env variable to cargo that will override the normal `RUSTC_WRAPPER` when both are present and the current crate is a workspace crate.

This change adds support to clippy to use this by setting the `RUSTC_WORKSPACE_WRAPPER` env variable instead `RUSTC_WRAPPER` and by detecting `--fix` as an arg and swapping out the `check` cargo command for `fix` when it is present.

WIP, here are the current issues that I still need to resolve

- [x] Detect if we're running on nightly rust
  - [x] Set `RUSTC_WORKSPACE_WRAPPER` on nightly, and `RUSTC_WRAPPER` on stable
  - [x] Error out on stable when `--fix` is specified, because stable currently hasn't landed the PR for `RUSTC_WORKSPACE_WRAPPER` so if we set this it just runs check and silently fails
- [ ] Update the help text
  - [ ] The current plan is to shell out to `cargo check --help` and then postprocess the output to mention clippy instead of check where appropriate and to add the extra info about `--fix` and the `-- -A lint` options.
- [x] tests?

changelog: add `--fix` arg to `cargo-clippy`
2020-04-15 22:38:42 +00:00
Jane Lusby
5cfb9ec1d7
Apply suggestions from code review
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2020-04-15 14:25:42 -07:00
Jane Lusby
664ad33faf manually fixing formatting at this point lol 2020-04-15 13:08:33 -07:00
Jane Lusby
0397e46ea5 fmt 2020-04-15 13:04:04 -07:00
Jane Lusby
b3030e1b90 rename field 2020-04-15 12:31:40 -07:00
bors
6651c1b9b2 Auto merge of #5470 - flip1995:rollup-cvkuiza, r=flip1995
Rollup of 5 pull requests

Successful merges:

 - #5226 (Add lint for explicit deref and deref_mut method calls)
 - #5248 (Add lint on large non scalar const)
 - #5430 (Disallow bit-shifting in integer_arithmetic)
 - #5466 (large_enum_variant: Report sizes of variants)
 - #5468 (Zero single char names)

Failed merges:

r? @ghost

changelog: rollup
2020-04-15 18:22:37 +00:00
Philipp Krones
19183a6af5
Rollup merge of #5468 - Toxyxer:zero-single-char-names, r=flip1995
Zero single char names

Fixes: #4086

changelog:
- Make the inequality strict
2020-04-15 20:12:31 +02:00
Philipp Krones
071a5904eb
Rollup merge of #5466 - phansch:large-enum-variant-output, r=flip1995
large_enum_variant: Report sizes of variants

This reports the sizes of the largest and second-largest variants.

Closes #5459

changelog: `large_enum_variant`: Report the sizes of the largest and second-largest variants.
2020-04-15 20:12:30 +02:00
Philipp Krones
2538e63885
Rollup merge of #5430 - michaelsproul:integer-arithmetic, r=flip1995
Disallow bit-shifting in integer_arithmetic

Make the `integer_arithmetic` lint detect all the operations that are defined as being capable of overflow in the [Rust Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#overflow), by also linting for bit-shifting operations (`<<`, `>>`).

changelog: Disallow bit-shifting in `integer_arithmetic`
2020-04-15 20:12:29 +02:00
Philipp Krones
ceea3c6a35
Rollup merge of #5248 - ThibsG:ConstValues, r=flip1995
Add lint on large non scalar const

This PR adds the new lint `non_scalar_const` that aims to warn against `const` declaration of large arrays. For performance, because of inlining, large arrays should be preferably declared as `static`.

Note: i made this one to warn on all const arrays, whether they are in a body function or not. I don't know if this is really necessary, i could just reduce this lint to variables out of function scope.

Fixes: #400

changelog: add new lint for large non-scalar types declared as const
2020-04-15 20:12:28 +02:00
Philipp Krones
3481bf4102
Rollup merge of #5226 - ThibsG:DerefExplicit1566, r=flip1995
Add lint for explicit deref and deref_mut method calls

This PR adds the lint `explicit_deref_method` that suggests replacing `deref()` and `deref_mut()` with `&*a` and `&mut *a`.

It doesn't lint inside macros.

This PR is the continuation of  #3258.

changelog: Add lint `explicit_deref_method`.

Fixes: #1566
2020-04-15 20:12:27 +02:00
bors
a9a4c8e630 Auto merge of #5467 - matthiaskrgr:rustup_43, r=flip1995
rustup https://github.com/rust-lang/rust/pull/71116

changelog: none
2020-04-15 17:46:24 +00:00
Philipp Krones
a353f0f174
Rename dummy_hir_id -> parent_hir_id 2020-04-15 19:46:05 +02:00
Matthias Krüger
721549569c rustup https://github.com/rust-lang/rust/pull/71116 2020-04-15 18:58:44 +02:00
Jane Lusby
625011081b revert the damn fmt changes 2020-04-15 09:22:45 -07:00
Jane Lusby
a3ce88b4d7 add some tests 2020-04-15 09:20:41 -07:00
Jane Lusby
216371d424 split it up for testing but the merge broke tests 2020-04-15 09:06:57 -07:00
Marcin Serwin
ce372c17cd Change default many single char names threshold 2020-04-15 17:58:26 +02:00
Jane Lusby
0441525690 Merge remote-tracking branch 'upstream/master' into clippy-fix 2020-04-15 08:24:13 -07:00
ThibsG
3c2bbcf00e Better precedence case management + more tests 2020-04-15 17:18:12 +02:00
ThibsG
72b9ae2a10 Use only check_expr with parent expr and precedence 2020-04-15 17:18:12 +02:00
ThibsG
b6d4330550 Check for Deref trait impl + add fixed version 2020-04-15 17:18:12 +02:00
ThibsG
c1132434a7 Report using stmts and expr + tests 2020-04-15 17:18:12 +02:00
ThibsG
6b4ab82746 Global rework + fix imports 2020-04-15 17:18:12 +02:00
Tom Milligan
b2d986850d Working basic dereference clip 2020-04-15 17:18:12 +02:00
Marcin Serwin
512f23fff1 Add test for zero single char names 2020-04-15 13:35:44 +02:00
Marcin Serwin
d3ebd06ec9 Make the single char threshold strict inequality 2020-04-15 13:35:44 +02:00
Philipp Hansch
69c3e9c90f
large_enum_variant: Report sizes of variants
This reports the sizes of the largest and second-largest variants.
2020-04-15 09:56:32 +02:00
bors
c496f4e63f Auto merge of #5464 - matthiaskrgr:dep_compiletest, r=phansch
deps: bump compiletest-rs from 0.4 to 0.5

changelog: none
2020-04-15 07:39:03 +00:00
bors
a96f874301 Auto merge of #5345 - Toxyxer:add-lint-for-float-in-array-comparison, r=flip1995
Add lint for float in array comparison

Fixes #4277
changelog:
- Added new handler for expression of index kind (e.g. `arr[i]`). It returns a constant when both array and index are constant, or when the array is constant and all values are equal.
- Trigger float_cmp and float_cmp_const lint when comparing arrays. Allow for comparison when one of the arrays contains only zeros or infinities.
- Added appropriate tests for such cases.
2020-04-15 06:39:11 +00:00
bors
c6cc07a851 Auto merge of #5452 - phansch:match_def_path_refactor, r=matthiaskrgr
Refactor: Use rustc's `match_def_path`

This replaces our match_def_path implementation with the rustc one.

Note that we can't just use it in all call sites because of the
`&[&str]` / `&[Symbol]` difference in Clippy/rustc.

changelog: none
2020-04-15 05:42:52 +00:00
Philipp Hansch
9ec95af702
Refactor: Use rustc's match_def_path
This replaces our match_def_path implementation with the rustc one.

Note that we can't just use it in all call sites because of the
`&[&str]` / `&[Symbol]` difference in Clippy/rustc.
2020-04-15 07:23:13 +02:00