summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/useless_conversion.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /src/tools/clippy/tests/ui/useless_conversion.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/useless_conversion.rs')
-rw-r--r--src/tools/clippy/tests/ui/useless_conversion.rs45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/tools/clippy/tests/ui/useless_conversion.rs b/src/tools/clippy/tests/ui/useless_conversion.rs
index c75a2bce4..51ba49873 100644
--- a/src/tools/clippy/tests/ui/useless_conversion.rs
+++ b/src/tools/clippy/tests/ui/useless_conversion.rs
@@ -1,7 +1,7 @@
//@run-rustfix
#![deny(clippy::useless_conversion)]
-#![allow(clippy::unnecessary_wraps)]
+#![allow(clippy::needless_if, clippy::unnecessary_wraps)]
fn test_generic<T: Copy>(val: T) -> T {
let _ = T::from(val);
@@ -155,6 +155,49 @@ fn main() {
let _ = vec![s4, s4, s4].into_iter().into_iter();
}
+#[allow(dead_code)]
+fn issue11065_fp() {
+ use std::option::IntoIter;
+ fn takes_into_iter(_: impl IntoIterator<Item = i32>) {}
+
+ macro_rules! x {
+ ($e:expr) => {
+ takes_into_iter($e);
+ let _: IntoIter<i32> = $e; // removing `.into_iter()` leads to a type error here
+ };
+ }
+ x!(Some(5).into_iter());
+}
+
+#[allow(dead_code)]
+fn explicit_into_iter_fn_arg() {
+ fn a<T>(_: T) {}
+ fn b<T: IntoIterator<Item = i32>>(_: T) {}
+ fn c(_: impl IntoIterator<Item = i32>) {}
+ fn d<T>(_: T)
+ where
+ T: IntoIterator<Item = i32>,
+ {
+ }
+ fn f(_: std::vec::IntoIter<i32>) {}
+
+ a(vec![1, 2].into_iter());
+ b(vec![1, 2].into_iter());
+ c(vec![1, 2].into_iter());
+ d(vec![1, 2].into_iter());
+ b([&1, &2, &3].into_iter().cloned());
+
+ b(vec![1, 2].into_iter().into_iter());
+ b(vec![1, 2].into_iter().into_iter().into_iter());
+
+ macro_rules! macro_generated {
+ () => {
+ vec![1, 2].into_iter()
+ };
+ }
+ b(macro_generated!());
+}
+
#[derive(Copy, Clone)]
struct Foo<const C: char>;