Commit graph

4020 commits

Author SHA1 Message Date
Yuki Okushi
9fd8e1088f Return early to avoid ICE 2020-05-30 18:48:54 +09:00
flip1995
a0e9f9bd0d Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2 2020-05-28 15:45:24 +02:00
Eduardo Broto
64a05f56c3 len_zero: skip ranges if feature range_is_empty is not enabled 2020-05-28 00:58:48 +02:00
bors
ee3088f27b Auto merge of #5631 - ThibsG:ExtendUselessConversion, r=matthiaskrgr
Extend useless conversion

This PR extends `useless_conversion` lint with `TryFrom` and `TryInto`

fixes: #5344

changelog: Extend `useless_conversion` with `TryFrom` and `TryInto`
2020-05-27 13:06:59 +00:00
Eduardo Broto
4161823475 Avoid triggering similar names on code from expansion 2020-05-27 00:06:50 +02:00
flip1995
04db13eb56 Fix fallout in similar_names 2020-05-26 21:41:51 +02:00
flip1995
8e22d15055 Fix fallout in redundant_field_names 2020-05-26 21:41:51 +02:00
flip1995
7fd3bd0f57 Register redundant_field_names and non_expressive_names as early passes 2020-05-26 21:41:51 +02:00
ThibsG
1801841ae5 Add test cases for broader coverage 2020-05-26 18:43:12 +02:00
bors
291385b3e0 Auto merge of #5609 - phansch:empty-line-after-outer-attr-fix, r=flip1995
Make empty_line_after_outer_attr an early lint

Fixes #5567

Unfortunately I couldn't find a way to reproduce the issue without syn/quote. Considering that most real-world macros use syn and/or quote, I think it's okay to pull them in anyway.

changelog: Fix false positive in [`empty_line_after_outer_attr`]
2020-05-26 15:10:35 +00:00
Philipp Hansch
fd86b3150e
Be less specific about quote and syn versions 2020-05-26 16:52:02 +02:00
Philipp Hansch
cdff59e156
Using dev-dependencies doesn't seem to work w/ compiletest 2020-05-26 16:52:02 +02:00
Philipp Hansch
e3f6a8fc20
Specify quote and syn versions 2020-05-26 16:52:02 +02:00
Philipp Hansch
67167be167
Make empty_line_after_outer_attr an early lint 2020-05-26 16:52:02 +02:00
bors
a00025ab21 Auto merge of #5638 - ebroto:issue_5628_add_suggestion_for_reversed_empty_ranges, r=phansch
reversed_empty_ranges: add suggestion for &slice[N..N]

As discussed in the issue thread, the user accepted this solution. Let me know if this is what we want, or if changing the way we lint the N..N case is prefered.

changelog: reversed_empty_ranges: add suggestion for &slice[N..N]

Closes #5628
2020-05-26 11:56:16 +00:00
bors
182ac89f16 Auto merge of #5636 - ebroto:issue_5041, r=phansch
multiple_crate_versions: skip dev and build deps

changelog: multiple_crate_versions: skip dev and build deps

Closes #5041
2020-05-26 06:23:58 +00:00
bors
2a6cfa7f05 Auto merge of #5647 - ebroto:5644_allow_ptr_arg_in_arg_position, r=flip1995
ptr_arg: honor `allow` attribute on arguments

The `intravisit::Visitor` impl for `LateContextAndPass` only takes into account the attributes of a function parameter inside the `check_param` method. `ptr_arg` starts its heuristics at `check_item` / `check_impl_item` / `check_trait_item`, so the `allow` is not taken into account automatically.

changelog: ptr_arg: honor `allow` attribute on arguments

Fixes #5644
2020-05-25 21:47:07 +00:00
Eduardo Broto
a1824e187c ptr_arg: honor allow attr on arguments 2020-05-25 23:09:06 +02:00
Jeremy Stucki
bcfeb4de15
Fix build 2020-05-25 21:41:20 +02:00
Jeremy Stucki
566377f627
Ignore calls to 'len' 2020-05-25 21:41:20 +02:00
Eduardo Broto
60d38ee1dd reversed_empty_ranges: add suggestion for &slice[N..N] 2020-05-25 20:06:15 +02:00
ThibsG
705bfdcc46 Extend useless_conversion lint with TryInto 2020-05-25 20:00:39 +02:00
ThibsG
4f8909fad9 Extend useless_conversion lint with TryFrom 2020-05-25 20:00:39 +02:00
Eduardo Broto
ec0a00e539 Use find_map instead of find() + map() 2020-05-25 20:00:08 +02:00
Eduardo Broto
8642fc97dd multiple_crate_versions: skip dev and build deps 2020-05-25 20:00:08 +02:00
bors
c41916d9bd Auto merge of #5616 - euclio:no-derive-suggestion, r=phansch,flip1995
new_without_default: do not suggest deriving

