1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 // Regression test for issue #21245. Check that we are able to infer
14 // the types in these examples correctly. It used to be that
15 // insufficient type propagation caused the type of the iterator to be
16 // incorrectly unified with the `*const` type to which it is coerced.
18 // pretty-expanded FIXME #23616
25 fn into_iter2(self) -> Self::Iter;
28 impl<I> IntoIterator for I where I: Iterator {
31 fn into_iter2(self) -> I {
36 fn desugared_for_loop_bad<T>(v: Vec<T>) {
37 match IntoIterator::into_iter2(v.iter()) {
40 match ::std::iter::Iterator::next(&mut iter) {
41 ::std::option::Option::Some(x) => {
42 unsafe { ptr::read(x); }
44 ::std::option::Option::None => break
51 fn desugared_for_loop_good<T>(v: Vec<T>) {
52 match v.iter().into_iter() {
55 match ::std::iter::Iterator::next(&mut iter) {
56 ::std::option::Option::Some(x) => {
57 unsafe { ptr::read(x); }
59 ::std::option::Option::None => break