-
Notifications
You must be signed in to change notification settings - Fork 13.4k
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
Update Clippy to 43a1777 #72118
Conversation
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.
Co-authored-by: Philipp Krones <[email protected]>
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
@bors r+ |
📌 Commit 10f3cd9 has been approved by |
@bors p=1 |
⌛ Testing commit 10f3cd9 with merge 8e94e3c0c2f2586ca487b82aa9b97a41d4fefa2d... |
💔 Test failed - checks-actions |
These wasm test failures seem unrelated? |
@bors retry |
⌛ Testing commit 10f3cd9 with merge 72185abf09e85720c684e7b84219158e252912a6... |
💔 Test failed - checks-actions |
Spurious failure again https://github.com/rust-lang-ci/rust/runs/670397946#step:16:66 |
yeah investigating |
@bors retry |
☀️ Test successful - checks-actions, checks-azure |
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