]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoDo not lint in macros for match lints
ThibsG [Fri, 27 Mar 2020 19:36:00 +0000 (20:36 +0100)]
Do not lint in macros for match lints

4 years agoAuto merge of #5363 - yaahc:clippy-fix, r=phansch,flip1995
bors [Wed, 15 Apr 2020 22:38:42 +0000 (22:38 +0000)]
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`

4 years agoApply suggestions from code review
Jane Lusby [Wed, 15 Apr 2020 21:25:42 +0000 (14:25 -0700)]
Apply suggestions from code review

Co-Authored-By: Philipp Krones <hello@philkrones.com>
4 years agomanually fixing formatting at this point lol
Jane Lusby [Wed, 15 Apr 2020 20:08:33 +0000 (13:08 -0700)]
manually fixing formatting at this point lol

4 years agofmt
Jane Lusby [Wed, 15 Apr 2020 20:04:04 +0000 (13:04 -0700)]
fmt

4 years agorename field
Jane Lusby [Wed, 15 Apr 2020 19:31:40 +0000 (12:31 -0700)]
rename field

4 years agoAuto merge of #5470 - flip1995:rollup-cvkuiza, r=flip1995
bors [Wed, 15 Apr 2020 18:22:37 +0000 (18:22 +0000)]
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

4 years agoRollup merge of #5468 - Toxyxer:zero-single-char-names, r=flip1995
Philipp Krones [Wed, 15 Apr 2020 18:12:31 +0000 (20:12 +0200)]
Rollup merge of #5468 - Toxyxer:zero-single-char-names, r=flip1995

Zero single char names

Fixes: #4086
changelog:
- Make the inequality strict

4 years agoRollup merge of #5466 - phansch:large-enum-variant-output, r=flip1995
Philipp Krones [Wed, 15 Apr 2020 18:12:30 +0000 (20:12 +0200)]
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.

4 years agoRollup merge of #5430 - michaelsproul:integer-arithmetic, r=flip1995
Philipp Krones [Wed, 15 Apr 2020 18:12:29 +0000 (20:12 +0200)]
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`

4 years agoRollup merge of #5248 - ThibsG:ConstValues, r=flip1995
Philipp Krones [Wed, 15 Apr 2020 18:12:28 +0000 (20:12 +0200)]
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

4 years agoRollup merge of #5226 - ThibsG:DerefExplicit1566, r=flip1995
Philipp Krones [Wed, 15 Apr 2020 18:12:27 +0000 (20:12 +0200)]
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
4 years agoAuto merge of #5467 - matthiaskrgr:rustup_43, r=flip1995
bors [Wed, 15 Apr 2020 17:46:24 +0000 (17:46 +0000)]
Auto merge of #5467 - matthiaskrgr:rustup_43, r=flip1995

rustup https://github.com/rust-lang/rust/pull/71116

changelog: none

4 years agoRename dummy_hir_id -> parent_hir_id
Philipp Krones [Wed, 15 Apr 2020 17:46:05 +0000 (19:46 +0200)]
Rename dummy_hir_id -> parent_hir_id

4 years agorustup https://github.com/rust-lang/rust/pull/71116
Matthias Krüger [Wed, 15 Apr 2020 11:44:28 +0000 (13:44 +0200)]
rustup https://github.com/rust-lang/rust/pull/71116

4 years agorevert the damn fmt changes
Jane Lusby [Wed, 15 Apr 2020 16:22:45 +0000 (09:22 -0700)]
revert the damn fmt changes

4 years agoadd some tests
Jane Lusby [Wed, 15 Apr 2020 16:20:41 +0000 (09:20 -0700)]
add some tests

4 years agosplit it up for testing but the merge broke tests
Jane Lusby [Wed, 15 Apr 2020 16:06:57 +0000 (09:06 -0700)]
split it up for testing but the merge broke tests

4 years agoChange default many single char names threshold
Marcin Serwin [Wed, 15 Apr 2020 15:58:26 +0000 (17:58 +0200)]
Change default many single char names threshold

4 years agoMerge remote-tracking branch 'upstream/master' into clippy-fix
Jane Lusby [Wed, 15 Apr 2020 15:24:13 +0000 (08:24 -0700)]
Merge remote-tracking branch 'upstream/master' into clippy-fix

