Commit graph

2986 commits

Author SHA1 Message Date
Jeremy Stucki
3fc1ec1ffd
Refactor option handling 2019-09-04 16:19:59 +02:00
bors
9d2772207e Auto merge of #4418 - euclio:byte-lit-suggestion, r=flip1995
use a structured suggestion for char-lit-as-u8

changelog: use a structured suggestion for char-lit-as-u8
2019-09-04 13:33:47 +00:00
Andy Russell
4ea246b0b3
use a structured suggestion for char-lit-as-u8 2019-09-04 08:50:55 -04:00
bors
ffe57fad85 Auto merge of #4498 - sinkuu:checked_arithmetic_unwrap, r=flip1995
Add manual_saturating_arithmetic lint

changelog: add `manual_saturating_arithmetic` lint

Fixes #1557. This lint detects manual saturating arithmetics like `x.checked_add(10u32).unwrap_or(u32::max_value())` and suggests replacing with `x.saturating_add(10u32)`.
2019-09-04 12:14:41 +00:00
Shotaro Yamada
c6fb9c8a2a Hide variables in doc-test 2019-09-04 21:10:08 +09:00
Shotaro Yamada
45fde0f86f Fix doctest and renaming src 2019-09-04 21:06:28 +09:00
bors
a2c4b2b8da Auto merge of #4490 - mikerite:fix-4364, r=flip1995
Fix `too_many_lines` false positive

changelog: Fix `too_many_lines` false positive
2019-09-04 11:35:13 +00:00
Shotaro Yamada
4960f79476 Add manual_saturating_arithmetic lint 2019-09-04 18:38:25 +09:00
bors
8239b7616f Auto merge of #4454 - BO41:search_is_some, r=flip1995
Dereference one less on search_is_some and make it auto-fixable

Fixes #4453

changelog: none
2019-09-04 07:53:44 +00:00
BO41
64cd9e4d60 Try to fix .fixed 2019-09-03 18:56:23 +02:00
bors
11da8c18a2 Auto merge of #4479 - rust-lang:uninit_assume_init, r=flip1995
lint against `MaybeUninit::uninit().assume_init()`

changelog: add `uninit_assumed_init` lint

This fixes #4272
2019-09-03 16:14:40 +00:00
Andre Bogus
b01f2d1126 lint against MaybeUninit::uninit().assume_init() 2019-09-03 17:37:38 +02:00
bors
aeadf1562c Auto merge of #4486 - lzutao:fix-panic-unseparate-literals, r=flip1995
Fix index out of bound in case of empty snippet

cc #4480

changelog: none
2019-09-03 13:17:30 +00:00
Yuki Okushi
c94c5e9048 Fix map_entry false positive 2019-09-03 20:31:02 +09:00
bors
2d7da04e17 Auto merge of #4493 - JohnTitor:fix-build-bytes, r=flip1995
Rustup to rust-lang/rust#63561

changelog: none
2019-09-03 10:44:47 +00:00
Yuki Okushi
7d30cb6e76 Remove Allocation::bytes 2019-09-03 18:29:08 +09:00
Michael Wright
232dd43fe9 Fix occurrences of too_many_lines violations 2019-09-03 06:26:49 +02:00
Michael Wright
0ae1a69330 Fix too_many_lines false positive
Fixes #4364
2019-09-03 06:25:54 +02:00
Yuki Okushi
9a5b996228 Allow deref_addrof in macros 2019-09-03 00:17:23 +09:00
Lzu Tao
17d445b66d Fix index out of bound in case of empty snippet 2019-09-02 20:38:40 +07:00
bors
1f9993729b Auto merge of #4482 - awoimbee:doc_explicit_counter_loop, r=flip1995
fix misleading doc for explicit_counter_loop lint

changelog: replace misleading examples for explicit_counter_loop & more concise `Why is it bad?` section

This fixes #4472
2019-09-02 12:46:13 +00:00
Arthur Woimée
223e23a5ce fix misleading doc for explicit_counter_loop lint 2019-09-01 21:54:47 +02:00
Michael Wright
2fdfd60569 Fix needless_lifetimes false positive 2019-09-01 08:11:40 +02:00
Cristian Kubis
8bc1ded805 Fix incorrect swap suggestion
Clippy suggests using swap on fields belonging to the same owner
causing two mutable borrows of the owner

Fixes #981

Signed-off-by: Cristian Kubis <cristian.kubis@tsunix.de>
2019-08-31 18:53:14 +02:00
Michael Wright
88750f9ad7 Fix extra_unused_lifetimes false positive
Fixes #4291
2019-08-31 08:16:04 +02:00
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
flip1995
3c11406c1f
Rustup to rust-lang/rust#60966 2019-08-30 10:11:27 +02: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
flip1995
dac81d867b
Use the spans returned by utils::method_calls 2019-08-29 17:34:03 +02:00
flip1995
832c0830ec
Also return the method spans in utils::method_calls 2019-08-29 17:34:02 +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 Krones
236666138f
Rollup merge of #4460 - JohnTitor:fix-inherent-to-string, r=flip1995
Fix `inherent_to_string` false positive

Fixes #4457

changelog: fixes `inherent_to_string` false positive
2019-08-28 13:00:52 +02:00
Yuki Okushi
2c282252a9 Replace Arg with Param 2019-08-28 18:33:25 +09: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
31cf2f2f35
Change float_cmp Applicability to HasPlaceholders
The suggestion includes an 'errors' placeholder currently, so it's not
`MachineApplicable`
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
d36c785344
Allow block_in_if_{stmt,expr} in external macro 2019-08-27 09:43:03 +02: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
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
bors
ba6681300e Auto merge of #4436 - BO41:written_as, r=phansch
Add some "could be written as" examples

