Commit Graph

3919 Commits

Author SHA1 Message Date
Andy Russell
a578bed69a
new_without_default: do not suggest deriving 2020-05-22 11:49:51 -04: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
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
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
Oliver Scherer
7744cf4e53 Update to rustc changes 2020-05-04 15:13:07 +02:00