---

changelog: do not suggest deriving `Default` in `new_without_default`

This commit changes the behavior of the `new_without_default` lint to not suggest deriving `Default`. This suggestion is misleading if the `new` implementation does something different than what a derived `Default` implementation would do, because then the two methods would not be equivalent.

Instead, the `can_derive_default` check is removed, and we always suggest implementing `Default` in terms of `new()`.
2020-05-25 17:19:00 +00:00
bors
7ca335a97d Auto merge of #5639 - nickrtorres:unnecessary-mut-passed-doc-cleanup, r=phansch
Clarify the documentation of the `unnecessary_mut_passed` lint

fixes #5433 by replacing "giving" with "passing"

changelog: Clarifies documentation for `unnecessary_mut_passed`
2020-05-25 17:02:12 +00:00
bors
f162dc3ea0 Auto merge of #5646 - flip1995:rustup, r=matthiaskrgr
Rustup

r? @phansch

changelog: none
2020-05-25 16:42:50 +00:00
Nick Torres
a709559705 Clarify the documentation of the unnecessary_mut_passed lint 2020-05-23 16:15:30 -07:00
Bastian Kauschke
e820a03d1c iterate List by value 2020-05-23 12:24:19 +02:00
Dylan MacKenzie
b3a690f5a1 Use OnceCell instead of Once 2020-05-22 13:31:02 -07:00
Andy Russell
a578bed69a
new_without_default: do not suggest deriving 2020-05-22 11:49:51 -04:00
bors
ce86f907ef Auto merge of #5632 - flip1995:rustup, r=phansch
Rustup

changelog: none
2020-05-22 13:00:38 +00:00
flip1995
6b3cf63bf5
Fix dogfood fallout 2020-05-22 14:45:51 +02:00
Eduardo Broto
7a0eccbd8a Add test for multiple_crate_versions
Make the output of the lint deterministic by sorting the versions
2020-05-21 14:11:11 +02:00
Eduardo Broto
bc93f7052e Add test for cargo_common_metadata
Fix missing `authors` entry in the provided example
2020-05-21 14:11:11 +02:00
bors
1831385ff0 Auto merge of #5611 - rrbutani:master, r=flip1995
Add to the list of words clippy::doc_markdown ignores

"TypeScript" is the only one of these I actually ran into organically; I can remove the others if they're too much.

changelog: Add to the list of words `clippy::doc_markdown` ignores
2020-05-20 14:15:12 +00:00
Bastian Kauschke
091239ee60 introduce newtype'd Predicate<'tcx> 2020-05-20 15:44:34 +02:00
Elichai Turkel
ecd0a67b01
Make match_wild_err_arm pedantic, and update help messages 2020-05-20 16:39:03 +03:00
Bastian Kauschke
2722522fac rename Predicate to PredicateKind, introduce alias 2020-05-20 15:38:03 +02:00
bors
cafa94662c Auto merge of #5582 - vtmargaryan:match_wildcard_for_single_variants, r=flip1995
New lint: `match_wildcard_for_single_variants`

changelog: Added a new lint match_wildcard_for_single_variants to warn on enum matches where a wildcard is used to match a single variant

Closes #5556
2020-05-20 12:51:28 +00:00
flip1995
f28f1f15da
Fix dogfood fallout 2020-05-20 13:32:53 +02:00
Amanieu d'Antras
d25b25610b Handle InlineAsm in clippy 2020-05-18 14:41:33 +01:00
Rahul Butani
1b3dc5f79b
Add to the list of words clippy::doc_markdown ignores 2020-05-17 22:21:02 -05:00
flip1995
f1d3086492 Merge commit 'e214ea82ad0a751563acf67e1cd9279cf302db3a' into clippyup 2020-05-17 17:36:26 +02:00
bors
e214ea82ad Auto merge of #5568 - ThibsG:RenameIdentityConversionLint, r=flip1995
Rename lint `identity_conversion` to `useless_conversion`