4 years agoBetter precedence case management + more tests
ThibsG [Sat, 21 Mar 2020 18:34:56 +0000 (19:34 +0100)]
Better precedence case management + more tests

4 years agoUse only check_expr with parent expr and precedence
ThibsG [Sat, 7 Mar 2020 14:33:27 +0000 (15:33 +0100)]
Use only check_expr with parent expr and precedence

4 years agoCheck for Deref trait impl + add fixed version
ThibsG [Tue, 25 Feb 2020 22:06:24 +0000 (23:06 +0100)]
Check for Deref trait impl + add fixed version

4 years agoReport using stmts and expr + tests
ThibsG [Sun, 26 Jan 2020 18:48:30 +0000 (19:48 +0100)]
Report using stmts and expr + tests

4 years agoGlobal rework + fix imports
ThibsG [Thu, 23 Jan 2020 15:28:01 +0000 (16:28 +0100)]
Global rework + fix imports

4 years agoWorking basic dereference clip
Tom Milligan [Wed, 3 Oct 2018 16:53:39 +0000 (17:53 +0100)]
Working basic dereference clip

4 years agoAdd test for zero single char names
Marcin Serwin [Wed, 15 Apr 2020 11:22:50 +0000 (13:22 +0200)]
Add test for zero single char names

4 years agoMake the single char threshold strict inequality
Marcin Serwin [Wed, 15 Apr 2020 11:22:28 +0000 (13:22 +0200)]
Make the single char threshold strict inequality

4 years agolarge_enum_variant: Report sizes of variants
Philipp Hansch [Wed, 15 Apr 2020 07:55:02 +0000 (09:55 +0200)]
large_enum_variant: Report sizes of variants

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

4 years agoAuto merge of #5464 - matthiaskrgr:dep_compiletest, r=phansch
bors [Wed, 15 Apr 2020 07:39:03 +0000 (07:39 +0000)]
Auto merge of #5464 - matthiaskrgr:dep_compiletest, r=phansch

deps: bump compiletest-rs from 0.4 to 0.5

changelog: none

4 years agoAuto merge of #5345 - Toxyxer:add-lint-for-float-in-array-comparison, r=flip1995
bors [Wed, 15 Apr 2020 06:39:11 +0000 (06:39 +0000)]
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.

4 years agoAuto merge of #5452 - phansch:match_def_path_refactor, r=matthiaskrgr
bors [Wed, 15 Apr 2020 05:42:52 +0000 (05:42 +0000)]
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

4 years agoRefactor: Use rustc's `match_def_path`
Philipp Hansch [Sun, 12 Apr 2020 08:41:25 +0000 (10:41 +0200)]
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.

4 years agoAuto merge of #5449 - phansch:diagnostic-items, r=matthiaskrgr
bors [Tue, 14 Apr 2020 19:58:17 +0000 (19:58 +0000)]
Auto merge of #5449 - phansch:diagnostic-items, r=matthiaskrgr

Make use of more diagnostic items

This makes use of some (not all) already existing diagnostic items. Specifically:

79982a2: `core::mem::uninitialized`, `core::mem::zeroed`, `alloc::sync::Arc`, `alloc::sync::Rc`
83874d0: `Option` and `Result`

cc #5393

changelog: none

4 years agoAuto merge of #5460 - phansch:fix_incorrect_tests, r=matthiaskrgr
bors [Tue, 14 Apr 2020 19:33:11 +0000 (19:33 +0000)]
Auto merge of #5460 - phansch:fix_incorrect_tests, r=matthiaskrgr

result_map_unit_fn: Fix incorrect UI tests

`x` and the `HasResult` struct were missing in this file.

changelog: none

4 years agodeps: bump compiletest-rs from 0.4 to 0.5
Matthias Krüger [Tue, 14 Apr 2020 19:29:23 +0000 (21:29 +0200)]
deps: bump compiletest-rs from 0.4 to 0.5

4 years agoAuto merge of #5457 - phansch:sym, r=matthiaskrgr
bors [Tue, 14 Apr 2020 12:30:14 +0000 (12:30 +0000)]
Auto merge of #5457 - phansch:sym, r=matthiaskrgr

