]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/issue-23729.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / compile-fail / issue-23729.rs
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.
4 //
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.
10
11 // Regression test for #23729
12
13 fn main() {
14 let fib = {
15 struct Recurrence {
16 mem: [u64; 2],
17 pos: usize,
18 }
19
20 impl Iterator for Recurrence {
21 //~^ ERROR E0046
22 //~| NOTE missing `Item` in implementation
23 #[inline]
24 fn next(&mut self) -> Option<u64> {
25 if self.pos < 2 {
26 let next_val = self.mem[self.pos];
27 self.pos += 1;
28 Some(next_val)
29 } else {
30 let next_val = self.mem[0] + self.mem[1];
31 self.mem[0] = self.mem[1];
32 self.mem[1] = next_val;
33 Some(next_val)
34 }
35 }
36 }
37
38 Recurrence { mem: [0, 1], pos: 0 }
39 };
40
41 for e in fib.take(10) {
42 println!("{}", e)
43 }
44 }