Skip to content

Commit 323f144

Browse files
committed
Cleanup code suggestion for into_iter_without_iter
Reorder the suggested code for the `IntoIterator` to match the ordering of the trait declaration: ```rust impl IntoIterator for ... { type Item = ...; type IntoIter = ...; ```
1 parent 1bdc08a commit 323f144

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clippy_lints/src/iter_without_into_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ impl {self_ty_without_ref} {{
247247
let sugg = format!(
248248
"
249249
impl IntoIterator for {self_ty_snippet} {{
250-
type IntoIter = {ret_ty};
251250
type Item = {iter_ty};
251+
type IntoIter = {ret_ty};
252252
fn into_iter(self) -> Self::IntoIter {{
253253
self.iter()
254254
}}

tests/ui/iter_without_into_iter.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ help: consider implementing `IntoIterator` for `&S1`
1313
|
1414
LL +
1515
LL + impl IntoIterator for &S1 {
16-
LL + type IntoIter = std::slice::Iter<'_, u8>;
1716
LL + type Item = &u8;
17+
LL + type IntoIter = std::slice::Iter<'_, u8>;
1818
LL + fn into_iter(self) -> Self::IntoIter {
1919
LL + self.iter()
2020
LL + }
@@ -34,8 +34,8 @@ help: consider implementing `IntoIterator` for `&mut S1`
3434
|
3535
LL +
3636
LL + impl IntoIterator for &mut S1 {
37-
LL + type IntoIter = std::slice::IterMut<'_, u8>;
3837
LL + type Item = &mut u8;
38+
LL + type IntoIter = std::slice::IterMut<'_, u8>;
3939
LL + fn into_iter(self) -> Self::IntoIter {
4040
LL + self.iter()
4141
LL + }
@@ -55,8 +55,8 @@ help: consider implementing `IntoIterator` for `&S3<'a>`
5555
|
5656
LL +
5757
LL + impl IntoIterator for &S3<'a> {
58-
LL + type IntoIter = std::slice::Iter<'_, u8>;
5958
LL + type Item = &u8;
59+
LL + type IntoIter = std::slice::Iter<'_, u8>;
6060
LL + fn into_iter(self) -> Self::IntoIter {
6161
LL + self.iter()
6262
LL + }
@@ -76,8 +76,8 @@ help: consider implementing `IntoIterator` for `&mut S3<'a>`
7676
|
7777
LL +
7878
LL + impl IntoIterator for &mut S3<'a> {
79-
LL + type IntoIter = std::slice::IterMut<'_, u8>;
8079
LL + type Item = &mut u8;
80+
LL + type IntoIter = std::slice::IterMut<'_, u8>;
8181
LL + fn into_iter(self) -> Self::IntoIter {
8282
LL + self.iter()
8383
LL + }
@@ -96,8 +96,8 @@ help: consider implementing `IntoIterator` for `&S8<T>`
9696
|
9797
LL +
9898
LL + impl IntoIterator for &S8<T> {
99-
LL + type IntoIter = std::slice::Iter<'static, T>;
10099
LL + type Item = &T;
100+
LL + type IntoIter = std::slice::Iter<'static, T>;
101101
LL + fn into_iter(self) -> Self::IntoIter {
102102
LL + self.iter()
103103
LL + }
@@ -117,8 +117,8 @@ help: consider implementing `IntoIterator` for `&S9<T>`
117117
|
118118
LL +
119119
LL + impl IntoIterator for &S9<T> {
120-
LL + type IntoIter = std::slice::Iter<'_, T>;
121120
LL + type Item = &T;
121+
LL + type IntoIter = std::slice::Iter<'_, T>;
122122
LL + fn into_iter(self) -> Self::IntoIter {
123123
LL + self.iter()
124124
LL + }
@@ -138,8 +138,8 @@ help: consider implementing `IntoIterator` for `&mut S9<T>`
138138
|
139139
LL +
140140
LL + impl IntoIterator for &mut S9<T> {
141-
LL + type IntoIter = std::slice::IterMut<'_, T>;
142141
LL + type Item = &mut T;
142+
LL + type IntoIter = std::slice::IterMut<'_, T>;
143143
LL + fn into_iter(self) -> Self::IntoIter {
144144
LL + self.iter()
145145
LL + }
@@ -162,8 +162,8 @@ help: consider implementing `IntoIterator` for `&Issue12037`
162162
|
163163
LL ~
164164
LL + impl IntoIterator for &Issue12037 {
165-
LL + type IntoIter = std::slice::Iter<'_, u8>;
166165
LL + type Item = &u8;
166+
LL + type IntoIter = std::slice::Iter<'_, u8>;
167167
LL + fn into_iter(self) -> Self::IntoIter {
168168
LL + self.iter()
169169
LL + }

0 commit comments

Comments
 (0)