diff options
| author | Alejandra González <blyxyas@gmail.com> | 2025-07-30 16:42:12 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-30 16:42:12 +0000 |
| commit | 445d41909e117ea4c23401e70bbbe5ca9a25e455 (patch) | |
| tree | 5bba4b1bcabd1254158db589c18b2d7d9b2cee2a /tests | |
| parent | 18e8ac3778a2859d412c34b0ff7a1f15c07c9103 (diff) | |
| parent | 20670f78fdd63fbf1597457fcb35a562a428e0e9 (diff) | |
| download | rust-445d41909e117ea4c23401e70bbbe5ca9a25e455.tar.gz rust-445d41909e117ea4c23401e70bbbe5ca9a25e455.zip | |
Fix `iter_on_single_items` FP on function pointers and let stmts (#15013)
Closes rust-lang/rust-clippy#14981 changelog: [`iter_on_single_items`] fix FP on function pointers and let stmts
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/iter_on_single_items.fixed | 24 | ||||
| -rw-r--r-- | tests/ui/iter_on_single_items.rs | 24 |
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/ui/iter_on_single_items.fixed b/tests/ui/iter_on_single_items.fixed index b43fad6449c..044037aac2e 100644 --- a/tests/ui/iter_on_single_items.fixed +++ b/tests/ui/iter_on_single_items.fixed @@ -66,3 +66,27 @@ fn main() { custom_option::custom_option(); in_macros!(); } + +mod issue14981 { + use std::option::IntoIter; + fn takes_into_iter(_: impl IntoIterator<Item = i32>) {} + + fn let_stmt() { + macro_rules! x { + ($e:expr) => { + let _: IntoIter<i32> = $e; + }; + } + x!(Some(5).into_iter()); + } + + fn fn_ptr() { + fn some_func(_: IntoIter<i32>) -> IntoIter<i32> { + todo!() + } + some_func(Some(5).into_iter()); + + const C: fn(IntoIter<i32>) -> IntoIter<i32> = <IntoIter<i32> as IntoIterator>::into_iter; + C(Some(5).into_iter()); + } +} diff --git a/tests/ui/iter_on_single_items.rs b/tests/ui/iter_on_single_items.rs index 625c96d3ef1..c925d0e480f 100644 --- a/tests/ui/iter_on_single_items.rs +++ b/tests/ui/iter_on_single_items.rs @@ -66,3 +66,27 @@ fn main() { custom_option::custom_option(); in_macros!(); } + +mod issue14981 { + use std::option::IntoIter; + fn takes_into_iter(_: impl IntoIterator<Item = i32>) {} + + fn let_stmt() { + macro_rules! x { + ($e:expr) => { + let _: IntoIter<i32> = $e; + }; + } + x!(Some(5).into_iter()); + } + + fn fn_ptr() { + fn some_func(_: IntoIter<i32>) -> IntoIter<i32> { + todo!() + } + some_func(Some(5).into_iter()); + + const C: fn(IntoIter<i32>) -> IntoIter<i32> = <IntoIter<i32> as IntoIterator>::into_iter; + C(Some(5).into_iter()); + } +} |
