Commit graph

1493 commits

Author SHA1 Message Date
Daniele D'Orazio
e1a78ae528 update tests and fix lints in clippy 2019-06-21 14:17:59 +02:00
Daniele D'Orazio
6396a7a425 make needless_return work with void functions 2019-06-21 13:58:22 +02:00
Lzu Tao
4fa498a3eb Fix warnings about unnecessary lifetime bounds
Rustup https://github.com/rust-lang/rust/pull/61172
2019-06-20 01:36:23 +07:00
Daniele D'Orazio
be14ea8c37 fix suggestion for floating points inequality
It should be of the form `(a - b).abs() > error` whereas it was
`(a - b).abs() < error` that is instead what should be used for equality.
2019-06-17 16:42:43 +02:00
flip1995
7e07d1bed8
Restructure rename tests 2019-06-14 10:45:03 +02:00
krk
fefa7e7f67
Register rename to the LintStore. 2019-06-14 10:45:03 +02:00
krk
55740219b0
Rename REDUNDANT_STATIC_LIFETIME to REDUNDANT_STATIC_LIFETIMES. 2019-06-14 10:45:03 +02:00
krk
637e92d44e
Rename const_static_lifetime to redundant_static_lifetime. 2019-06-14 10:45:02 +02:00
krk
b38ce08e76
Merge StaticConst and StaticStatic lints into StaticConst. 2019-06-14 09:41:47 +02:00
krk
16bd4796e9
Add lint for statics with explicit static lifetime. 2019-06-14 09:41:46 +02:00
Thiago Arrais
b364eb7b54 Adds lint for integer division 2019-06-12 09:37:14 -03:00
Grzegorz
d4ad23bb3f redundant_closure_for_method_calls fixes:
lint does not trigger when there is a difference in mutability
lint does not trigger when the method belongs to a trait which is not implemebted directly (Deref)
2019-06-12 13:43:36 +02:00
Alexander Shabalin
41a4ce52dd Workaround for rust-lang/rustfmt#3615 2019-06-10 20:19:29 +03:00
Alexander Shabalin
86bab94631 Fixing eta with respect to lazy evaluation. 2019-06-10 13:58:40 +03:00
Michael Wright
b726b41daf Add OUTER_EXPN_INFO lint 2019-06-08 13:35:04 +02:00
bors
5be4e71262 Auto merge of #4136 - euclio:println-writeln-suggestions, r=flip1995
add suggestions for print/write with newline lint

changelog: Add machine-applicable suggestions for `print!`/`write!` with newline lints.
2019-06-06 08:26:48 +00:00
Michael Wright
98585a0324 Fix .map(..).unwrap_or_else(..) bad suggestion
Closes #4144
2019-06-02 08:50:20 +02:00
Philipp Hansch
6feef17071
Fix ellipsis_inclusive_range_patterns lint warnings
Changed from `allow` to `warn` in https://github.com/rust-lang/rust/pull/61342
2019-06-01 07:54:47 +02:00
Andy Russell
2d0c797da6
add suggestions for print/write with newline lint 2019-05-30 13:46:04 -04:00
bors
0ab3f1762e Auto merge of #4113 - rust-lang:author, r=flip1995
Fix `Block`  dump in author lint

changelog: The `#[clippy::author]` attribute now emits correct pattern code for block expressions
2019-05-30 10:34:56 +00:00
Philipp Hansch
2c72026fcb
Rustup to https://github.com/rust-lang/rust/pull/61203
Migrates all trait objects to use `dyn`
2019-05-30 08:31:09 +02:00
Oliver Scherer
3908d86f8a
Don't rustfmt author test
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2019-05-28 15:34:25 +02:00
Oliver Scherer
f98e4bd33b
Fix Block dump in author lint 2019-05-28 13:01:11 +02:00
bors
d57845ffdf Auto merge of #4071 - matthiaskrgr:sizeof, r=flip1995
trivially_copy_pass_by_ref: print size of type and limit in the lint message

changelog: trivially_copy_pass_by_ref: print size of type and limit in the lint message
2019-05-28 07:56:04 +00:00
bors
7b501f0f6a Auto merge of #4137 - euclio:let-return, r=oli-obk
tweak `let_and_return` diagnostic

changelog: `let_and_return`: label the unnecessary let binding and convert the note to a structured
suggestion
2019-05-27 13:04:14 +00:00
bors
eb0a2884d2 Auto merge of #4149 - flip1995:rollup-6knpdqb, r=flip1995
Rollup of 2 pull requests

Successful merges:

 - #4102 (Fix match_same_arms to fail late)
 - #4119 (Improve non ascii literal)

Failed merges:

r? @ghost
2019-05-27 11:33:29 +00:00
Philipp Krones
dce670c73c
Rollup merge of #4119 - BO41:non_ascii_literal, r=flip1995
Improve non ascii literal