fixes #4405
changelog: none
2019-08-26 11:11:57 +00:00
Lzu Tao
c1a4b26406 Cleaner code for unsep literals 2019-08-26 16:11:43 +07:00
Lzu Tao
dac2509bac Account for trait alias when looking for defid 2019-08-25 20:36:11 +07:00
Philipp Hansch
818b2ccfc5
Rustup to https://github.com/rust-lang/rust/pull/63854 2019-08-25 08:06:32 +02: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
BO41
31a6ab47e1 Fix lint doc 2019-08-24 13:57:25 +02:00
bors
2bcb615594 Auto merge of #4443 - jeremystucki:methods-refactoring, r=phansch
Small refactoring of methods/mod.rs

changelog: none
2019-08-24 07:45:29 +00:00
Jeremy Stucki
2da8288433
Refactor some minor things 2019-08-23 22:52:04 +02:00
Jeremy Stucki
907aebcf8b
Use more if-chains 2019-08-23 22:51:44 +02:00
Jeremy Stucki
4130dfba2e
Refactor 'lint_or_fun_call' 2019-08-23 22:31:22 +02:00
Jeremy Stucki
419c87fb35
Refactor 'check_unwrap_or_default' 2019-08-23 14:36:00 +02:00
Jeremy Stucki
1436fea271
Refactor 'check_impl_item' 2019-08-23 14:20:55 +02:00
Lzu Tao
5b367ed4a3 Add missing field to LitKind::Str 2019-08-23 18:02:13 +07: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
BO41
eebb7cd839 Add examples to some complexity lints 2019-08-22 15:41:07 +02:00
BO41
3f56cb5d8b Add example to a perf lint 2019-08-22 15:41:07 +02:00
BO41
43a2ba34e6 Add examples to some correctness lints 2019-08-22 15:41:07 +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
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
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
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
Philipp Hansch
1055cf5b9f
Merge pull request #4416 from SimonSapin/plugin
Import rustc_plugin from its new location
2019-08-20 07:28:59 +02:00
KRAAI, MATTHEW [VISUS]
eaf8f08390 Restore en dashes 2019-08-19 12:38:33 -07:00
KRAAI, MATTHEW [VISUS]
204b2f3658 Remove in_macro_or_desugar 2019-08-19 09:30:32 -07:00
Simon Sapin
08d8ffc6a9 Import rustc_plugin from its new location
Depends on https://github.com/rust-lang/rust/pull/62727
2019-08-19 17:52:10 +02: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
bors
d1f1844f46 Auto merge of #4386 - lzutao:lint-option-and_then-some, r=flip1995
Add option_and_then_some lint

changelog: Add complexity lint to warn about `option.and_then(|o| Some(x))` and suggest replacing with `option.map(|o| x)`.

Closes #4299
2019-08-19 07:35:53 +00:00
Michael Wright
68a1af540c Fix clone_on_copy false positives
Closes #4384
2019-08-19 08:19:54 +02:00
Matthias Krüger
88f417e446 try to fix build in rustc repo 2019-08-19 06:10:00 +02:00
Lzu Tao
7065239da5 Add option_and_then_some lint 2019-08-19 03:54:40 +00:00
Jamie McClymont
4ee9d02efa Requested changes 2019-08-19 14:20:38 +12:00
bors
f01a0c0e08 Auto merge of #4403 - xd009642:type_repetition_improvements, r=phansch,flip1995
Improvements to `type_repetition_in_bounds`

Improvements to the `type_repetition_in_bounds` trait based on feedback from #4380 #4326 #4323

Currently just make it pedantic. Hopefully, more to come

changelog: move `type_repetition_in_bounds` to `pedantic`
2019-08-18 21:03:21 +00:00
bors
6668e629ba Auto merge of #4404 - BO41:patch-1, r=flip1995
Add "could be written as" example to MANUAL_MEMCPY

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

changelog: none
2019-08-18 20:34:25 +00:00
xd009642
76598adafb Run update_lints 2019-08-18 16:59:31 +01: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
Michael Wright
b313d25350 Fix breakage due to rust-lang/rust#61708 2019-08-18 13:14:47 +02:00
Lzu Tao
533bdfbdbc Fix assertions_on_constants lint 2019-08-18 02:34:30 +07:00
Lzu Tao
439284b584 Make code cleaner and more readable 2019-08-18 01:47:45 +07:00
BO41
b17cb32bcb
Add "could be written as" example to MANUAL_MEMCPY 2019-08-17 13:09:03 +00:00
xd009642
c1e57402d3 Made lint pedantic 2019-08-17 11:45:05 +01:00
bors
49dff2c9f3 Auto merge of #4397 - kraai:remove-a, r=flip1995
Remove "a" from single_match_else description

changelog: none
2019-08-16 20:04:39 +00:00
flip1995
2456b355f2
Run rustfmt 2019-08-16 19:05:44 +02:00
KRAAI, MATTHEW [VISUS]
f74d9db7f4 Use outer_expn_data instead of outer_expn_info 2019-08-16 09:31:12 -07:00
KRAAI, MATTHEW [VISUS]
a68abc03a2 Remove "a" from single_match_else description 2019-08-16 05:41:35 -07:00
Lzu Tao
65b906a8fc Rustup "Remove Spanned from {ast,hir}::FieldPat" 2019-08-16 09:32:27 +07:00
Jeremy Stucki
f4f31a4ff4
Implement lint 'suspicious_map' 2019-08-15 22:58:32 +02:00
flip1995
ebd3eeaede
Also specify patch version of toml crate 2019-08-15 15:58:36 +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