Cleanup: Use our `sym!` macro more

It's much shorter than Symbol::intern and the effect should still be clear

---

changelog: none

4 years agoAuto merge of #5463 - matthiaskrgr:rustup_42, r=phansch
bors [Tue, 14 Apr 2020 12:18:02 +0000 (12:18 +0000)]
Auto merge of #5463 - matthiaskrgr:rustup_42, r=phansch

rustup https://github.com/rust-lang/rust/pull/70643

changelog: none

4 years agorustup https://github.com/rust-lang/rust/pull/70643
Matthias Krüger [Tue, 14 Apr 2020 10:25:45 +0000 (12:25 +0200)]
rustup https://github.com/rust-lang/rust/pull/70643

4 years agoAuto merge of #5453 - rabisg0:fix/redundant_clone, r=phansch
bors [Tue, 14 Apr 2020 05:59:26 +0000 (05:59 +0000)]
Auto merge of #5453 - rabisg0:fix/redundant_clone, r=phansch

Fixes #5405: redundant clone false positive with arrays

Check whether slice elements implement Copy before suggesting to drop
the clone method

changelog: add a check for slice indexing on redundant_clone lint

4 years agoAuto merge of #5458 - phansch:is-proc-macro-attr, r=matthiaskrgr
bors [Tue, 14 Apr 2020 05:31:03 +0000 (05:31 +0000)]
Auto merge of #5458 - phansch:is-proc-macro-attr, r=matthiaskrgr

Cleanup: Use rustc's is_proc_macro_attr

It's doing exactly the same: https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_ast/expand/mod.rs.html#8-12

changelog: none

4 years agoAuto merge of #5448 - Emerentius:update_new_ret_no_self_docs, r=phansch
bors [Mon, 13 Apr 2020 20:32:44 +0000 (20:32 +0000)]
Auto merge of #5448 - Emerentius:update_new_ret_no_self_docs, r=phansch

Update documentation for new_ret_no_self

changelog: Update documentation for lint new_ret_no_self to reflect that the return type must only contain `Self`, not be `Self`

The lint was changed to be more lenient than the documentation implies in PR #3338 (Related issue #3313)

4 years agoAuto merge of #5461 - phansch:disable_rustfmt_integration_test, r=matthiaskrgr
bors [Mon, 13 Apr 2020 20:17:48 +0000 (20:17 +0000)]
Auto merge of #5461 - phansch:disable_rustfmt_integration_test, r=matthiaskrgr

Temporarily disable rustfmt integration test