This PR improves the example of the [non_ascii_literal](https://rust-lang.github.io/rust-clippy/master/index.html#non_ascii_literal) lint.
It also makes it auto-fixable.

Please review. This is my first PR to this project.
(Thanks @flip1995 for the help :)

changelog: none
fixes #4117
2019-05-27 13:09:17 +02:00
Philipp Krones
f0a767352b
Rollup merge of #4102 - Urriel:fix/4096_match_same_arms, r=flip1995
Fix match_same_arms to fail late

Changes:
- Add a function search_same_list which return a list of matched expressions
- Change the match_same_arms implementation behavior. It will lint each same arms found.

fixes #4096

changelog: none
2019-05-27 13:09:16 +02:00
bors
cf81a3b6d0 Auto merge of #3832 - HarrisonMc555:use_last, r=flip1995
Implement "Use last" lint

Closes #3673

This lint checks the use of `x.get(x.len() - 1)` and suggests `x.last()` (where `x` is a `Vec`).

There's at least one more thing that needs to happen here. I believe I am correctly checking most of the scenarios and avoiding false positives. However, if different `Vec`s are used for the `x.get` and `y.len`, then it will emit a false positive. In other words, I need to check to make sure the `Vec`s are the same.

Also, a lot of these commits were temporary and not helpful to the project history...am I supposed to squash on merge? If so, how do I do that?

changelog: New lint: `get_last_with_len`
2019-05-27 11:04:38 +00:00
Andy Russell
effea41fe4
tweak let_and_return diagnostic
Label the unnecessary let binding and convert the note to structured
suggestion.
2019-05-24 14:52:55 -04:00
Philipp Hansch
aca56727db
Rustup to https://github.com/rust-lang/rust/pull/59545 2019-05-24 08:19:51 +02:00
Matthias Krüger
5d58163f7d trivially_copy_pass_by_ref: print size of type and limit in the lint message 2019-05-23 23:48:20 +02:00
Philipp Hansch
a316179850
Rustup to https://github.com/rust-lang/rust/pull/60965 2019-05-23 20:19:00 +02:00
Matthias Krüger
3d0795bb04 tests: update needless_bool test stderr
I'm getting a test failure otherwise with rust master (f688ba608923bdbf6b46ec65af2f6464b6233a75).
2019-05-23 17:03:59 +02:00
Vincent Dal Maso
40f36658f5 Fix breaking tests
Changes:
- Fix stderr breaking the tests
- Adding tests over the if arms
2019-05-21 13:08:19 +02:00
Vincent Dal Maso
fa9f744c2c Add the common case search
Changes:
- Refactor the common case search into a function.
- Fix the useless Option around the vec in the search_same_list.
2019-05-21 13:08:19 +02:00
Harrison McCullough
f32c2fcb7e Implement get_last_with_len lint 2019-05-20 18:01:21 -06:00
Philipp Hansch
3f382999ab
Lifetimes UI test cleanup
* Removes an unneeded `#![warn(clippy::extra_unused_lifetimes)]` from
  the `needless_lifetimes` test - the tests for those are in a different
  file.

* Renames `unused_lt.{rs,stderr}` to `extra_unused_lifetimes.{rs,stderr}`
* Renames `lifetimes.{rs,stderr}` to `needless_lifetimes.{rs,stderr}`
2019-05-20 19:19:49 +02:00
BO41
36c8aaba8f Fix tests and make other ascii lints auto-fixable 2019-05-20 16:02:50 +02:00
Oliver Scherer
efac2e5eff Revert "Turn off two tests broken due to #4108"
This reverts commit 568a3ecfc3.
2019-05-20 12:31:53 +02:00
bors
fd56381015 Auto merge of #4088 - pJunger:check1, r=oli-obk
Added lint for TryFrom for checked integer conversion.

works towards #3947

Added lint for try_from for checked integer conversion.
Should recognize simple & straight-forward checked integer conversions.
2019-05-20 09:31:09 +00:00
bors
0417a0ac4d Auto merge of #4107 - taiki-e:useless_attribute, r=flip1995
useless_attribute: Add unreachable_pub to whitelists

Fixes #4106

changelog: `useless_attribute`: whitelist `unreachable_pub` on `use` items
2019-05-19 10:37:09 +00:00
bors
4071b2996e Auto merge of #4099 - flip1995:ul_4094, r=oli-obk
Add macro check for unreadable_literal lint

Closes #4094

changelog: Disable `unreadable_literal` lint inside macros
2019-05-19 08:46:43 +00:00
pJunger
00a5ef64a2 Added suggestion for conversion with is_ok. 2019-05-18 09:33:26 +02:00
pJunger
47444c44ad Added lint for TryFrom for checked integer conversion rust-lang#3947. 2019-05-18 09:33:25 +02:00
Taiki Endo
40fc725298 useless_attribute: Add unreachable_pub to whitelists 2019-05-18 14:22:16 +09:00
Oliver Scherer
568a3ecfc3 Turn off two tests broken due to #4108 2019-05-18 00:57:23 +02:00
flip1995
08d2a0d6b2
Also rename the lint in test files 2019-05-16 20:18:07 +02:00
Vincent Dal Maso
bfb230369e Add test for multiple same arms lints
Changes:
- Add a test to match multiple arms in the same match statement
2019-05-16 14:13:57 +02:00
Michael Wright
4fcaab3d62 Split redundant_closure lint
Move the method checking into a new lint called
`redundant_closures_for_method_calls` and put it in the pedantic group.

This aspect of the lint seems more controversial than the rest.

cc #3942
2019-05-16 08:25:39 +02:00
flip1995
3543f58c84
Add macro check for unreadable_literal lint
Closes #4094
2019-05-15 14:57:56 +02:00
bors
82b2dfb9f6 Auto merge of #4095 - flip1995:mscn_test, r=phansch
Add test for #3198

Closes #3198

changelog: none
2019-05-14 12:02:22 +00:00
flip1995
861d233256
Add test for #3198 2019-05-14 13:46:10 +02:00
bors
501830bf01 Auto merge of #4084 - mikerite:fix-4019, r=oli-obk
Fix 4019

Fixes #4019
2019-05-14 11:26:16 +00:00
flip1995
a5bcaf538d
Add regression test for identity_conversion FP 2019-05-12 21:32:29 +02:00
bors
2122bdb94b Auto merge of #4087 - phansch:move_tests, r=matthiaskrgr
UI test cleanup: Extract many_single_char_names tests

changelog: none

cc #2038, #4086
2019-05-12 17:36:39 +00:00
Philipp Hansch
915ada04f5
UI test cleanup: Extract many_single_char_names tests 2019-05-12 18:40:32 +02:00
bors
e9b7a7125e Auto merge of #4085 - phansch:empty_loop_tests, r=matthiaskrgr
Add tests for empty_loop lint

changelog: none

Closes #4072
2019-05-12 13:50:57 +00:00
Philipp Hansch
9a24ab8466
Add tests for empty_loop lint 2019-05-12 13:07:58 +02:00
Michael Wright
e6e3f24e0c Fix #4019 2019-05-12 10:18:38 +02:00
Michael Wright
c44a882a84 Move ctor tests from methods.rs to or_fun_calls.rs 2019-05-12 09:32:39 +02:00
Manish Goregaokar
7eb8018554 Rename in_macro to in_macro_or_desugar 2019-05-11 21:39:02 -07:00
Manish Goregaokar
19cfb84405 Start handling desugarings in author lint 2019-05-10 23:43:58 -07:00
Manish Goregaokar
0499184201 Ignore desugarings in macro checks 2019-05-10 23:40:42 -07:00
Michael Wright
dcfe380de4 Remove unused attrs in while_let_on_iterator tests 2019-05-09 05:58:54 +02:00
Michael Wright
225f86f2c3 Fix while_let_on_iterator.stderr 2019-05-09 05:54:05 +02:00
Michael Wright
5149ed40a9 Rename while_loop tests to while_let_on_iterator 2019-05-08 09:30:17 +02:00
Michael Wright
1cb94a7e6c Split while_loop.rs tests
Split out while_let_loop tests into separate file.
Split ice-360 out into separate file.
2019-05-08 09:24:24 +02:00
Michael Wright
87f7eaa2c8 Add test for #771.
Closes #771
2019-05-07 06:28:51 +02:00
Michael Wright
a4bba694c0 Clean up while_loop tests
At some stage, we started adding test cases inside the function which tests
refutable patterns. This commits splits those test cases out into separate
functions.
2019-05-06 07:49:45 +02:00
bors
8b906f94f3 Auto merge of #4053 - euclio:too-many-args-span, r=flip1995
remove function body from "too many args" span

changelog: Remove the function body from the "too many arguments" span.
2019-05-03 07:26:55 +00:00
Andy Russell
9253506112
remove function body from "too many args" span 2019-05-02 10:36:59 -04:00
bors
8151a17422 Auto merge of #4049 - airt:fix-4033-search_is_some, r=flip1995
Fix #4033 search_is_some

Fixes #4033.

Suggest `any(|x| ..)` instead of `any(|&x| ..)` for `find(|&x| ..).is_some()` (Lint [search_is_some](https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some))

FnDecl of `find`:

```rust
fn find<P>(&mut self, mut p: P) -> Option<Self::Item> where
    P: FnMut(&Self::Item) -> bool
```

FnDecl of `any`:

```rust
fn any<F>(&mut self, mut f: F) -> bool where
    F: FnMut(Self::Item) -> bool
```

If match on `|&_|` in closure of `find`, only use `|_|` in the suggestion.

PS. It's the first time that I have used the `hir` API, please correct me if there is any mistake 😺
2019-05-02 08:45:02 +00:00
bors
1cf5d7f04c Auto merge of #4035 - JoshMcguigan:useless_let_if_seq-3043, r=oli-obk
useless_let_if_seq handle interior mutability

fixes #3043

This passes all tests, including a new one specifically dealing with a type with interior mutability. The main thing I'm unsure of is whether the span I used in the call to `is_freeze` is the most appropriate span to use, or if it matters.
2019-05-02 07:03:28 +00:00
Matthias Krüger
f195680edb more Use->DropTemps fixes 2019-05-01 23:04:35 +02:00
André Luis Leal Cardoso Junior
b411391f8e Add lints for find_map 2019-04-30 16:45:28 -03:00
airt
2d4d275519 change |&x| to |x| in stderr file 2019-05-01 01:06:15 +08:00
bors
f1eda09ea1 Auto merge of #4032 - phansch:add_tests, r=phansch
Add two more tests for redundant_closure

These two cases were fixed by #4008.

Closes #1439

changelog: none
2019-04-29 07:03:54 +00:00
Manish Goregaokar
770de14505 Suggest .copied() for map_clone on iterators too 2019-04-28 11:14:39 -07:00
Michael Wright
5ad79c2b3d Fix breakage due to rust-lang/rust#60225 2019-04-28 09:11:20 +02:00
Philipp Hansch
3f637cb369
Add two more tests for redundant_closure
These two cases were fixed by #4008.

Closes #1439

changelog: none
2019-04-26 06:48:27 +02:00
Josh Mcguigan
bb12d59551 cargo fmt 2019-04-25 19:41:23 -07:00
Josh Mcguigan
2bbe8be8d0 useless_let_if_seq handle interior mutability 2019-04-25 19:07:01 -07:00
bors
910d538ef1 Auto merge of #4008 - g-bartoszek:boxed-fnmut, r=phansch
Do not trigger redundant_closure for non-function types

fixes #3898

Added a check for the entity being called in the closure body to be a FnDef. This way lint does not trigger for ADTs (Box) but I'm not sure if it's correct and not too restrictive.

<!--
Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only updates to the latest nightly, you can leave the
`changelog` entry as `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.

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

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 -->

changelog: Fix false positive in `redundant_closure` pertaining to non-function types
2019-04-25 18:13:47 +00:00
bors
6a0105e59f Auto merge of #4026 - cemiloten:working-on-#3981, r=flip1995
Attempt to fix #3981

Fixes #3981

Hi, hopefully this is correct, happy to have feedback.

changelog: Don't trigger `unnecessary_cast` inside a macro
2019-04-25 10:37:30 +00:00
cemil
8eae2d3707 Ignore unnecessary cast if inside macro 2019-04-25 12:06:20 +02:00
bors
111cf2a067 Auto merge of #4023 - phansch:add_test, r=flip1995
Add test for or_fun_call macro suggestion

changelog: none

Closes #1018
2019-04-24 17:16:59 +00:00
bors
bcf0805614 Auto merge of #4022 - phansch:move_some_loop_tests, r=flip1995
UI test cleanup: Extract needless_range_loop tests

changelog: none
2019-04-24 08:29:33 +00:00
bors
253601a91c Auto merge of #4024 - kraai:suppress-let_and_return-if-let-has-attributes, r=flip1995
Suppress let_and_return if let has attributes

Fixes #3882.

changelog: suppress `let_and_return` if `let` has attributes
2019-04-24 07:29:35 +00:00
Matthew Kraai
c0479402e4 Suppress let_and_return if let has attributes
Fixes #3882.
2019-04-23 23:32:16 -07:00
Philipp Hansch
de24a74b45
Add test for or_fun_call macro suggestion
Closes #1018
2019-04-24 08:11:20 +02:00
Philipp Hansch
0fbe49d8a6
UI test cleanup: Extract needless_range_loop tests 2019-04-24 08:01:16 +02:00
Matthew Kraai
9a43e09d77 Change "if types change" to "if you later change the type"
Fixes #3964.
2019-04-23 16:53:09 -07:00
Manish Goregaokar
b03cf3ff97 Add test 2019-04-23 08:01:42 -07:00
Matthew Kraai
4171299632 Move path_buf_push_overwrite to nursery
See #4012.
2019-04-21 10:24:51 -07:00
Grzegorz
4f801a278d redundant closure triggers for fnptrs and closures 2019-04-20 22:20:14 +02:00
bors
65d88c7ba7 Auto merge of #4011 - phansch:add_test_for_derive_expansion, r=flip1995
Add test for derives for used_underscore_binding lint

This closes #852 as I can't reproduce the original issue anymore.

changelog: none
2019-04-20 18:55:48 +00:00
bors
54e80c7b34 Auto merge of #4007 - phansch:fix_allowing_toplevel_ref_arg, r=flip1995
Allow allowing of toplevel_ref_arg lint

I'm not sure why some lints need the `HirId` to be able to recognize the
lint level attributes, but this commit makes the lint level attributes
work for `toplevel_ref_arg`.

Fixes #2332

changelog: Allow allowing of `toplevel_ref_arg` lint
2019-04-20 18:22:53 +00:00
bors
fc1c2f5f1a Auto merge of #4005 - phansch:rustfix_match_as_ref, r=flip1995
Add run-rustfix for match_as_ref lint

* Extracts `match_as_ref` into separate file
* Adds `// run-rustfix` to `tests/ui/match_as_ref.rs`

cc #3630

changelog: none
2019-04-20 17:21:20 +00:00
bors
7a6d5c00d3 Auto merge of #4006 - phansch:fix_module_name_repetitions_fp, r=flip1995
Fix false positive in module_name_repetitions lint

This lint was triggering on modules inside expanded attrs, like
for example `#[cfg(test)]` and possibly more.

It was not reporting a location in #3892 because `span.lo()` and `span.hi()` both were 0.

Fixes #3892

changelog: Fix false positive in `module_name_repetitions` lint
2019-04-20 16:58:51 +00:00
Philipp Hansch
60a1759b5f
Add test for derives for used_underscore_binding lint
This closes #852 as I can't reproduce the original issue anymore.
2019-04-20 09:33:13 +02:00
Philipp Hansch
158aa39a7c
Allow allowing of toplevel_ref_arg lint
I'm not sure why some lints need the `HirId` to be able to recognize the
lint level attributes, but this commit makes the lint level attributes
work for `toplevel_ref_arg`.
2019-04-19 15:18:32 +02:00
Grzegorz
aa9cf07d56 redundant closure for functions restricted to FnDefs 2019-04-19 15:14:49 +02:00
Philipp Hansch
850c24edd3
Fix false positive in module_name_repetitions lint
This lint was triggering on modules inside expanded attrs, like
for example `#[cfg(test)]` and possibly more.
2019-04-19 12:53:03 +02:00
Philipp Hansch
9a6c82094f
Add run-rustfix for match_as_ref lint
* Extracts `match_as_ref` into separate file
* Adds `// run-rustfix` to `tests/ui/match_as_ref.rs`
2019-04-19 12:08:34 +02:00
bors
12e8075d91 Auto merge of #3989 - flip1995:assert_on_const, r=phansch
Don't trigger assertions_on_constants on debug_assert!(false)

Fixes #3948
Fixes #3765

changelog: Fix `debug_assert!` false positive on `assertions_on_constants` lint
2019-04-19 09:57:35 +00:00
bors
77fbdb6494 Auto merge of #3978 - phansch:rustfix_len_zero, r=flip1995
Add run-rustfix for len_zero lint

* Extracts len_without_is_empty into separate file
* Adds `// run-rustfix` to `tests/ui/len_zero.rs`

cc #3630
2019-04-18 21:18:23 +00:00
bors
c6e43b1ba7 Auto merge of #3954 - andrehjr:add-lint-path-buf-overwrite, r=flip1995
Add Lint PathBufPushOverwrite

Closes #3923

This is a very simple Lint that checks if push is being called with a Root Path. Because that can make it overwrite the previous path.

I used std::path::Path to check if it's root, in order to keep it working across windows/linux environments instead of checking for '/'. Is that alright?

On the `if_chain!` block, Is there a way to make it short while getting the value of the first argument? I got the example from other lints.

Note that this is first Lint, I hope I got everything covered  🚀
2019-04-18 11:29:43 +00:00
André Luis Leal Cardoso Junior
7e9cb5b84a Add lint PathBufPushOverwrite 2019-04-18 08:05:55 -03:00
bors
6feed2713c Auto merge of #3985 - phansch:move_some_cast_tests, r=flip1995
Move two cast_lossless tests to their correct files

First part of checking off the `tests/ui/cast.rs` checkbox in #3630.
2019-04-18 10:06:55 +00:00
flip1995
88359a136f
Update *.stderr file 2019-04-18 12:05:09 +02:00
flip1995
5b836e344c
Add test for debug_assert!(false) 2019-04-18 11:48:19 +02:00
bors
95e537b039 Auto merge of #3987 - phansch:rustfix_option_map_or_none, r=flip1995
Add run-rustfix for option_map_or_none lint

* Extracts `option_map_or_none` tests into separate file
 * Adds `// run-rustfix` to `tests/ui/option_map_or_none.rs`

cc #3630
2019-04-18 09:43:42 +00:00
Philipp Hansch
0f69aac3d9
Add run-rustfix for option_map_or_none lint 2019-04-18 08:12:59 +02:00
Philipp Hansch
8163a1a5f8
Move two cast_lossless tests to their correct files
First part of checking off the `tests/ui/cast.rs` checkbox in #3630.
2019-04-18 06:54:32 +02:00
Matthew Kraai
ef29db773e Add tests for declare_lint_pass and impl_lint_pass 2019-04-17 09:35:23 -07:00
bors
27d62cf603 Auto merge of #3966 - flip1995:internal_lints, r=oli-obk
Enable rustc internal lints

Closes #3965

I'm not 100% sure if enabling the `-Zunstable-options` flag in the `.cargo/config` file is the right place.
2019-04-17 04:46:19 +00:00
bors
ea25f044ec Auto merge of #3977 - phansch:add_rustfix_bool_comparison, r=flip1995
Add run-rustfix for bool_comparison lint

cc #3630
2019-04-17 02:35:02 +00:00
bors
1936368da1 Auto merge of #3976 - phansch:deref_addrof_rustfix, r=flip1995
Add run-rustfix for deref_addrof lint

* renames `tests/ui/reference.{rs,stderr}` to
  `tests/ui/deref_addrof.{rs,stderr}
* Moves small part of the testfile to a separate file as the lint
  triggered again on the fixed code (as intended)
* Adds `// run-rustfix` to `tests/ui/deref_addrof.rs`

cc #3630
2019-04-17 01:50:58 +00:00
Philipp Hansch
bae7d29dbe
Add run-rustfix for len_zero lint
* Extracts len_without_is_empty into separate file
* Adds `// run-rustfix` to `tests/ui/len_zero.rs`
2019-04-16 21:46:07 +02:00
Philipp Hansch
90ddf0da6c
Add run-rustfix for bool_comparison lint 2019-04-16 20:42:54 +02:00
Philipp Hansch
d1e84c615c
Add run-rustfix for deref_addrof lint
* renames `tests/ui/reference.{rs,stderr}` to
  `tests/ui/deref_addrof.{rs,stderr}
* Moves small part of the testfile to a separate file as the lint
  triggered again on the fixed code (as intended)
* Adds `// run-rustfix` to `tests/ui/deref_addrof.rs`
2019-04-16 20:32:54 +02:00
Manish Goregaokar
e9cde416ba Only suggest .copied() for Option right now 2019-04-15 15:44:09 -07:00
Manish Goregaokar
ad2c65bd1b Also suggest .copied() when .clone() is called on a Copy type 2019-04-15 14:39:41 -07:00
Manish Goregaokar
d2f7ae70ae Suggest .copied() instead of .cloned() in map_clone when dealing with references 2019-04-15 14:32:39 -07:00
flip1995
5361b842d1
Remove clippy::default_hash_types internal lint 2019-04-15 13:21:52 +02:00
Manish Goregaokar
1366b9516b Rust upgrade to rustc 1.35.0-nightly (00856722b 2019-04-13) 2019-04-13 18:57:16 -07:00
bors
d516925ec8 Auto merge of #3946 - rchaser53:issue-3920, r=flip1995
fix format does not parse escaped braces error

related: https://github.com/rust-lang/rust-clippy/issues/3920
2019-04-12 17:03:01 +00:00
rchaser53
db6ca9b8d3 fix format does not parse escaped braces error 2019-04-13 01:39:10 +09:00
Philipp Hansch
25e2affd31
UI test cleanup: Extract iter_nth tests 2019-04-11 08:23:43 +02:00
Philipp Hansch
fdc2255e81
UI test cleanup: Extract or_fun_call tests 2019-04-11 07:47:04 +02:00
bors
2278814c8e Auto merge of #3931 - phansch:3891, r=flip1995
Fix ICE in decimal_literal_representation lint

Handling the integer parsing properly instead of just unwrapping.

Note that the test is not catching the ICE because plain UI tests
[currently hide ICEs][compiletest_issue]. Once that issue is fixed, this
test would fail properly again.

Fixes #3891

[compiletest_issue]: https://github.com/laumann/compiletest-rs/issues/169
2019-04-10 20:57:15 +00:00
bors
3d469f436f Auto merge of #3933 - phansch:add_rustfix_eta, r=oli-obk
Add // run-rustfix for eta.rs test

cc #3071, #3630
2019-04-10 09:15:27 +00:00
Philipp Hansch
9e4e1302a6
Add // run-rustfix for eta.rs test
cc #3071, #3630
2019-04-10 08:16:07 +02:00
Philipp Hansch
2b0dc39f5b
Don't emit useless_attribute lint in external macros 2019-04-10 07:30:59 +02:00
bors
37f5c1ec73 Auto merge of #3925 - phansch:3741, r=flip1995
Fix ICE in suspicious_else_formatting

Fixes #3741
2019-04-09 07:13:08 +00:00
Philipp Hansch
0307ff020c
Fix ICE in decimal_literal_representation lint
Handling the integer parsing properly instead of just unwrapping.

Note that the test is not catching the ICE because plain UI tests
[currently hide ICEs][compiletest_issue]. Once that issue is fixed, this
test would fail properly again.

[compiletest_issue]: https://github.com/laumann/compiletest-rs/issues/169
2019-04-08 22:16:34 +02:00
Philipp Hansch
3ab8038450
Remove force-host and explain no-prefer-dynamic 2019-04-08 21:23:39 +02:00
Klemen Košir
560fd163d6
Escape a single quote in single_char_pattern hint 2019-04-08 21:55:50 +09:00
bors
4fdd113bed Auto merge of #3921 - euclio:single-char-names-multispan, r=flip1995
use a multispan for MANY_SINGLE_CHAR_NAMES
2019-04-08 08:42:13 +00:00
bors
e91ba8af85 Auto merge of #3848 - felix91gr:null_transmute, r=flip1995
Transmuting known null ptr to ref

Working on implementing #628
2019-04-08 07:20:25 +00:00
bors
42e1cf3763 Auto merge of #3901 - rail-rain:issue_1670, r=flip1995
Fix `explicit_counter_loop` suggestion

#1670

This code seems to me to work, but I have two question.
* Because range expression desugared in hir, `Sugg::hir` doesn't add parenthesis to range expression.  Which function is better to check range do you think, `check_for_loop_explicit_counter` or `hir_from_snippet`?
* Do you think we need to distinguish between range expression and struct expression that creates `std::ops::Range*`?
2019-04-08 06:28:15 +00:00
Philipp Hansch
60c1bb0546
Fix ICE in suspicious_else_formatting 2019-04-07 11:11:06 +02:00
Andy Russell
0d50d44ea6
use a multispan for MANY_SINGLE_CHAR_NAMES 2019-04-05 10:07:39 -04:00
Philipp Hansch
b545f1c3bb
Add missing // run-pass annotations to ICE tests
compiletest UI tests do not fail when encountering panics and ICEs
unless the `// run-pass` flag is used.

(This was forgotten in https://github.com/rust-lang/rust-clippy/pull/3743)
2019-04-05 07:22:36 +02:00
Félix Fischer
069957a8ad Add TransmutingNull Lint
* Late Lint pass, catches:
  * One liner: 0 -> null -> transmute
  * One liner: std:null() -> transmute
  * Const (which resolves to null) -> transmute
* UI Test case for Lint
* Updated test for issue 3849, because now the lint that code generated is in Clippy.
* Expanded `const.rs` miri-based Constant Folding code, to cover
  raw pointers
2019-04-02 11:39:43 -03:00
flip1995
41927796bf
Run rustfmt 2019-04-01 20:37:05 +02:00
Philipp Hansch
b253c564d5
Rustup to https://github.com/rust-lang/rust/pull/58805 2019-04-01 20:37:05 +02:00
flip1995
6f01ecfefd
Fix question_mark lint+test 2019-04-01 20:37:05 +02:00
rail
2b82c71b55 use span_lint_and_sugg in explicit_counter_loop 2019-03-28 08:51:57 +09:00
Oliver Scherer
d020565ed2 Hacky rustup 2019-03-26 10:55:03 +01:00
rail
9698e41994 Change explicit_counter_loop's message to add parentheses if necessary 2019-03-23 15:36:48 +09:00
rail
bd6c2df066 Change explicit_counter_loop's message to reflect original variable name 2019-03-23 15:30:17 +09:00
Philipp Hansch
0452704978
cargo fmt 2019-03-19 06:57:41 +01:00
Philipp Hansch
f1d0858a8f
Add rustfix tests for mistyped_literal_suffix lint
This moves all `mistyped_literal_suffix` tests to their own file and
enables rustfix tests for them.

cc #3603, #2038

Based on #3887
2019-03-19 06:55:42 +01:00
Philipp Hansch
4e51c980bc
Move some unreadable_literal ui tests to correct file
The moved tests were part of `tests/ui/literals.rs` before. Now they are
placed in `tests/ui/unreadable_literal.rs`, which now also runs
`rustfix` on these 4 extra let statements.
2019-03-19 06:55:42 +01:00
bors
54e20519d2 Auto merge of #3886 - phansch:rustfix_useless_asref, r=flip1995
Enable rustfix for `useless_asref` lint tests

cc #3630
2019-03-15 09:43:29 +00:00
Philipp Hansch
0019ca5e4f
Enable rustfix for useless_asref lint tests 2019-03-15 07:29:12 +01:00
bors
e7806413c6 Auto merge of #3883 - daxpedda:missing_docs_in_private_items, r=phansch
Add `doc(include = ...)` detection to `missing_docs_in_private_items`

The whole `missing documentation in crate` part doesn't have any tests. If I should add test cases tell me.
2019-03-15 06:18:28 +00:00
daxpedda
9061fd3199
Another test for missing crate documentation. 2019-03-14 19:38:41 +01:00
daxpedda
e1096e3310
Add a test for doc(include)
Tiny code improvement.
2019-03-14 19:33:06 +01:00
bors
bb41b16423 Auto merge of #3879 - phansch:rustfix_string_lit_as_bytes, r=flip1995
Run rustfix for string_lit_as_bytes tests

This moves the `string_lit_as_bytes` tests into a new file and enables
rustfix tests for them.

cc #3603, #2038
2019-03-14 17:29:19 +00:00
bors
9df38117d9 Auto merge of #3877 - rink1969:3842, r=flip1995
casting integer literal to float is unnecessary

fix issue https://github.com/rust-lang/rust-clippy/issues/3842
2019-03-14 16:32:15 +00:00
rink1969
d9dd008e44 casting integer literal to float is unnecessary 2019-03-14 15:53:08 +08:00
Philipp Hansch
5e4a7eb1fc
UI test cleanup: Extract manual_memcpy tests 2019-03-14 07:26:47 +01:00
Philipp Hansch
67aad6c180
Run rustfix for string_lit_as_bytes tests
This moves the `string_lit_as_bytes` tests into a new file and enables
rustfix tests for them.
2019-03-14 06:59:30 +01:00
bors
8fc0a738e3 Auto merge of #3869 - taiki-e:use_self, r=flip1995
Fix `use_self` false positive on nested functions

Related to https://github.com/rust-lang/rust-clippy/pull/3640

The current `use_self` warns the following code.

```rust
#![warn(clippy::use_self)]
struct Foo {}
impl Foo {
    fn bar() {
        fn baz() -> Foo { //^ warning: unnecessary structure name repetition
            Foo {} //^ warning: unnecessary structure name repetition
         }
    }
}
```
2019-03-12 12:09:56 +00:00
bors
3d31c2157a Auto merge of #3794 - mikerite:fix-3739, r=phansch
Fix `boxed_local` suggestion

Don't warn about an argument that is moved into a closure.

ExprUseVisitor doesn't walk into nested bodies so use a new
visitor that collects the variables that are moved into closures.

Fixes #3739
2019-03-12 07:43:14 +00:00
bors
75bfa29533 Auto merge of #3871 - taiki-e:needless_continue, r=phansch
Fix `needless_continue` false positive

If the `continue` has a label, check it matches the label of the loop.

Fixes https://github.com/rust-lang/rust-clippy/issues/2329
2019-03-12 07:04:44 +00:00
Michael Wright
6937d5581a Merge branch 'master' into fix-3739 2019-03-12 08:13:44 +02:00
Taiki Endo
1bc7da2fec Fix needless_continue false positive 2019-03-12 03:40:30 +09:00
Taiki Endo
187ce4c5ab Fix use_self false positive on nested functions 2019-03-11 23:24:49 +09:00
Taiki Endo
4896b259eb Filter out proc_macro and proc_macro_attribute 2019-03-11 20:45:57 +09:00
flip1995
44c46d2059
Run rustfmt 2019-03-10 22:12:26 +01:00
flip1995
3282955238
Update tests 2019-03-10 22:07:10 +01:00
Alexander Regueiro
a7c0800938 Reblessed test outputs. 2019-03-10 18:13:15 +00:00
Alexander Regueiro
d2b85323ad Addressed points raised in review. 2019-03-10 18:06:28 +00:00
Alexander Regueiro
d43966a176 Various cosmetic improvements. 2019-03-10 18:06:28 +00:00
Manish Goregaokar
038ec7f5d8 Move get_unwrap to restriction
fixes #3862
2019-03-09 13:48:06 -08:00
rchaser53
ae787d954e fix missing a semicolon 2019-03-07 23:26:47 +09:00
Michael Wright
7b948232ba Enable rustfix on unused_unit tests 2019-03-07 08:26:53 +02:00
Michael Wright
fbcf7eefb9 Add [rustfmt::skip] to unused_unit test 2019-03-07 08:13:59 +02:00
Michael Wright
131c8f6bf2 Add [rustfmt::skip] to doc_markdown tests 2019-03-07 08:03:15 +02:00
Félix Fischer
ddc718087f Renamed: Cyclomatic Complexity -> Cognitive Complexity
* Ran automatic naming update

* Formalized rename of `cyclomatic_complexity` to `cognitive_complexity`
** Added the rename to `lib.rs`
** Added rename test

* Added warning for deprecated key `cyclomatic_complexity_threshold` and tests for it

* Added deprecation status for Clippy's builtin attribute

* Updated tests for new builtin attribute renaming
2019-03-06 10:07:38 -03:00
Michael Wright
464ed58861 Ensure expect_fun_call bad suggestion is fixed
Closes #3839
2019-03-06 07:00:05 +02:00
Philipp Hansch
15cba2e956
Fix missing_const_for_fn for impl trait methods 2019-03-05 08:11:55 +01:00
Philipp Hansch
b87f5bc55a
Don't trigger missing_const_for_fn in external macros
As reported in #3841. Only fixes the part where it triggers on the
`derive`.
2019-03-04 22:56:33 +01:00
flip1995
c4eb780156
Add test for unknown Clippy attributes 2019-02-28 20:18:42 +01:00
Michael Wright
6e6e39b4a8 Add rustfmt::skip to double_parens tests 2019-02-28 08:02:45 +02:00
bors
ff2798840c Auto merge of #3666 - detrumi:map-or-on-non-copy, r=flip1995
Only suggest map_or for copy types

Fixes #2686
2019-02-27 08:28:48 +00:00
Michael Wright
11682b4cd2 Add rustfmt::skip to outer attr format tests 2019-02-27 07:41:07 +02:00
bors
6e8931c5f5 Auto merge of #3821 - g-bartoszek:redundant_closure-different-borrow-levels, r=oli-obk
do not trigger redundant_closure when there is a difference in borrow…

… level between closure parameter and "self", fixes  #3802
2019-02-26 17:30:48 +00:00
Wilco Kusee
eb70a72459
Fix false negative 2019-02-26 17:29:36 +01:00
Wilco Kusee
fec6e55d1d
Attempt to fix false negative 2019-02-26 17:27:41 +01:00
Wilco Kusee
54ab22f6db
Only suggest map_or for copy types 2019-02-26 17:27:40 +01:00
bors
0957f7d3b7 Auto merge of #3817 - rust-lang:fix-bool_comparison-on-non-bool, r=oli-obk
Fix `bool_comparison` with non-`bool` expressions

Fixes #3703.
It just moves around the type check that was already there for some comparison to all of them, because if one type isn't `bool`, none of those comparison can be simplified.
2019-02-26 15:51:40 +00:00
Grzegorz
a7f4d41a7d do not trigger redundant_closure when there is a difference in borrow level between closure parameter and "self" 2019-02-26 12:12:27 +01:00
Michael Wright
7fd0fbf435 Add [rustfmt::skip] to formatting lint tests 2019-02-26 07:49:46 +02:00
mcarton
c0c0686a65 Fix bool_comparison with non-bool expressions 2019-02-25 22:31:16 +01:00
bors
50d9473856 Auto merge of #3808 - mikerite:useless-format-suggestions, r=oli-obk
Fix `useless_format` suggestions
2019-02-25 16:21:26 +00:00