Commit graph

8447 commits

Author SHA1 Message Date
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
bors
43d9cdc7b3 Auto merge of #5580 - matthiaskrgr:regex_dep, r=flip1995
deps: remove unused regex dependency from root crate

changelog: none
2020-05-09 12:41:19 +00:00
Matthias Krüger
438877380a deps: remove unused regex dependency from root crate 2020-05-09 01:27:30 +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
bors
78b7d4944c Auto merge of #5576 - ebroto:manual_async_fn, r=flip1995
Add the manual_async_fn lint

changelog: Added the `manual_async_fn` lint to warn on functions that can be simplified using async syntax

Closes #5503
2020-05-08 01:50:28 +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
bors
b63868dedb Auto merge of #5566 - oli-obk:sync-from-rustc, r=flip1995
Update to rustc changes

changelog: none

So, turns out `git subtree push` dies in various interesting ways, but the source cause is that the rustc repo looks like

```
--- A --- B --- C ---
     \--- D ---/
```

where `B` is the commit where I added clippy to rustc and `D` is an arbitrary other PR and `C` is the master branch (or an earlier commit in it). When we now do `git subtree push`, it doesn't stop looking for things to merge at `B` as it needs to look at `D`, too, but then the bad thing happens, and it doesn't stop at `A` either, and just goes on looking at the entire history of rustc in a recursive bash script. That recursion then quickly runs into a stack overflow. While we can increase the stack size via `ulimit -s 60000`, that just means I was waiting for 30 minutes looking at `git subtree push` counting up the number of commits it has looked at. I aborted that, as a process that needs 30 mins for a push is not reasonable.

This PR cheats by just doing a `cp -r ../rustc/src/tools/clippy/* .` inside my clippy checkout and committing all changes. I'm working on getting us a better workflow, but until then, this workaround will work nicely. Note that this requires a `git subrepo pull` to have occurred in the `rustc` checkout. It's not necessary to merge that pull in order to update clippy, it's just necessary in order to not revert code in the clippy repo that hasn't been synced yet to the rustc repo.
2020-05-06 09:49:00 +00:00
Oliver Scherer
780a63a1ba Update ui tests 2020-05-05 15:11:59 +02:00
Oliver Scherer
7744cf4e53 Update to rustc changes 2020-05-04 15:13:07 +02:00
bors
76ddac5e8e Auto merge of #5560 - CrazyRoka:fix-match-on-vector-full-range, 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 #5551
changelog: fix match_on_vec_items when matching full range
2020-05-02 16:13:02 +00:00
bors
75a717159d Auto merge of #5558 - ThibsG:FixUnwrapInArgs, r=flip1995
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 #5174

changelog: Fixes a false positive in `unnecessary_unwrap` lint when checks are done in macro parameters.
2020-05-02 15:59:18 +00:00
bors
60538d6c8e Auto merge of #5559 - alex-700:fix-while-let-on-iterator-fp, 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 #3780

changelog: fix FP on while-let-on-iterator for arrays and bindings
2020-05-02 15:30:58 +00:00
CrazyRoka
de58c5644d Changed RANGE_FULL constant in utils 2020-05-02 17:37:03 +03:00
bors
cc9088f287 Auto merge of #5550 - ebroto:manual_non_exhaustive, r=flip1995
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 #2017
2020-05-02 13:53:39 +00:00
CrazyRoka
e7138e0629 Fix match on vec items: match on vec[..]
- Added new tests
- Fixed false positive when matching on full range, which will never panic
2020-05-02 14:25:45 +03:00
Aleksei Latyshev
d0c1f8ada2
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
2020-05-02 14:21:29 +03:00
ThibsG
72ce6d5be9 Fix unwrap lint when checks are done in parameters 2020-05-02 13:03:11 +02:00
bors
991efa6375 Auto merge of #5555 - flip1995:pedantic_match_on_vec_items, r=phansch
Move match_on_vec_items to pedantic

Addresses https://github.com/rust-lang/rust-clippy/issues/5551#issuecomment-622515580

Fixes #5553

changelog: Move [`match_on_vec_items`] to pedantic

