Skip to content

Update Clippy to 43a1777 #72118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
May 14, 2020
Merged

Update Clippy to 43a1777 #72118

merged 53 commits into from
May 14, 2020

Conversation

flip1995
Copy link
Member

Updates Clippy to rust-lang/rust-clippy@43a1777

We should establish a process on how often and when to update Clippy. (After X feature PRs? Once per week? Only on bug fixes and in the release week? ...?)

r? @oli-obk

rail-rain and others added 30 commits April 27, 2020 17:42
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.
Fix the bugs of `manual_memcpy`, simplify the suggestion and refactor it

While I’m working on the long procrastinated work to expand `manual_memcpy`(rust-lang#1670), I found a few minor bugs and probably unidiomatic or old coding style. There is a brief explanation of changes to the behaviour this PR will make below. And, I have a questoin: do I need to add tests for the first and second fixed bugs? I thought it might be too rare cases to include the tests for those. I added for the last one though.

* Bug fix
  * It negates resulted offsets (`src/dst_offset`) when `offset` is subtraction by 0. This PR will remove any subtraction by 0 as a part of minification.

    ```rust
    for i in 0..5 {
        dst[i - 0] = src[i];
    }
    ```

    ```diff
     warning: it looks like you're manually copying between slices
       --> src/main.rs:2:14
        |
    LL  |     for i in 0..5 {
    -   |              ^^^^ help: try replacing the loop by: `dst[..-5].clone_from_slice(&src[..5])`
    +   |              ^^^^ help: try replacing the loop by: `dst[..5].clone_from_slice(&src[..5])`
        |
    ```
  * It prints `RangeTo` or `RangeFull` when both of `end` and `offset` are 0, which have different meaning. This PR will print 0. I could reject the cases `end` is 0, but I thought I won’t catch other cases `reverse_range_loop` will trigger, and it’s over to catch every such cases.

    ```rust
    for i in 0..0 {
        dst[i] = src[i];
    }
    ```

    ```diff
     warning: it looks like you're manually copying between slices
       --> src/main.rs:2:14
        |
     LL |     for i in 0..0 {
    -   |              ^^^^ help: try replacing the loop by: `dst.clone_from_slice(&src[..])`
    +   |              ^^^^ help: try replacing the loop by: `dst[..0].clone_from_slice(&src[..0])`
        |
    ```
  * it prints four dots when `end` is `None`. This PR will ignore any `for` loops without `end` because a `for` loop that takes `RangeFrom` as its argument and contains indexing without the statements or the expressions that end loops such as `break` will definitely panic, and `manual_memcpy` should ignore the loops with such control flow.

    ```rust
    fn manual_copy(src: &[u32], dst: &mut [u32]) {
        for i in 0.. {
            dst[i] = src[i];
        }
    }
    ```

    ```diff
    -warning: it looks like you're manually copying between slices
    -  --> src/main.rs:2:14
    -   |
    -LL |     for i in 0.. {
    -   |              ^^^ help: try replacing the loop by: `dst[....].clone_from_slice(&src[....])`
    -   |
    ```
* Simplification of the suggestion

  * It prints 0 when `start` or `end` and `offset` are same (from rust-lang#3323). This PR will use `RangeTo`

changelog: fixed the bugs of `manual_memcpy` and also simplify the suggestion.
…r=phansch

Move match_on_vec_items to pedantic

Addresses rust-lang/rust-clippy#5551 (comment)

Fixes rust-lang#5553

changelog: Move [`match_on_vec_items`] to pedantic

r? @phansch
- fix `is_refutable` for slice patterns
- fix `is_refutable` for bindings
- add some TODO-s for cases, which can not be fixed easily
- Added new tests
- Fixed false positive when matching on full range, which will never panic
Implement the manual_non_exhaustive lint

Some implementation notes:
* Not providing automatic fixups because additional changes may be needed in other parts of the code, e.g. when constructing a struct.
* Even though the attribute is valid on enum variants, it's not possible to use the manual implementation of the pattern because the visibility is always public, so the lint ignores enum variants.
* Unit structs are also ignored, it's not possible to implement the pattern manually without fields.
* The attribute is not accepted in unions, so those are ignored too.
* Even though the original issue did not mention it, tuple structs are also linted because it's possible to apply the pattern manually.

changelog: Added the manual non-exhaustive implementation lint

Closes rust-lang#2017
… r=flip1995

Fix FP on while-let-on-iterator

- fix `is_refutable` for slice patterns
- fix `is_refutable` for bindings
- add some TODO-s for cases, which can not be fixed easily

fixes rust-lang#3780

changelog: fix FP on while-let-on-iterator for arrays and bindings
Fix `unnecessary_unwrap` lint when checks are done in parameters

Fixes a false positive in `unnecessary_unwrap` lint when checks are done in macro parameters.

FIxes rust-lang#5174

changelog: Fixes a false positive in `unnecessary_unwrap` lint when checks are done in macro parameters.
…ge, r=phansch,flip1995

Fix match on vec items: match on vec[..]

- Added new tests
- Fixed false positive when matching on full range, which will never panic

Closes rust-lang#5551
changelog: fix match_on_vec_items when matching full range
@oli-obk
Copy link
Contributor

oli-obk commented May 12, 2020

@bors r+

@bors
Copy link
Collaborator

bors commented May 12, 2020

📌 Commit 10f3cd9 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 12, 2020
@Dylan-DPC-zz
Copy link

@bors p=1

@bors
Copy link
Collaborator

bors commented May 13, 2020

⌛ Testing commit 10f3cd9 with merge 8e94e3c0c2f2586ca487b82aa9b97a41d4fefa2d...

@bors
Copy link
Collaborator

bors commented May 13, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 13, 2020
@flip1995
Copy link
Member Author

These wasm test failures seem unrelated?

@oli-obk
Copy link
Contributor

oli-obk commented May 13, 2020

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 13, 2020
@bors
Copy link
Collaborator

bors commented May 13, 2020

⌛ Testing commit 10f3cd9 with merge 72185abf09e85720c684e7b84219158e252912a6...

@bors
Copy link
Collaborator

bors commented May 13, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 13, 2020
@matthiaskrgr
Copy link
Member

@Dylan-DPC-zz
Copy link

yeah investigating

@Dylan-DPC-zz
Copy link

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 13, 2020
@bors
Copy link
Collaborator

bors commented May 13, 2020

⌛ Testing commit 10f3cd9 with merge 94c0ab9...

@bors
Copy link
Collaborator

bors commented May 14, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: oli-obk
Pushing 94c0ab9 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 14, 2020
@bors bors merged commit 94c0ab9 into rust-lang:master May 14, 2020
@flip1995 flip1995 deleted the clippyup branch May 14, 2020 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.