diff options
Diffstat (limited to 'src/test/ui/closures/closure-referencing-itself-issue-25954.rs')
-rw-r--r-- | src/test/ui/closures/closure-referencing-itself-issue-25954.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/closures/closure-referencing-itself-issue-25954.rs b/src/test/ui/closures/closure-referencing-itself-issue-25954.rs new file mode 100644 index 000000000..7dd0e5179 --- /dev/null +++ b/src/test/ui/closures/closure-referencing-itself-issue-25954.rs @@ -0,0 +1,18 @@ +// Regression test for #25954: detect and reject a closure type that +// references itself. + +use std::cell::{Cell, RefCell}; + +struct A<T: Fn()> { + x: RefCell<Option<T>>, + b: Cell<i32>, +} + +fn main() { + let mut p = A{x: RefCell::new(None), b: Cell::new(4i32)}; + + // This is an error about types of infinite size: + let q = || p.b.set(5i32); //~ ERROR mismatched types + + *(p.x.borrow_mut()) = Some(q); +} |