Running rustfmt from master is currently broken and [fails our bors build](https://github.com/rust-lang/rust-clippy/runs/582066368#step:10:19):
https://github.com/rust-lang/rust/issues/71077

changelog: none

4 years agoExplain panic on `E0463` in integration tests
Philipp Hansch [Mon, 13 Apr 2020 20:12:57 +0000 (22:12 +0200)]
Explain panic on `E0463` in integration tests

4 years agoTemporarily disable rustfmt integration test
Philipp Hansch [Mon, 13 Apr 2020 13:31:39 +0000 (15:31 +0200)]
Temporarily disable rustfmt integration test

Running rustfmt from master is currently broken:
https://github.com/rust-lang/rust/issues/71077

4 years agoresult_map_unit_fn: Fix incorrect UI tests
Philipp Hansch [Mon, 13 Apr 2020 13:26:53 +0000 (15:26 +0200)]
result_map_unit_fn: Fix incorrect UI tests

`x` and the `HasResult` struct were missing in this file.

4 years agoCleanup: Use rustc's is_proc_macro_attr
Philipp Hansch [Mon, 13 Apr 2020 07:33:00 +0000 (09:33 +0200)]
Cleanup: Use rustc's is_proc_macro_attr

It's doing exactly the same: https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_ast/expand/mod.rs.html#8-12

4 years agoCleanup: Use our `sym!` macro more
Philipp Hansch [Mon, 13 Apr 2020 06:57:34 +0000 (08:57 +0200)]
Cleanup: Use our `sym!` macro more

It's much shorter that Symbol::intern and the result should still be
clear.

4 years agoFixes #5405: redundant clone false positive with arrays
Rabi Guha [Sun, 12 Apr 2020 09:55:47 +0000 (15:25 +0530)]
Fixes #5405: redundant clone false positive with arrays

Check whether slice elements implement Copy before suggesting to drop
the clone method

4 years agoDisallow bit-shifting in `integer_arithmetic` lint
Michael Sproul [Mon, 13 Apr 2020 03:11:19 +0000 (13:11 +1000)]
Disallow bit-shifting in `integer_arithmetic` lint

With this change, the lint checks all operations that are defined as
being capable of overflow in the Rust Reference.

4 years agoupdate lints
Emerentius [Sun, 12 Apr 2020 21:47:58 +0000 (23:47 +0200)]
update lints

4 years agocargo dev fmt
Philipp Hansch [Sun, 12 Apr 2020 13:23:54 +0000 (15:23 +0200)]
cargo dev fmt

4 years agoMake use of Option/Result diagnostic items
Philipp Hansch [Sun, 12 Apr 2020 13:23:07 +0000 (15:23 +0200)]
Make use of Option/Result diagnostic items

4 years agoAuto merge of #5454 - spl:patch-1, r=phansch
bors [Sun, 12 Apr 2020 12:54:32 +0000 (12:54 +0000)]
Auto merge of #5454 - spl:patch-1, r=phansch

verbose_bit_mask: fix bit mask used in docs

changelog: fixes verbose_bit_mask docs

4 years agoMake use of some existing diagnostic items
Philipp Hansch [Fri, 10 Apr 2020 21:18:03 +0000 (23:18 +0200)]
Make use of some existing diagnostic items

4 years agoSay that diagnostic items are preferred over paths
Philipp Hansch [Fri, 10 Apr 2020 21:16:48 +0000 (23:16 +0200)]
Say that diagnostic items are preferred over paths

4 years agoverbose_bit_mask: fix bit mask used in docs
Sean Leather [Sun, 12 Apr 2020 11:11:14 +0000 (13:11 +0200)]
verbose_bit_mask: fix bit mask used in docs

Change the existing hex bit mask (`0x1111`) to a binary one (`0b1111`).

The former does not seem to have anything to do with trailing zeros and is
probably a typo.

4 years agoAuto merge of #5451 - xyzd:allow-uuid-format-digit-grouping, r=phansch
bors [Sun, 12 Apr 2020 08:14:27 +0000 (08:14 +0000)]
Auto merge of #5451 - xyzd:allow-uuid-format-digit-grouping, r=phansch

Allow UUID style formatting for `inconsistent_digit_grouping` lint

This change adds a check to the `inconsistent_digit_grouping` to add a check for
NumericLiterals that follow the UUID format of 8-4-4-4-12.

If the NumericLiteral matches the UUID format, no further inconsistent grouping checks
will be performed.

Closes #5431

changelog: Allow UUID style formatting for `inconsistent_digit_grouping` lint

4 years agoAllow UUID style formatting for `inconsistent_digit_grouping` lint
Dan B [Sun, 12 Apr 2020 00:24:37 +0000 (01:24 +0100)]
Allow UUID style formatting for `inconsistent_digit_grouping` lint

This change adds a check to the `inconsistent_digit_grouping` to add a check for
NumericLiterals that follow the UUID format of 8-4-4-4-12.

If the NumericLiteral matches the UUID format, no further inconsistent grouping checks
will be performed.

Closes #5431

4 years agoAuto merge of #5450 - matthiaskrgr:rustup_41, r=phansch
bors [Sat, 11 Apr 2020 08:20:11 +0000 (08:20 +0000)]
Auto merge of #5450 - matthiaskrgr:rustup_41, r=phansch

rustup https://github.com/rust-lang/rust/pull/69745

changelog: none

4 years agorustup https://github.com/rust-lang/rust/pull/70986
Matthias Krüger [Sat, 11 Apr 2020 08:01:23 +0000 (10:01 +0200)]
rustup https://github.com/rust-lang/rust/pull/70986

4 years agorustup https://github.com/rust-lang/rust/pull/69745
Matthias Krüger [Fri, 10 Apr 2020 23:41:52 +0000 (01:41 +0200)]
rustup https://github.com/rust-lang/rust/pull/69745

4 years agoAuto merge of #5441 - rabisg0:fix/clone-on-copy, r=phansch
bors [Fri, 10 Apr 2020 21:49:26 +0000 (21:49 +0000)]
Auto merge of #5441 - rabisg0:fix/clone-on-copy, r=phansch

Check for clone-on-copy in argument positions

Earlier if arguments to method calls matched the above pattern they were
not reported. This patch ensures such arguments are checked as well.

Fixes #5436

changelog: apply clone_on_copy lint to func args as well

4 years agoAuto merge of #5446 - rust-lang:gimme-a-second, r=flip1995
bors [Fri, 10 Apr 2020 21:33:45 +0000 (21:33 +0000)]
Auto merge of #5446 - rust-lang:gimme-a-second, r=flip1995

compare with the second largest instead of the smallest variant

This should make the lint less noisy for now. See [my comment](https://github.com/rust-lang/rust-clippy/issues/5418#issuecomment-610440898) to issue #5418.

---

changelog: none

4 years agoAuto merge of #5447 - phansch:rustuppp, r=matthiaskrgr
bors [Fri, 10 Apr 2020 18:07:03 +0000 (18:07 +0000)]
Auto merge of #5447 - phansch:rustuppp, r=matthiaskrgr

Rustup to https://github.com/rust-lang/rust/pull/70913

changelog: none

4 years agoUpdate documentation for new_ret_no_self
Emerentius [Fri, 10 Apr 2020 17:08:31 +0000 (19:08 +0200)]
Update documentation for new_ret_no_self

The lint was changed to be more lenient than the documentation implies in PR #3338.
Related issue #3313

4 years agoRustup to https://github.com/rust-lang/rust/pull/70913
Philipp Hansch [Fri, 10 Apr 2020 17:03:34 +0000 (19:03 +0200)]
Rustup to https://github.com/rust-lang/rust/pull/70913

4 years agocompare with the second largest instead of the smallest variant
Andre Bogus [Wed, 8 Apr 2020 22:05:20 +0000 (00:05 +0200)]
compare with the second largest instead of the smallest variant

4 years agoAuto merge of #5442 - rust-lang:revert-5420-newret, r=Manishearth
bors [Thu, 9 Apr 2020 19:06:26 +0000 (19:06 +0000)]
Auto merge of #5442 - rust-lang:revert-5420-newret, r=Manishearth

Revert "Downgrade new_ret_no_self to pedantic"

Reverts rust-lang/rust-clippy#5420

This got through with the big rollup merge, where I didn't recheck every PR of the rollup. Reverting because of the reason given in https://github.com/rust-lang/rust-clippy/pull/5420#issuecomment-610744974 by @joshtriplett

changelog: Move new_ret_no_self back to style category

4 years agoRevert "Downgrade new_ret_no_self to pedantic"
Philipp Krones [Thu, 9 Apr 2020 17:38:20 +0000 (19:38 +0200)]
Revert "Downgrade new_ret_no_self to pedantic"

4 years agoCheck for clone-on-copy in argument positions
Rabi Guha [Thu, 9 Apr 2020 13:50:09 +0000 (19:20 +0530)]
Check for clone-on-copy in argument positions

Earlier if arguments to method calls matched the above pattern they were
not reported. This patch ensures such arguments are checked as well.

Fixes #5436

4 years agoUpdate doc generation script
ThibsG [Mon, 23 Mar 2020 21:07:46 +0000 (22:07 +0100)]
Update doc generation script

4 years agoAdd lint on large const arrays
ThibsG [Sat, 29 Feb 2020 17:41:18 +0000 (18:41 +0100)]
Add lint on large const arrays

4 years agoMake the epsilon note spanless
Marcin Serwin [Mon, 6 Apr 2020 13:29:54 +0000 (15:29 +0200)]
Make the epsilon note spanless

4 years agoSplit check_fn function
Marcin Serwin [Mon, 6 Apr 2020 07:40:53 +0000 (09:40 +0200)]
Split check_fn function

4 years agoIndicate when arrays are compared in error message
Marcin Serwin [Mon, 6 Apr 2020 07:06:50 +0000 (09:06 +0200)]
Indicate when arrays are compared in error message

4 years agoMake epsilon note spanless when comparing arrays
Marcin Serwin [Mon, 6 Apr 2020 06:56:22 +0000 (08:56 +0200)]
Make epsilon note spanless when comparing arrays

4 years agoAdd float cmp const tests for arrays
Marcin Serwin [Fri, 20 Mar 2020 10:54:04 +0000 (11:54 +0100)]
Add float cmp const tests for arrays

4 years agoAdd float cmp tests for arrays
Marcin Serwin [Fri, 20 Mar 2020 10:42:39 +0000 (11:42 +0100)]
Add float cmp tests for arrays

4 years agoHandle constant arrays with single value
Marcin Serwin [Fri, 20 Mar 2020 10:25:39 +0000 (11:25 +0100)]
Handle constant arrays with single value

4 years agoDon't show comparison suggestion for arrays
Marcin Serwin [Fri, 20 Mar 2020 09:51:48 +0000 (10:51 +0100)]
Don't show comparison suggestion for arrays

4 years agoAllow for const arrays of zeros
Marcin Serwin [Fri, 20 Mar 2020 09:40:44 +0000 (10:40 +0100)]
Allow for const arrays of zeros

4 years agoHandle evaluating constant index expression
Marcin Serwin [Thu, 19 Mar 2020 15:54:19 +0000 (16:54 +0100)]
Handle evaluating constant index expression

4 years agoAdd handling of float arrays to miri_to_const
Marcin Serwin [Thu, 19 Mar 2020 14:53:02 +0000 (15:53 +0100)]
Add handling of float arrays to miri_to_const

4 years agoUpdate stderr of float_cmp test
Marcin Serwin [Tue, 17 Mar 2020 09:32:20 +0000 (10:32 +0100)]
Update stderr of float_cmp test

4 years agoUpdate field names in is_float
Marcin Serwin [Tue, 17 Mar 2020 08:03:36 +0000 (09:03 +0100)]
Update field names in is_float

4 years agoAdd tests for float in array comparison
briankabiro [Thu, 19 Sep 2019 12:57:43 +0000 (15:57 +0300)]
Add tests for float in array comparison

4 years agoAdd lint when comparing floats in an array
briankabiro [Wed, 31 Jul 2019 11:52:12 +0000 (14:52 +0300)]
Add lint when comparing floats in an array

Finishes #4277

4 years agoAuto merge of #5411 - dtolnay:hasher, r=flip1995
bors [Wed, 8 Apr 2020 17:14:09 +0000 (17:14 +0000)]
Auto merge of #5411 - dtolnay:hasher, r=flip1995

Downgrade implicit_hasher to pedantic

From the [documentation](https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher), this lint is intended to suggest:

```diff
- pub fn foo(map: &mut HashMap<i32, i32>) { }

+ pub fn foo<S: BuildHasher>(map: &mut HashMap<i32, i32, S>) { }
```

I think this is pedantic. I get that this lint can benefit core libraries like serde, but that's exactly the use case for pedantic lints; a library like serde will [enable clippy_pedantic](https://github.com/serde-rs/json/blob/fd6741f4b0b3fc90a58a6f578e33a9adc6403f3f/src/lib.rs#L304) and take the time to go through everything possible. Similar for libraries doing a libz blitz style checkup before committing to a 1.0 release; it would make sense to run through all the available pedantic lints then.

But otherwise, for most codebases and certainly for industrial codebases, the above suggested change just makes the codebase more obtuse for questionable benefit.

changelog: Remove implicit_hasher from default set of enabled lints

4 years agoAuto merge of #5437 - rabisg0:should-impl-trait, r=flip1995
bors [Wed, 8 Apr 2020 16:55:47 +0000 (16:55 +0000)]
Auto merge of #5437 - rabisg0:should-impl-trait, r=flip1995

Check fn header along with decl when suggesting to implement trait

When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.

Fixes #5413, #4290

changelog: check fn header along with decl for should_implement_trait

4 years agoAuto merge of #5428 - dtolnay:cognitive, r=flip1995
bors [Wed, 8 Apr 2020 16:38:00 +0000 (16:38 +0000)]
Auto merge of #5428 - dtolnay:cognitive, r=flip1995

Move cognitive_complexity to nursery

As discussed in https://github.com/rust-lang/rust-clippy/issues/5418#issuecomment-610054361; Clippy's current understanding of cognitive complexity is not good enough yet at analyzing code for understandability to have this lint be enabled by default.

changelog: Remove cognitive_complexity from default set of enabled lints

4 years agoCheck fn header along with decl when suggesting to implement trait
Rabi Guha [Wed, 8 Apr 2020 10:57:58 +0000 (16:27 +0530)]
Check fn header along with decl when suggesting to implement trait

When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.

Fixes #5413, #4290

4 years agoDowngrade implicit_hasher to pedantic
David Tolnay [Fri, 3 Apr 2020 02:09:30 +0000 (19:09 -0700)]
Downgrade implicit_hasher to pedantic

4 years agoMove cognitive_complexity to nursery
David Tolnay [Mon, 6 Apr 2020 22:46:40 +0000 (15:46 -0700)]
Move cognitive_complexity to nursery

4 years agoAuto merge of #5438 - flip1995:rollup-pi762oy, r=flip1995
bors [Wed, 8 Apr 2020 14:17:47 +0000 (14:17 +0000)]
Auto merge of #5438 - flip1995:rollup-pi762oy, r=flip1995

Rollup of 11 pull requests

Successful merges:

 - #5406 (Fix update_lints)
 - #5409 (Downgrade let_unit_value to pedantic)
 - #5410 (Downgrade trivially_copy_pass_by_ref to pedantic)
 - #5412 (Downgrade inefficient_to_string to pedantic)
 - #5415 (Add new lint for `Result<T, E>.map_or(None, Some(T))`)
 - #5417 (Update doc links and mentioned names in docs)
 - #5419 (Downgrade unreadable_literal to pedantic)
 - #5420 (Downgrade new_ret_no_self to pedantic)
 - #5422 (CONTRIBUTING.md: fix broken triage link)
 - #5424 (Incorrect suspicious_op_assign_impl)
 - #5425 (Ehance opt_as_ref_deref lint.)

Failed merges:

 - #5345 (Add lint for float in array comparison)
 - #5411 (Downgrade implicit_hasher to pedantic)
 - #5428 (Move cognitive_complexity to nursery)

r? @ghost

changelog: rollup

4 years agoRun fmt and update test
flip1995 [Wed, 8 Apr 2020 14:00:03 +0000 (16:00 +0200)]
Run fmt and update test

4 years agoRollup merge of #5425 - xiongmao86:issue5367, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:28 +0000 (15:50 +0200)]
Rollup merge of #5425 - xiongmao86:issue5367, r=flip1995

Ehance opt_as_ref_deref lint.

- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Run `cargo dev fmt`

Lint on opt.as_ref().map(|x| &**x). Fixes #5367.

changelog: lint on opt.as_ref().map(|x| &**x)

4 years agoRollup merge of #5424 - jpospychala:suspicious_op_assign_impl, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:26 +0000 (15:50 +0200)]
Rollup merge of #5424 - jpospychala:suspicious_op_assign_impl, r=flip1995

Incorrect suspicious_op_assign_impl

fixes #5255

changelog: In suspicious_op_assign_impl ignore all operators in expression if it's part of AssignOp

4 years agoRollup merge of #5422 - nickrtorres:contributing-triage, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:25 +0000 (15:50 +0200)]
Rollup merge of #5422 - nickrtorres:contributing-triage, r=flip1995

CONTRIBUTING.md: fix broken triage link

Fixes #5421

4 years agoRollup merge of #5420 - dtolnay:newret, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:24 +0000 (15:50 +0200)]
Rollup merge of #5420 - dtolnay:newret, r=flip1995

Downgrade new_ret_no_self to pedantic

As motivated by #5418. This is the second most widely suppressed Clippy style lint, and [this grep.app search](https://grep.app/search?q=%5C%5Ballow%5C%28.%2Aclippy%3A%3Anew_ret_no_self%5Cb&regexp=true&case=true&filter[lang][0]=Rust) shows a large number of diverse reasonable signatures for a `new` method.

changelog: Remove new_ret_no_self from default set of enabled lints