From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/specialization/issue-36804.rs | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/ui/specialization/issue-36804.rs (limited to 'tests/ui/specialization/issue-36804.rs') diff --git a/tests/ui/specialization/issue-36804.rs b/tests/ui/specialization/issue-36804.rs new file mode 100644 index 000000000..89350602f --- /dev/null +++ b/tests/ui/specialization/issue-36804.rs @@ -0,0 +1,35 @@ +// check-pass +#![feature(specialization)] //~ WARN the feature `specialization` is incomplete + +pub struct Cloned(I); + +impl<'a, I, T: 'a> Iterator for Cloned +where + I: Iterator, + T: Clone, +{ + type Item = T; + + fn next(&mut self) -> Option { + unimplemented!() + } + + default fn count(self) -> usize where Self: Sized { + self.fold(0, |cnt, _| cnt + 1) + } +} + +impl<'a, I, T: 'a> Iterator for Cloned +where + I: Iterator, + T: Copy, +{ + fn count(self) -> usize { + unimplemented!() + } +} + +fn main() { + let a = [1,2,3,4]; + Cloned(a.iter()).count(); +} -- cgit v1.2.3