diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/span/issue-23729.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/span/issue-23729.rs b/src/test/ui/span/issue-23729.rs new file mode 100644 index 000000000..ca33f9c77 --- /dev/null +++ b/src/test/ui/span/issue-23729.rs @@ -0,0 +1,33 @@ +// Regression test for #23729 + +fn main() { + let fib = { + struct Recurrence { + mem: [u64; 2], + pos: usize, + } + + impl Iterator for Recurrence { + //~^ ERROR E0046 + #[inline] + fn next(&mut self) -> Option<u64> { + if self.pos < 2 { + let next_val = self.mem[self.pos]; + self.pos += 1; + Some(next_val) + } else { + let next_val = self.mem[0] + self.mem[1]; + self.mem[0] = self.mem[1]; + self.mem[1] = next_val; + Some(next_val) + } + } + } + + Recurrence { mem: [0, 1], pos: 0 } + }; + + for e in fib.take(10) { + println!("{}", e) + } +} |