Lint name `identity_conversion` was misleading, so this PR renames it to `useless_conversion`.

As decision has not really came up in the issue comments, this PR will probably need discussion.

fixes #3106

changelog: Rename lint `identity_conversion` to `useless_conversion`
2020-05-17 11:29:04 +00:00
bors
6ae0643d1a Auto merge of #5529 - alex-700:improve-option-and-then-some-lint, r=phansch
Improve `option_and_then_some` lint

fixed #5492

changelog: Improve and generalize `option_and_then_some` and rename it to `bind_instead_of_map`.
2020-05-17 10:58:56 +00:00
Aleksei Latyshev
07f1edf2d4
improve and generalize option_and_then_some lint
- rename it to bind_instead_of_map
2020-05-17 12:17:03 +03:00
flip1995
cb0d40a7ec
Merge remote-tracking branch 'upstream/master' into rustup 2020-05-17 01:13:02 +02:00
Aleksei Latyshev
cb7f9679a6
simplify multispan_sugg interface
- add `multispan_sugg_with_applicability`
- not it gets `&str` instead of `String`, like in `diag.multispan_suggestion`
2020-05-17 00:09:37 +03:00
ThibsG
e55b920970 Rename lint identity_conversion to useless_conversion 2020-05-16 22:50:20 +02:00
bors
cfd720d506 Auto merge of #5563 - ThibsG:MergeLints, r=flip1995
Merge some lints together

This PR merges following lints:

- `block_in_if_condition_expr` and `block_in_if_condition_stmt` → `blocks_in_if_conditions`
- `option_map_unwrap_or`, `option_map_unwrap_or_else` and `result_map_unwrap_or_else` → `map_unwrap`
- `option_unwrap_used` and `result_unwrap_used` → `unwrap_used`
- `option_expect_used` and `result_expect_used` → `expect_used`
- `wrong_pub_self_convention` into `wrong_self_convention`
- `for_loop_over_option` and `for_loop_over_result` → `for_loops_over_fallibles`

Lints that have already been merged since the issue was created:
- [x] `new_without_default` and `new_without_default_derive` → `new_without_default`

Need more discussion:
- `string_add` and `string_add_assign`: do we agree to merge them or not? Is there something more to do? → **not merge finally**
- `identity_op` and `modulo_one` → `useless_arithmetic`: seems outdated, since `modulo_arithmetic` has been created.

fixes #1078

changelog: Merging some lints together:
- `block_in_if_condition_expr` and `block_in_if_condition_stmt` → `blocks_in_if_conditions`
- `option_map_unwrap_or`, `option_map_unwrap_or_else` and `result_map_unwrap_or_else` → `map_unwrap_or`
- `option_unwrap_used` and `result_unwrap_used` → `unwrap_used`
- `option_expect_used` and `result_expect_used` → `expect_used`
- `for_loop_over_option` and `for_loop_over_result` → `for_loops_over_fallibles`
2020-05-16 20:17:11 +00:00
Ralf Jung
8bba1b7589 Rollup merge of #72047 - Julian-Wollersberger:literal_error_reporting_cleanup, r=petrochenkov
Literal error reporting cleanup

While doing some performance work, I noticed some code duplication in `librustc_parser/lexer/mod.rs`, so I cleaned it up.

This PR is probably best reviewed commit by commit.

I'm not sure what the API stability practices for `librustc_lexer` are. Four public methods in `unescape.rs` can be removed, but two are used by clippy, so I left them in for now.
I could open a PR for Rust-Analyzer when this one lands.

But how do I open a PR for clippy? (Git submodules are frustrating to work with)
2020-05-16 19:46:31 +02:00
bors
0c9427309c Auto merge of #5596 - ebroto:issue_5212, r=phansch
Fix comparison_chain false positive

changelog: comparison_chain: fix false positives when the binary operation is the same.

Fixes #5212
2020-05-16 08:49:15 +00:00
bors
53a98050b8 Auto merge of #5602 - ebroto:issue_3430, r=phansch
identity_op: allow `1 << 0`

I went for accepting `1 << 0` verbatim instead of something more general as it seems to be what everyone in the issue thread needed.

changelog: identity_op: allow `1 << 0` as it's a common pattern in bit manipulation code.

Fixes #3430
2020-05-16 08:33:47 +00:00
Dylan DPC
b0490cc80d Rollup merge of #71948 - csmoe:issue-61076, r=oli-obk
Suggest to await future before ? operator

