Commit graph

2476 commits

Author SHA1 Message Date
bors
a3fcaee562 Auto merge of #4473 - phansch:fix_cast_lossless_fp, r=flip1995
Fix cast_lossless false positive in impl const fn

Fixes https://github.com/rust-lang/rust-clippy/issues/3656#issuecomment-526387382

changelog: Fix false positive in `cast_lossless`
2019-08-30 20:30:53 +00:00
bors
2bff3d87d5 Auto merge of #4446 - mikerite:fix-4437, r=phansch
Fix `match_as_ref` bad suggestion

Fixes #4437

changelog: Fix `match_as_ref` bad suggestion
2019-08-30 06:07:41 +00:00
Philipp Hansch
fb1ae1747f
Fix cast_lossless false positive in impl const fn
Fixes https://github.com/rust-lang/rust-clippy/issues/3656#issuecomment-526387382
2019-08-30 07:22:35 +02:00
bors
28a8a6a483 Auto merge of #4450 - phansch:fix_const_fn_fp, r=flip1995
Fix missing_const_for_fn false positive

We don't want to lint if the type of the method implements drop.
(constant functions cannot evaluate destructors)

changelog: Fix `missing_const_for_fn` false positive

Fixes #4449
2019-08-29 17:24:21 +00:00
Philipp Hansch
5e1fdf9ae6
Add missing UI test change 2019-08-29 18:37:43 +02:00
flip1995
6bbf418747
Fix tests 2019-08-29 17:34:33 +02:00
BO41
945d4cf69f
Dereference one less on search_is_some and make it auto-fixable 2019-08-29 17:34:02 +02:00
bors
888b736560 Auto merge of #4408 - phansch:more_rustfix_tests, r=flip1995
More rustfix tests

<!--
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 `./util/dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

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

cc #3630

This is probably easier reviewed per-commit.

changelog: none
2019-08-29 10:48:14 +00:00
Victor Polevoy
87ef86ef5a Improve cognitive_complexity lint's warning.
Adds the value of complexity limit set for the lint
to the warning.

Fixes #4466

Signed-off-by: Victor Polevoy <fx@thefx.co>
2019-08-29 11:54:18 +02:00
Michael Wright
0c8332558b Merge branch 'master' into fix-4437 2019-08-29 08:17:36 +02:00
Philipp Hansch
1b18597554
Fix missing_const_for_fn false positive
We don't want to lint if any of the input parameters implement drop.

(constant functions cannot evaluate destructors)
2019-08-29 08:07:41 +02:00
Philipp Hansch
eeeadf30bf
Make useless_attribute suggestion MaybeIncorrect 2019-08-28 21:17:12 +02:00
Philipp Hansch
f41677902d
Update int_plus_one suggestion text
This is now in line with the recommendations from here:
https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.Diagnostic.html#method.span_suggestion
2019-08-28 07:29:30 +02:00
Philipp Hansch
8a161d71f8
Add run-rustfix for rename test
I removed the `Bar` static and `Foo` impl because they are not needed
for what's tested here as far as I can tell.
2019-08-28 07:23:23 +02:00
Philipp Hansch
dea92fada5
Add run-rustfix for outer_expn_data 2019-08-28 07:23:23 +02:00
Philipp Hansch
a3418933c6
Add run-rustfix for useless_attribute test 2019-08-28 07:23:23 +02:00
Philipp Hansch
b6e87c6ae3
Add run-rustfix for int_plus_one test 2019-08-28 07:23:23 +02:00
Philipp Hansch
cb341c8090
Add run-rustfix for assign_ops test 2019-08-28 07:23:23 +02:00
Yuki Okushi
1dca950ac4 Fix inherent_to_string false positive 2019-08-28 06:46:26 +09:00
flip1995
e7d8cf8511
Add test for external macro 2019-08-27 09:43:19 +02:00
bors
949b347f65 Auto merge of #4444 - phansch:split_up_cmp_owned2, r=flip1995
Split up cmp_owned tests, add run-rustfix

Some of the cmp_owned tests emitted non-machine-applicable suggestions,
so I moved them to `tests/ui/cmp_owned/without_suggestion.rs` and added
`// run-rustfix` to the other half.

