Skip to content
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

Cleanup code suggestion for into_iter_without_iter #13634

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clippy_lints/src/iter_without_into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ impl {self_ty_without_ref} {{
let sugg = format!(
"
impl IntoIterator for {self_ty_snippet} {{
type IntoIter = {ret_ty};
type Item = {iter_ty};
type IntoIter = {ret_ty};
fn into_iter(self) -> Self::IntoIter {{
self.iter()
}}
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/iter_without_into_iter.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ help: consider implementing `IntoIterator` for `&S1`
|
LL +
LL + impl IntoIterator for &S1 {
LL + type IntoIter = std::slice::Iter<'_, u8>;
LL + type Item = &u8;
LL + type IntoIter = std::slice::Iter<'_, u8>;
LL + fn into_iter(self) -> Self::IntoIter {
LL + self.iter()
LL + }
Expand All @@ -34,8 +34,8 @@ help: consider implementing `IntoIterator` for `&mut S1`
|
LL +
LL + impl IntoIterator for &mut S1 {
LL + type IntoIter = std::slice::IterMut<'_, u8>;
LL + type Item = &mut u8;
LL + type IntoIter = std::slice::IterMut<'_, u8>;
LL + fn into_iter(self) -> Self::IntoIter {
LL + self.iter()
LL + }
Expand All @@ -55,8 +55,8 @@ help: consider implementing `IntoIterator` for `&S3<'a>`
|
LL +
LL + impl IntoIterator for &S3<'a> {
LL + type IntoIter = std::slice::Iter<'_, u8>;
LL + type Item = &u8;
LL + type IntoIter = std::slice::Iter<'_, u8>;
LL + fn into_iter(self) -> Self::IntoIter {
LL + self.iter()
LL + }
Expand All @@ -76,8 +76,8 @@ help: consider implementing `IntoIterator` for `&mut S3<'a>`
|
LL +
LL + impl IntoIterator for &mut S3<'a> {
LL + type IntoIter = std::slice::IterMut<'_, u8>;
LL + type Item = &mut u8;
LL + type IntoIter = std::slice::IterMut<'_, u8>;
LL + fn into_iter(self) -> Self::IntoIter {
LL + self.iter()
LL + }
Expand All @@ -96,8 +96,8 @@ help: consider implementing `IntoIterator` for `&S8<T>`
|
LL +
LL + impl IntoIterator for &S8<T> {
LL + type IntoIter = std::slice::Iter<'static, T>;
LL + type Item = &T;
LL + type IntoIter = std::slice::Iter<'static, T>;
LL + fn into_iter(self) -> Self::IntoIter {
LL + self.iter()
LL + }
Expand All @@ -117,8 +117,8 @@ help: consider implementing `IntoIterator` for `&S9<T>`
|
LL +
LL + impl IntoIterator for &S9<T> {
LL + type IntoIter = std::slice::Iter<'_, T>;
LL + type Item = &T;
LL + type IntoIter = std::slice::Iter<'_, T>;
LL + fn into_iter(self) -> Self::IntoIter {
LL + self.iter()
LL + }
Expand All @@ -138,8 +138,8 @@ help: consider implementing `IntoIterator` for `&mut S9<T>`
|
LL +
LL + impl IntoIterator for &mut S9<T> {
LL + type IntoIter = std::slice::IterMut<'_, T>;
LL + type Item = &mut T;
LL + type IntoIter = std::slice::IterMut<'_, T>;
LL + fn into_iter(self) -> Self::IntoIter {
LL + self.iter()
LL + }
Expand All @@ -162,8 +162,8 @@ help: consider implementing `IntoIterator` for `&Issue12037`
|
LL ~
LL + impl IntoIterator for &Issue12037 {
LL + type IntoIter = std::slice::Iter<'_, u8>;
LL + type Item = &u8;
LL + type IntoIter = std::slice::Iter<'_, u8>;
LL + fn into_iter(self) -> Self::IntoIter {
LL + self.iter()
LL + }
Expand Down