diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/issues/issue-22886.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-22886.rs b/src/test/ui/issues/issue-22886.rs new file mode 100644 index 000000000..f8b576e09 --- /dev/null +++ b/src/test/ui/issues/issue-22886.rs @@ -0,0 +1,21 @@ +// Regression test for #22886. + +fn crash_please() { + let mut iter = Newtype(Some(Box::new(0))); + let saved = iter.next().unwrap(); + println!("{}", saved); + iter.0 = None; + println!("{}", saved); +} + +struct Newtype(Option<Box<usize>>); + +impl<'a> Iterator for Newtype { //~ ERROR E0207 + type Item = &'a Box<usize>; + + fn next(&mut self) -> Option<&Box<usize>> { + self.0.as_ref() + } +} + +fn main() { } |