changelog: none

cc #3630
2019-08-26 14:32:12 +00:00
bors
fea888f2ec Auto merge of #4445 - phansch:fix_unused_unit_sugg, r=flip1995
Fix unused_unit false positive

changelog: Fix `unused_unit` false positive

For some reason the `expr` of `stmt.node` didn't contain the expansion information, but the `stmt.span` does.

Fixes #4076
2019-08-26 13:29:01 +00:00
Philipp Hansch
6d425a60a7
Use correct path in comment
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2019-08-26 15:28:35 +02:00
bors
f760088820 Auto merge of #4430 - lzutao:defid_trait_alias, r=flip1995
Account for trait alias when looking for defid

I hit the crash on the `expect` call when running clippy on rustc libcore.
Hopefully this will fix it.
changelog: none
2019-08-26 12:46:00 +00:00
Lzu Tao
c222e7eca7
Add regression test for looking for trait defid in nocore 2019-08-26 14:45:28 +02:00
bors
b8e5e6f3c2 Auto merge of #4421 - lzutao:unsep_literal, r=flip1995
Cleaner code for unsep literals

Continuing discussion in https://github.com/rust-lang/rust-clippy/pull/4401#issuecomment-522498754
changelog: none
r? @flip1995
2019-08-26 10:32:24 +00:00
bors
7f15607e9a Auto merge of #4451 - hvenev:non-exec, r=flip1995
Mark rust source file as non-executable.

It would be nice if you can backport this to beta as well.

changelog: none
2019-08-26 09:53:34 +00:00
bors
d089032331 Auto merge of #4431 - phansch:more_rustfix, r=flip1995
Add 3 more run-rustfix headers

changelog: none

cc #3630
2019-08-26 09:15:20 +00:00
Lzu Tao
c1a4b26406 Cleaner code for unsep literals 2019-08-26 16:11:43 +07:00
flip1995
0fc8eaf294
Remove empty *.std{err,out} files 2019-08-26 10:22:34 +02:00
Hristo Venev
2a009b0ebf Mark rust source file as non-executable. 2019-08-25 17:49:45 +00:00
Michael Wright
23336adf84 Fix match_as_ref bad suggestion
Fixes #4437
2019-08-25 07:10:45 +02:00
Philipp Hansch
957dedb11d
Fix unused_unit false positive
Fixes #4076
2019-08-24 22:09:02 +02:00
Philipp Hansch
9a0b598b73
Split up cmp_owned tests, add run-rustfix
Some of the cmp_owned tests emitted non-machine-applicable suggestions,
so I moved them to `tests/ui/cmp_owned/without_suggestion.rs` and added
`// run-rustfix` to the other half.

cc #3630
2019-08-24 10:38:45 +02:00
Lzu Tao
f717a77ecc Re-add false positive check 2019-08-23 09:16:50 +00:00
Lzu Tao
ce2d2920ef Add raw string regression test for useless_format lint 2019-08-23 09:16:50 +00:00
Lzu Tao
09d302a786 Re-factor useless_format lint 2019-08-23 09:16:50 +00:00
Lzu Tao
4134e608c5 Update Unicode lint tests 2019-08-23 05:42:45 +00:00
Philipp Hansch
55aa9d2767
Add run-rustfix for range_plus_minus_one tests 2019-08-22 07:47:30 +02:00
Philipp Hansch
18fb1d9d2f
Add run-rustfix for or_fun_call tests 2019-08-22 07:41:00 +02:00
Philipp Hansch
9bda1e2264
Add run-rustfix for short_circuit_statement test 2019-08-22 07:21:29 +02:00
bors
57c67a29d2 Auto merge of #4352 - phansch:fix_redundant_pattern_matching, r=flip1995
Fix some suggestions for redundant_pattern_matching

.. and change the Applicability to `MaybeIncorrect`.

Fixes the problem displayed in https://github.com/rust-lang/rust-clippy/issues/4344#issuecomment-519206388.

