summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/unused_peekable.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:13:23 +0000
commit20431706a863f92cb37dc512fef6e48d192aaf2c (patch)
tree2867f13f5fd5437ba628c67d7f87309ccadcd286 /src/tools/clippy/tests/ui/unused_peekable.rs
parentReleasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff)
downloadrustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz
rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/tools/clippy/tests/ui/unused_peekable.rs33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/tools/clippy/tests/ui/unused_peekable.rs b/src/tools/clippy/tests/ui/unused_peekable.rs
index 153457e36..7374dfdf9 100644
--- a/src/tools/clippy/tests/ui/unused_peekable.rs
+++ b/src/tools/clippy/tests/ui/unused_peekable.rs
@@ -57,12 +57,22 @@ fn valid() {
impl PeekableConsumer {
fn consume(&self, _: Peekable<Empty<u32>>) {}
fn consume_mut_ref(&self, _: &mut Peekable<Empty<u32>>) {}
+ fn consume_assoc(_: Peekable<Empty<u32>>) {}
+ fn consume_assoc_mut_ref(_: &mut Peekable<Empty<u32>>) {}
}
-
let peekable_consumer = PeekableConsumer;
- let mut passed_along_to_method = std::iter::empty::<u32>().peekable();
- peekable_consumer.consume_mut_ref(&mut passed_along_to_method);
- peekable_consumer.consume(passed_along_to_method);
+
+ let peekable = std::iter::empty::<u32>().peekable();
+ peekable_consumer.consume(peekable);
+
+ let mut peekable = std::iter::empty::<u32>().peekable();
+ peekable_consumer.consume_mut_ref(&mut peekable);
+
+ let peekable = std::iter::empty::<u32>().peekable();
+ PeekableConsumer::consume_assoc(peekable);
+
+ let mut peekable = std::iter::empty::<u32>().peekable();
+ PeekableConsumer::consume_assoc_mut_ref(&mut peekable);
// `peek` called in another block
let mut peekable_in_block = std::iter::empty::<u32>().peekable();
@@ -141,4 +151,19 @@ fn valid() {
{
peekable_last_expr.peek();
}
+
+ let mut peek_in_closure = std::iter::empty::<u32>().peekable();
+ let _ = || {
+ let _ = peek_in_closure.peek();
+ };
+
+ trait PeekTrait {}
+ impl<I> PeekTrait for Peekable<I> where I: Iterator {}
+
+ let mut peekable = std::iter::empty::<u32>().peekable();
+ let _dyn = &mut peekable as &mut dyn PeekTrait;
+
+ fn takes_dyn(_: &mut dyn PeekTrait) {}
+ let mut peekable = std::iter::empty::<u32>().peekable();
+ takes_dyn(&mut peekable);
}