Commit graph

4007 commits

Author SHA1 Message Date
bors
6c833df69b Auto merge of #5678 - lzutao:slice, r=flip1995
Make use of slice pattern

changelog: none
2020-06-02 16:42:51 +00:00
Lzu Tao
fbf0b84b32 Make use of slice pattern 2020-06-02 21:42:33 +07:00
bors
5cb9ef390a Auto merge of #5664 - ThibsG:GiveCorrectedCode, r=flip1995
Give corrected code

This PR adds corrected code for doc examples.

I did this in several commits to facilitate review.
Don't hesitate to tell me if I forgot some.
Also, sometimes I felt it was not necessary to give corrected code, but I maybe wrong.

fixes: #4829

changelog: Improve documentation examples across multiple lints.
2020-06-02 12:11:28 +00:00
bors
f760d77bdb Auto merge of #5597 - esamudera:slice_iter_next, r=flip1995
New lint: iter_next_slice

Hello, this is a work-in-progress PR for issue: https://github.com/rust-lang/rust-clippy/issues/5572

I have implemented lint to replace `iter().next()` for `slice[index..]` and `array` with `get(index)` and `get(0)` respectively. However since I made a lot of changes, I would like to request some feedback before continuing so that I could fix mistakes.

Thank you!

---

changelog: implement `iter_next_slice` lint and test, and modify `needless_continues`, `for_loop_over_options_result` UI tests since they have `iter().next()`
2020-06-02 11:42:22 +00:00
bors
bfafb8e0d6 Auto merge of #5673 - phansch:endless-loop, r=Manishearth
Add regression test for endless loop / update `pulldown_cmark`

Closes #4917

This was fixed in pulldown_cmark 0.7.1, specifically raphlinus/pulldown-cmark#438

changelog: none
2020-06-01 17:16:06 +00:00
ThibsG
137a3b4d32 Corrected doc PR fixes 2020-06-01 10:49:48 +02:00
ThibsG
9893254dff Add more corrected code for doc 2020-06-01 10:39:52 +02:00
ThibsG
19339334cb Give more corrected code examples in doc 2020-06-01 10:39:52 +02:00
ThibsG
262c9dc025 Fix more code examples 2020-06-01 10:39:52 +02:00
ThibsG
61587c9a29 Fix some code examples in doc 2020-06-01 10:39:52 +02:00
Philipp Hansch
861b897c54
Add regression test for endless loop
This was fixed in pulldown_cmark 0.7.1, specifically
https://github.com/raphlinus/pulldown-cmark/pull/438
2020-06-01 10:20:17 +02:00
JarredAllen
b89880a30c Ran update_lints 2020-05-31 15:19:31 -07:00
JarredAllen
9a5baed482 Implement suggestions from phansch 2020-05-31 15:09:12 -07:00
Ericko Samudera
32fde0b511 New lint: iter_next_slice 2020-06-01 03:08:51 +07:00
JarredAllen
20cb512e81 Updated test cases and formatted 2020-05-31 12:06:32 -07:00
JarredAllen
015ab9f925 Renamed to 2020-05-31 11:55:45 -07:00
JarredAllen
07886a9764 Detect also when works 2020-05-31 11:55:45 -07:00
JarredAllen
059e8edd15 Detect also a non-reversed comparison 2020-05-31 11:55:45 -07:00
JarredAllen
955a25ee7d Added negative test cases and ran cargo dev fmt 2020-05-31 11:55:45 -07:00
JarredAllen
943cb94dce Passes all tests now! 2020-05-31 11:55:45 -07:00
JarredAllen
8590ab4d46 More progress towards sort_by_key_reverse lint 2020-05-31 11:55:45 -07:00
JarredAllen
24847ea53e Attempted start at sort_by_key_reverse lint 2020-05-31 11:55:45 -07:00
JarredAllen
7e843515d9 Created lint 2020-05-31 11:55:45 -07:00
bors
9fdcb13edb Auto merge of #4455 - flip1995:unit_arg_appl, r=phansch
Rework suggestion generation of `unit_arg` lint

Found this bug while running `cargo fix --clippy` on quite a big codebase:

This would replace something like:
```rust
Some(fn_that_actually_does_something(&a, b))
```
with
```rust
Some(())
```
which obviously suppresses side effects.

Since pretty much every expression could have side effects, I think making this suggestion `MaybeIncorrect` is the best thing to do here.

A correct suggestion would be:

```rust
fn_that_actually_does_something(&a, b);
Some(())
```

Somehow the suggestion is not correctly applied to the arguments, when more than one argument is a unit value. I have to look into this a little more, though.

changelog: Fixes suggestion of `unit_arg` lint, so that it suggests semantic equivalent code

Fixes #4741
2020-05-31 18:01:40 +00:00
flip1995
a9cde3a804
Don't suggest to move empty blocks 2020-05-31 19:29:03 +02:00
flip1995
4c9cefa122
Move linting out in its own function 2020-05-31 18:50:33 +02:00
flip1995
f9c325f5b6
Suggest to remove the semicolon of the last stmt in a block 2020-05-31 18:50:33 +02:00
flip1995
0f69cafc2d
Rework suggestion generation and use multipart_suggestion again 2020-05-31 18:50:31 +02:00
flip1995
a1a1a4b82a
Use multiple span_suggestions instead of multipart_suggestion
multipart suggestions aren't autofixable by rustfix yet
2020-05-31 18:48:29 +02:00
flip1995
0ab823c509
Rework suggestion generation of unit_arg lint 2020-05-31 18:47:48 +02:00
Michael Wright
6122612232 Increase cargo_metadata version to 0.9.1
`clippy_lints` makes use of `dep_kinds` on `NodeDep` but this was only
added in versoin 0.9.1. Compiling with 0.9.0 will fail because of this.
2020-05-31 17:38:59 +02:00
bors
8aa8f42556 Auto merge of #5667 - djugei:master, r=flip1995
moved cast_ptr_alignment to pedantic and expanded documentation

fixes: #5618
changelog: cast_ptr_alignment moved to pedantic
2020-05-31 14:26:03 +00:00
djugei
18b5ceed79
ran update_lints 2020-05-31 16:00:29 +02:00
djugei
0bcfae92f8
moved cast_ptr_alignment to pedantic and expanded documentation 2020-05-31 15:41:33 +02:00
Philipp Krones
873c9fc8f2
Rollup merge of #5656 - ebroto:len_zero_ranges, r=matthiaskrgr
len_zero: skip ranges if feature `range_is_empty` is not enabled

If the feature is not enabled, calling `is_empty()` on a range is ambiguous. Moreover, the two possible resolutions are unstable methods, one inherent to the range and the other being part of the `ExactSizeIterator` trait.

Since `len_zero` only checks for existing `is_empty()` inherent methods, we only take into account the `range_is_empty` feature.

Related: https://github.com/rust-lang/rust/issues/48111#issuecomment-445132965

changelog: len_zero: avoid linting ranges without #![feature(range_is_empty)]

Fixes: #3807
2020-05-31 14:57:33 +02:00
Philipp Krones
0fff522071
Rollup merge of #5637 - montrivo:feature/vec_resize_to_zero, r=yaahc,flip1995
new lint: vec_resize_to_zero

implements #5444

changelog: new lint vec_resize_to_zero
2020-05-31 14:57:32 +02:00
flip1995
37381d33a4
Fix sync fallout 2020-05-31 14:05:57 +02:00
Tim Nielens
5faab874f9 new lint: vec_resize_to_zero 2020-05-30 17:52:10 +02: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