We now append `{}` to the suggestion so that the conditional has the
correct syntax again.

(If we were to _remove_ the `if` instead, it would trigger the
`unused_must_use` warning for `#[must_use]` types.)

changelog: Fix some suggestions for `redundant_pattern_matching`
2019-08-21 08:15:36 +00:00
Philipp Hansch
436d429d27
Add two more tests, allow 2 other lints. 2019-08-21 07:43:42 +02:00
Michael Wright
59893bcab0 Fix temporary_cstring_as_ptr false negative
Fixes #4375.

Changes the check to test when `.unwrap().as_ptr()` is called on any
`Result<CString, _>` as suggested by @flip1995
(https://github.com/rust-lang/rust-clippy/issues/4375#issuecomment-520724123).
2019-08-21 07:35:04 +02:00
Philipp Hansch
84716e49f0
Add more testcases for redundant_pattern_matching
These should make sure that, when the suggestions are fixed, they are
fixed for all these cases.
2019-08-21 07:29:44 +02:00
Philipp Hansch
0d85d7e60f
Fix suggestions for redundant_pattern_matching
Fixes the problem displayed in https://github.com/rust-lang/rust-clippy/issues/4344#issuecomment-519206388.

We now append `{}` to the suggestion so that the conditional has the
correct syntax again.

(If we were to _remove_ the `if` instead, it would trigger the
`unused_must_use` warning for `#[must_use]` types.
2019-08-21 07:29:44 +02:00
Lzu Tao
2a66196013 Remove feature gate for async_await 2019-08-20 23:21:39 +00:00
bors
835205b8da Auto merge of #4401 - JJJollyjim:literal-separation-suggestion, r=flip1995
Add autofixable suggestion for unseparated integer literal suffixes

changelog: Add autofixable suggestion for unseparated integer literal suffixes

Somewhat WIP, since I haven't been able to get this working when adding `// run-rustfix` to `ui/literals.rs`. I think the issue is that there are multiple suggestions operating on one numerical literal, and I'm not sure what the best approach is to work around that.

Thanks
2019-08-20 07:54:25 +00:00
Jamie McClymont
370433f633 Requested test cleanup 2019-08-19 20:22:42 +12:00
bors
5c71c1b838 Auto merge of #4411 - mikerite:fix-4384, r=flip1995
Fix `clone_on_copy` false positives

Closes #4384

changelog: Fix `clone_on_copy` false positives
2019-08-19 08:04:12 +00:00
Michael Wright
68a1af540c Fix clone_on_copy false positives
Closes #4384
2019-08-19 08:19:54 +02:00
Lzu Tao
41eba2f26a Add test 2019-08-19 05:41:47 +00:00
Lzu Tao
50ecd595a6 Allow option_and_then_some in option_map_or_none test 2019-08-19 03:54:40 +00:00
Lzu Tao
7065239da5 Add option_and_then_some lint 2019-08-19 03:54:40 +00:00
Jamie McClymont
802a6d33da run-rustfix for unseparated-prefix-literals 2019-08-19 02:58:58 +12:00
Jeremy Stucki
9c39c02b75
Change lint type to 'complexity' 2019-08-18 16:49:11 +02:00
Jamie McClymont
c8fb62148e Add autofixable suggestion for unseparated integer literal suffices 2019-08-19 02:46:12 +12:00
Jeremy Stucki
5df84f2192
Merge branch 'origin/master' into suspicious_map 2019-08-18 16:37:31 +02:00
KRAAI, MATTHEW [VISUS]
f74d9db7f4 Use outer_expn_data instead of outer_expn_info 2019-08-16 09:31:12 -07:00
Jeremy Stucki
72e4e4ac6c
Add ui test 2019-08-15 22:58:32 +02:00
bors
607b8299c5 Auto merge of #4382 - jeremystucki:unnecessary_fold_span, r=flip1995
Change span of unnecessary_fold lint

Resolves #4381

changelog: Change linted span of `unnecessary_fold`
2019-08-15 12:57:51 +00:00
bors
a3da66d6d3 Auto merge of #4348 - phansch:deprecate-unused-unused-collect, r=flip1995
Deprecate unused_collect lint

I found this because we only had two test cases in total for this lint.
It turns out the functionality is fully covered by rustc these days.

[Playground Examples](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=eb8ee6db389c77180c9fb152d3c608f4)

changelog: Deprecate `unused_collect` lint. This is fully covered by rustc's `#[must_use]` on `collect`

cc #2846
2019-08-15 10:47:20 +00:00
flip1995
87fa2d90f5
Rustup to rust-lang/rust#62984
Lint redundant_semicolon was added to rustc
2019-08-15 10:14:06 +02:00
flip1995
e1d573c242
Rustup to rust-lang/rust#62672
try macro is deprecated now, so Clippy will drop the support for it also
2019-08-15 10:14:06 +02:00
Philipp Hansch
42f03539ca
Deprecate unused_collect lint
I found this because we only had two test cases in total for this lint.
It turns out the functionality is fully covered by rustc these days.

[Playground Examples](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=eb8ee6db389c77180c9fb152d3c608f4)

changelog: Deprecate `unused_collect` lint. This is fully covered by
rustc's `#[must_use]` on `collect`

cc #2846
2019-08-14 21:47:11 +02:00
Jeremy Stucki
4366137d2e
Update tests 2019-08-14 19:35:17 +02:00
Jeremy Stucki
214d499103
Add multiline test 2019-08-14 19:34:50 +02:00
bors
06430e7af4 Auto merge of #4363 - phansch:fix_lint_deprecation, r=flip1995
Update lint deprecation for tool lints

changelog: Allow tool lints (`clippy::*`) to be deprecated

Our lint deprecation previously didn't work for tool lints, because
`register_removed` was registering lints to be removed _without_ the
`clippy` prefix.

Fixes #4349
2019-08-14 11:37:10 +00:00
bors
63d2d066f9 Auto merge of #4369 - mikerite:fix-4293, r=flip1995
Fix `wrong_self_convention` issue

Resolves #4293

changelog: Fix `wrong_self_convention` issue
2019-08-14 10:59:36 +00:00
bors
4f8bdf3587 Auto merge of #4231 - jeremystucki:flat-map, r=flip1995
Implement flat_map lint

Fixes #4224

changelog: New Lint `flat_map_identity` to detect unnecessary calls to `flat_map`
2019-08-14 09:36:16 +00:00
flip1995
17808c7d00
Update ui-toml tests 2019-08-14 09:58:00 +02:00
Jeremy Stucki
2bfcf89f82
Merge branch 'origin/master' into flat-map 2019-08-14 07:36:37 +02:00
Jeremy Stucki
2fe5e2cea9
Update test 2019-08-13 21:50:52 +02:00
Jeremy Stucki
6a263c0816
Add 'unnecessary_flat_map.fixed' 2019-08-13 08:03:04 +02:00
Jeremy Stucki
d51136d594
Use 'span_lint_and_sugg' 2019-08-12 21:42:57 +02:00
Philipp Hansch
e406ab5117
Add deprecation tests for deprecated tool lints 2019-08-12 19:42:23 +02:00
Philipp Hansch
0d0db5ed5f
Move old lint deprecation tests to deprecated_old.rs 2019-08-12 19:42:23 +02:00
Philipp Hansch
0b7e2376c8
Keep old deprecated lints deprecated as non-tool, too 2019-08-12 19:42:23 +02:00
Philipp Hansch
5114050839
Update lint deprecation for tool lints
Our lint deprecation previously didn't work for tool lints, because
`register_removed` was registering lints to be removed _without_ the
`clippy` prefix.
2019-08-12 19:20:36 +02:00
bors
e255f36afe Auto merge of #4365 - lukas-code:async_new_ret_no_self, r=flip1995
new_ret_no_self: allow Self in inner type for impl Trait return types

Check the inner types of associated types of a trait when checking for Self in the return type of a `new` method. This means that the following will no longer warn:
```rust
trait Trait {
    type Inner;
}

struct S;

impl S {
    fn new() -> impl Trait<Inner = Option<Self>> {
        struct TraitImpl;

        impl Trait for TraitImpl {
            type Inner = Option<S>;
        }

        TraitImpl
    }
}
```
```rust
#![feature(async_await)]

struct Connection;

impl Connection {
    async fn new() -> Result<Self, ()> {
        Ok(S)
    }
}
```
closes #4359

changelog: fix `new_ret_no_self` lint for async `new` functions.
2019-08-12 05:15:16 +00:00
Jeremy Stucki
b651f19eb8
Rename 'flat_map' → 'flat_map_identity' 2019-08-11 20:34:25 +02:00
Jeremy Stucki
f0ce04f814
Handle calls with 'std::convert::identity' 2019-08-11 19:51:43 +02:00
Jeremy Stucki
05d9f884e1
Merge branch 'origin/master' into flat-map 2019-08-11 19:22:40 +02:00
Ralf Jung
2dcce60fdc deprecate invalid_ref lint 2019-08-11 09:31:55 +02:00
Michael Wright
77278ccda9 Fix wrong_self_convention issue
Resolves #4293
2019-08-10 06:01:15 +02:00
Lukas Markeffsky
d55315808d fixed tests (again) and added a test that should actually cause a warning for new_ret_no_self 2019-08-09 23:15:49 +02:00
Lukas Markeffsky
54efffcec1 removed unused imports #2 2019-08-09 19:47:25 +02:00
Lukas Markeffsky
1d2c23a2a5 removed unused imports 2019-08-09 19:44:20 +02:00
Lukas Markeffsky
4fbe9f67ee upgrade test to rust 2018 2019-08-09 19:19:49 +02:00
Lukas Markeffsky
d7b9a845aa new_ret_no_self: walk associated types in impl Trait return types 2019-08-09 17:44:05 +02:00
bors
c55d38ed7a Auto merge of #4362 - lzutao:expect-on-cstring_as_ptr, r=flip1995
Fix lint_cstring_as_ptr for expect

Closes #4312
changelog: none
2019-08-09 09:22:02 +00:00
Lzu Tao
b825cddb6d Add more tests for raw string literal 2019-08-09 06:22:26 +00:00
Lzu Tao
c23a5c586f Fix lint_cstring_as_ptr for expect 2019-08-09 12:39:33 +07:00
Lzu Tao
30cbdc7491 Fix lint_single_char_pattern on raw string literal 2019-08-09 10:55:30 +07:00
bors
4465e2fbb8 Auto merge of #4355 - lzutao:macro_expn_try_err, r=flip1995
Fix macro expansion in try_err lint

Fixes #4309

changelog: none
2019-08-08 15:16:17 +00:00
Lzu Tao
0487b58f9a Fix macro expansion in try_err lint 2019-08-08 20:22:52 +07:00
bors
e76ef1db03 Auto merge of #4339 - phansch:rustfix_needless_bool, r=flip1995
Add run-rustfix for needless_bool lint

This splits up the needless_bool tests into `fixable.rs` and
`simple.rs`. `simple.rs` contains the code that triggers the lint
diagnostic without a suggestion.

changelog: none

cc #3630
2019-08-07 11:00:09 +00:00
Philipp Hansch
0a988c6630
Don't emit enum_variant_names if remainder starts with a numeric
As [per the reference](https://doc.rust-lang.org/reference/identifiers.html),
identifiers must start with a letter. So we don't suggest a better
variant naming in these cases.

Fixes #739
2019-08-06 20:45:36 +02:00
Philipp Hansch
39c8f84f3b
Add run-rustfix for needless_bool lint
This splits up the needless_bool tests into `fixable.rs` and
`simple.rs`. `simple.rs` contains the code that triggers the lint
diagnostic without a suggestion.
2019-08-05 22:10:56 +02:00
Philipp Hansch
4cfb0966a1
Fix needless_bool suggestion with if-else-if-else
Closes #4334
2019-08-05 20:52:38 +02:00