diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index 7e941267ce824..4bfebf107ef10 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -2703,9 +2703,23 @@ fn select_fold1(mut it: I, mut f: F) -> Option #[stable(feature = "rust1", since = "1.0.0")] impl Iterator for &mut I { type Item = I::Item; + default fn next(&mut self) -> Option { (**self).next() } + default fn size_hint(&self) -> (usize, Option) { (**self).size_hint() } + default fn nth(&mut self, n: usize) -> Option { + (**self).nth(n) + } +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl Iterator for &mut I { fn next(&mut self) -> Option { (**self).next() } fn size_hint(&self) -> (usize, Option) { (**self).size_hint() } fn nth(&mut self, n: usize) -> Option { (**self).nth(n) } + fn try_fold(&mut self, init: B, f: F) -> R where + F: FnMut(B, Self::Item) -> R, R: Try + { + (**self).try_fold(init, f) + } } diff --git a/src/test/ui/issues/issue-31173.stderr b/src/test/ui/issues/issue-31173.stderr index 3ca8338882681..239c3da83d127 100644 --- a/src/test/ui/issues/issue-31173.stderr +++ b/src/test/ui/issues/issue-31173.stderr @@ -14,7 +14,6 @@ LL | .collect(); | ^^^^^^^ | = note: the method `collect` exists but the following trait bounds were not satisfied: - `&mut std::iter::Cloned, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]>> : std::iter::Iterator` `std::iter::Cloned, [closure@$DIR/issue-31173.rs:6:39: 9:6 found_e:_]>> : std::iter::Iterator` error: aborting due to 2 previous errors diff --git a/src/test/ui/methods/method-call-err-msg.stderr b/src/test/ui/methods/method-call-err-msg.stderr index b8ae4c34dc155..26fbae7ec3e16 100644 --- a/src/test/ui/methods/method-call-err-msg.stderr +++ b/src/test/ui/methods/method-call-err-msg.stderr @@ -34,8 +34,6 @@ LL | pub struct Foo; LL | .take() | ^^^^ | - = note: the method `take` exists but the following trait bounds were not satisfied: - `&mut Foo : std::iter::Iterator` = help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item `take`, perhaps you need to implement one of them: candidate #1: `std::io::Read` diff --git a/src/test/ui/mismatched_types/issue-36053-2.stderr b/src/test/ui/mismatched_types/issue-36053-2.stderr index 3f87ef74b8ea3..6e136037c02e5 100644 --- a/src/test/ui/mismatched_types/issue-36053-2.stderr +++ b/src/test/ui/mismatched_types/issue-36053-2.stderr @@ -5,7 +5,6 @@ LL | once::<&str>("str").fuse().filter(|a: &str| true).count(); | ^^^^^ | = note: the method `count` exists but the following trait bounds were not satisfied: - `&mut std::iter::Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]> : std::iter::Iterator` `std::iter::Filter>, [closure@$DIR/issue-36053-2.rs:7:39: 7:53]> : std::iter::Iterator` error[E0631]: type mismatch in closure arguments