Commit graph

2161 commits

Author SHA1 Message Date
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
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
bors
9897442f27 Auto merge of #4018 - rust-lang:or_fn_call_variants, r=oli-obk
Ignore non-const ctor expressions in or_fn_call

Fixes https://github.com/rust-lang/rust-clippy/issues/1338

Should have been fixed by #919, however that focuses on const ctor expressions only, and `.or(Some(local))` isn't const.

This also automatically ignores things like `.or(Some(local.clone())` which we don't actually want to do; I need to figure out what to do here.

changelog: Fixed false positive in [`or_fn_call`] pertaining to enum variant constructors

r? @oli-obk @phansch
2019-04-23 18:24:10 +00:00
Manish Goregaokar
b03cf3ff97 Add test 2019-04-23 08:01:42 -07:00
Igor Matuszewski
56389f36a3 compiletest: Disambiguate extern crate deps shared with the compiler 2019-04-23 10:32:41 +02: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