r? @phansch
2020-05-02 08:45:59 +00:00
bors
e3b8c41d0d Auto merge of #5536 - rail-rain:fix_manual_memcpy, r=phansch
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`(#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 #3323). This PR will use `RangeTo`

changelog: fixed the bugs of `manual_memcpy` and also simplify the suggestion.
2020-05-02 08:11:48 +00:00
ebroto
350c17de24 Use the only variant left instead of a wildcard
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-05-01 23:04:58 +02:00
flip1995
10e3f9bdb8
Move match_on_vec_items to pedantic 2020-05-01 23:02:31 +02:00
Eduardo Broto
42b0b4754c Apply suggestions from PR review 2020-05-01 22:37:14 +02:00
bors
d2708873ef Auto merge of #5548 - matthiaskrgr:traget_os, r=flip1995
mismatched_target_os: link to respective section in rust reference

changelog: none
2020-05-01 16:33:14 +00:00
Eduardo Broto
f072ded3bf Implement the manual_non_exhaustive lint 2020-05-01 02:10:16 +02:00
Matthias Krüger
b7800e1ac3 mismatched_target_os: link to respective section in rust reference 2020-05-01 01:21:24 +02:00
rail
461f4a3466 Add missing tests 2020-04-30 17:32:37 +12:00
bors
0a53ed2d8e Auto merge of #5547 - CrazyRoka:fix-clone-double-ref-suggestion, r=flip1995
Fixed incorrect suggestion of `clone_double_ref` lint

- Added `<_>` to suggestion
- Changed help message
- Added new tests
Closes #5494

changelog: Improve suggestion of [`clone_double_ref`]
2020-04-29 20:05:18 +00:00
CrazyRoka
20c069beec Fixed incorrect suggestion of clone_double_ref lint
- Added `<_>` to suggestion
- Changed help message
2020-04-29 22:40:57 +03:00
bors
28197b6226 Auto merge of #5545 - flip1995:rustup, r=flip1995
Rustup to rust-lang/rust#71518

changelog: none
2020-04-29 13:59:30 +00:00
flip1995
cd3480991a
Rustup to rust-lang/rust#71518 2020-04-29 15:48:43 +02:00
bors
9a3b0a0588 Auto merge of #5543 - matthiaskrgr:rustup_45, r=flip1995
rustup https://github.com/rust-lang/rust/pull/71292/

cc https://github.com/rust-lang/rust/issues/71608

---

changelog: none
2020-04-28 18:30:01 +00:00
Matthias Krüger
bdc9528e7c rustup https://github.com/rust-lang/rust/pull/71292/ 2020-04-28 15:05:56 +02:00
Stanislav Tkach
1afb6e6e3b
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.
2020-04-28 12:08:38 +03:00
bors
2c4d566113 Auto merge of #5535 - ebroto:issue_5360, r=phansch
used_underscore_binding: do not lint on `await` desugaring

changelog: used_underscore_binding: do not lint on `await` desugaring

Fixes #5360
2020-04-28 05:36:30 +00:00
Eduardo Broto
fc5fc6378c Test that we lint the awaited expression 2020-04-27 21:29:31 +02:00
Eduardo Broto
3a96f548d1 used_underscore_binding: do not lint on await desugaring 2020-04-27 21:20:08 +02:00
bors
f2486b3d35 Auto merge of #5538 - csmoe:rustup, r=phansch
rustup: rust-lang/rust#71628

cc https://github.com/rust-lang/rust/issues/71608

changelog: none
2020-04-27 16:58:24 +00:00
csmoe
305177d9cc rustup: rust-lang/rust#71628 2020-04-27 22:40:56 +08:00
rail
51585a1298 Removed unused lifetimes and a needless bool 2020-04-27 20:37:21 +12:00
rail
be9f7c2b6d Merge branch 'master' into fix_manual_memcpy 2020-04-27 19:52:49 +12:00
rail
582614fbbe Extract building the suggestion of manual_memcpy 2020-04-27 19:44:44 +12:00
rail
9fc6f37778 Delay getting the snippet from slices 2020-04-27 19:34:41 +12:00
rail
4f2617c059 Separate getting offsets and getting index expressions 2020-04-27 19:26:00 +12:00
rail
3d121d53af Extract roles getting indexes from get_indexed_assignments 2020-04-27 19:15:51 +12:00
rail
aab80eedf3 Extract get_fixed_offset_var from fetch_cloned_fixed_offset_var` 2020-04-27 19:04:56 +12:00
rail
ecb472c052 Use fn instead of closures where unnecessary 2020-04-27 19:02:08 +12:00