Commit graph

3932 commits

Author SHA1 Message Date
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
Elichai Turkel
ecd0a67b01
Make match_wild_err_arm pedantic, and update help messages 2020-05-20 16:39:03 +03: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