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.
11 // Regression test for issue #21245. Check that we are able to infer
12 // the types in these examples correctly. It used to be that
13 // insufficient type propagation caused the type of the iterator to be
14 // incorrectly unified with the `*const` type to which it is coerced.
16 // pretty-expanded FIXME #23616
23 fn into_iter(self) -> Self::Iter;
26 impl<I> IntoIterator for I where I: Iterator {
29 fn into_iter(self) -> I {
34 fn desugared_for_loop_bad<T>(v: Vec<T>) {
35 match IntoIterator::into_iter(v.iter()) {
38 match ::std::iter::Iterator::next(&mut iter) {
39 ::std::option::Option::Some(x) => {
40 unsafe { ptr::read(x); }
42 ::std::option::Option::None => break
49 fn desugared_for_loop_good<T>(v: Vec<T>) {
50 match v.iter().into_iter() {
53 match ::std::iter::Iterator::next(&mut iter) {
54 ::std::option::Option::Some(x) => {
55 unsafe { ptr::read(x); }
57 ::std::option::Option::None => break