Skip to content

Commit 1e276d7

Browse files
committed
Fixed wrongly replaced comment in lint declaration
1 parent 83e0039 commit 1e276d7

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

clippy_lints/src/methods/chunks_exact_with_const_size.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,26 @@ pub(super) fn check(
4949
format!("using `{method_name}` with a constant chunk size"),
5050
|diag| {
5151
if let Node::LetStmt(let_stmt) = cx.tcx.parent_hir_node(expr.hir_id) {
52+
// The `ChunksExact(Mut)` struct is stored for later -- this likely means that the user intends to
53+
// not only use it as an iterator, but also access the remainder using
54+
// `(into_)remainder`. For now, just give a help message in this case.
55+
// TODO: give a suggestion that replaces this:
56+
// ```
57+
// let chunk_iter = bytes.chunks_exact(CHUNK_SIZE);
58+
// let remainder_chunk = chunk_iter.remainder();
59+
// for chunk in chunk_iter {
60+
// /* ... */
61+
// }
62+
// ```
63+
// with this:
64+
// ```
65+
// let chunk_iter = bytes.as_chunks::<CHUNK_SIZE>();
66+
// let remainder_chunk = chunk_iter.1;
67+
// for chunk in chunk_iter.0.iter() {
68+
// /* ... */
69+
// }
70+
// ```
71+
5272
diag.span_help(call_span, format!("consider using `{as_chunks}` instead"));
5373

5474
// Try to extract the variable name to provide a more helpful note

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ declare_clippy_lint! {
21062106
/// ```no_run
21072107
/// let slice = [1, 2, 3, 4, 5, 6];
21082108
/// let (chunks, remainder) = slice.as_chunks::<2>();
2109-
/// for chunk in chunk_iter.0.iter() {}
2109+
/// for chunk in chunk_iter {}
21102110
/// ```
21112111
#[clippy::version = "1.93.0"]
21122112
pub CHUNKS_EXACT_WITH_CONST_SIZE,

0 commit comments

Comments
 (0)