Closes https://github.com/rust-lang/rust/issues/71811
cc #61076
2020-05-16 02:37:21 +02:00
bors
cac9ad02cf Auto merge of #5599 - dtolnay:letif, r=flip1995
Downgrade useless_let_if_seq to nursery

I feel that this lint has the wrong balance of incorrect suggestions for a default-enabled lint.

The immediate code I faced was something like:

```rust
fn main() {
    let mut good = do1();
    if !do2() {
        good = false;
    }
    if good {
        println!("good");
    }
}

fn do1() -> bool { println!("1"); false }
fn do2() -> bool { println!("2"); false }
```

On this code Clippy calls it unidiomatic and suggests the following diff, which has different behavior in a way that I don't necessarily want.

```diff
- let mut good = do1();
- if !do2() {
-     good = false;
- }
+ let good = if !do2() {
+     false
+ } else {
+     do1()
+ };
```

On exploring issues filed about this lint, I have found that other users have also struggled with inappropriate suggestions (https://github.com/rust-lang/rust-clippy/issues/4124, https://github.com/rust-lang/rust-clippy/issues/3043, https://github.com/rust-lang/rust-clippy/issues/2918, https://github.com/rust-lang/rust-clippy/issues/2176) and suggestions that make the code worse (https://github.com/rust-lang/rust-clippy/issues/3769, https://github.com/rust-lang/rust-clippy/issues/2749). Overall I believe that this lint is still at nursery quality for now and should not be enabled.

---

changelog: Remove useless_let_if_seq from default set of enabled lints
2020-05-15 21:55:43 +00:00
Vardan Margaryan
2620d2449d Fix check for missing enum variants from match expressions
TupleStruct matches are checked for exhaustiveness
2020-05-16 00:06:52 +03:00
Vardan Margaryan
10313a2631 Revert "Fix cases of match_wildcard_for_single_variants lint when it is spanned on Option"
This reverts commit 4948307977.
2020-05-15 22:33:37 +03:00
Eduardo Broto
fc8ab099c3 identity_op: allow 1 << 0 2020-05-15 21:17:37 +02:00
ThibsG
ab87f87ba0 Fix CHANGELOG.md and lint names plural 2020-05-15 18:27:11 +02:00
bors
e22ccf5332 Auto merge of #5592 - ebroto:extend_unused_unit, r=flip1995
unused_unit: lint also in type parameters and where clauses

changelog: unused_unit now also lints in type parameters and where clauses

Fixes #5585
2020-05-15 14:47:11 +00:00
csmoe
0a86335cd4 implement type_implments_trait query 2020-05-15 15:37:11 +08:00
ThibsG
93386563f6 Rename lint map_unwrap to map_unwrap_or and register lints as renamed 2020-05-15 09:17:39 +02:00
Vardan Margaryan
1c59cd5f21 Fix example code of wildcard_enum_match_arm lint 2020-05-14 22:41:05 +03:00
Vardan Margaryan
749619cfe3 Apply suggestions from PR review 2020-05-14 22:40:33 +03:00
Vardan Margaryan
4948307977 Fix cases of match_wildcard_for_single_variants lint when it is spanned on Option 2020-05-14 22:36:46 +03:00
Vardan Margaryan
0ad9f7d651 Fix trivial cases of new match_wildcard_for_single_variants lint 2020-05-14 22:36:46 +03:00
Vardan Margaryan
94e4b5ec31 Add the redundant_wildcard_enum_match lint 2020-05-14 22:36:46 +03:00
David Tolnay
95399f8f94
Downgrade useless_let_if_seq to nursery 2020-05-14 09:57:36 -07:00
ThibsG
adbdf7549c Merge for_loop_over_option and for_loop_over_result lints into for_loop_over_fallible lint 2020-05-14 16:01:07 +02:00
ThibsG
0e8be599cd Merge option_expect_used and result_expect_used lints into expect_used lint 2020-05-14 16:01:07 +02:00
ThibsG
bcf61666bd Merge option_unwrap_used and result_unwrap_used lints into unwrap_used lint 2020-05-14 16:01:07 +02:00
ThibsG
6cbdd1e49d Merge option_map_unwrap_or, option_map_unwrap_or_else and result_map_unwrap_or_else lints into map_unwrap lint 2020-05-14 15:56:17 +02:00
ThibsG
945c944709 Merge block_in_if_condition_expr and block_in_if_condition_stmt lints into block_in_if_condition lint 2020-05-14 15:56:17 +02:00
bors
e1842b0cac Auto merge of #5583 - ebroto:reversed_empty_ranges, r=yaahc,flip1995
Reversed empty ranges

This lint checks range expressions with inverted limits which result in empty ranges. This includes also the ranges used to index slices.

The lint reverse_range_loop was covering iteration of reversed ranges in a for loop, which is a subset of what this new lint covers, so it has been removed. I'm not sure if that's the best choice. It would be doable to check in the new lint that we are not in the arguments of a for loop; I went for removing it because the logic was too similar to keep them separated.

changelog: Added reversed_empty_ranges lint that checks for ranges where the limits have been inverted, resulting in empty ranges. Removed reverse_range_loop which was covering a subset of the new lint.

Closes #4192
Closes #96
2020-05-14 12:59:24 +00:00
Eduardo Broto
9217675c7f Fix comparison_chain false positive 2020-05-14 00:26:09 +02:00
Eduardo Broto
671c1e34cc Avoid running doctest that is expected to panic 2020-05-13 21:07:13 +02:00
Eduardo Broto
e4cd8e7961 Fix ICE caused in unwrap module 2020-05-13 20:35:52 +02:00
Eduardo Broto
0f2b1193f9 Remove reverse_range_loop lint 2020-05-13 20:33:32 +02:00
Eduardo Broto
8ffa0bfaa2 New lint: reversed_empty_ranges 2020-05-13 20:33:32 +02:00
Eduardo Broto
f20b962773 unused_unit: lint also in type parameters and where clauses 2020-05-13 20:33:12 +02:00
Julian Wollersberger
ff9a9ed37c Replace some usages of the old unescape_ functions in AST, clippy and tests. 2020-05-13 10:05:04 +02:00
flip1995
505280b108
Run cargo dev fmt 2020-05-11 21:31:01 +02:00
Camille GILLOT
8ab3224b3b
Fix clippy. 2020-05-11 21:26:39 +02:00
flip1995
d13d8987b0 Merge commit '43a1777b89cf6791f9e20878b4e5e3ae907867a5' into clippyup 2020-05-11 20:23:47 +02:00
Glenn Hope
b69200b846 Move is_test_module check to top of function 2020-05-09 11:10:16 -07:00
Glenn Hope
0ba61c612e Check is_macro inside check_exceptions, update references to fix test 2020-05-09 11:10:16 -07:00
Glenn Hope
4db6abcd50 Remove check for Fn, reflect this in test cases, make test cases more robust/explicit 2020-05-09 11:09:38 -07:00
Glenn Hope
152cdcb45b Remove unnecessary field, check for Mod/Fn ItemKind 2020-05-09 11:09:38 -07:00
Glenn Hope
a42a2bdac2 Also have flag disable macro check 2020-05-09 11:09:38 -07:00
Glenn Hope
ad92486d52 Add check for "test" in parent name. Include flag for disabling wildcard import exceptions 2020-05-09 11:09:38 -07:00
Glenn Hope
56f4e1c3a8 Check if the parent module name contains "test" 2020-05-09 11:09:38 -07:00
Glenn Hope
bdc75dbb7b Run cargo dev fmt 2020-05-09 11:09:38 -07:00
Glenn Hope
0c14ea8ed7 Allow 'use super::*;' imports 2020-05-09 11:09:38 -07:00
Camille GILLOT
31c84e5077 Fix clippy. 2020-05-08 13:57:01 +02:00
bors
ceddf34b2e Auto merge of #5541 - DarkEld3r:patch-1, r=flip1995
Extend example for the `unneeded_field_pattern` lint

Current example is incorrect (or pseudo-code) because a struct name is omitted. I have used the code from the tests instead. Perhaps this example can be made less verbose, but I think it is more convenient to see a "real" code as an example.

---

changelog: extend example for the `unneeded_field_pattern` lint
2020-05-08 10:34:50 +00:00
Eduardo Broto
3e4bc026e2 Apply suggestions from PR review 2020-05-07 22:40:28 +02:00
Eduardo Broto
4ac348b308 Fix doc comment in lint declaration 2020-05-07 22:03:38 +02:00
Eduardo Broto
3b58d66b22 Add the manual_async_fn lint 2020-05-07 21:42:40 +02:00