]> git.lizzy.rs Git - rust.git/blob - src/test/ui/span/issue-23729.rs
Rollup merge of #47117 - tinaun:no_more_dups, r=frewsxcv
[rust.git] / src / test / ui / span / 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             #[inline]
23             fn next(&mut self) -> Option<u64> {
24                 if self.pos < 2 {
25                     let next_val = self.mem[self.pos];
26                     self.pos += 1;
27                     Some(next_val)
28                 } else {
29                     let next_val = self.mem[0] + self.mem[1];
30                     self.mem[0] = self.mem[1];
31                     self.mem[1] = next_val;
32                     Some(next_val)
33                 }
34             }
35         }
36
37         Recurrence { mem: [0, 1], pos: 0 }
38     };
39
40     for e in fib.take(10) {
41         println!("{}", e)
42     }
43 }