diff options
Diffstat (limited to 'tests/ui/structs/mutable-unit-struct-borrow-11267.rs')
| -rw-r--r-- | tests/ui/structs/mutable-unit-struct-borrow-11267.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/structs/mutable-unit-struct-borrow-11267.rs b/tests/ui/structs/mutable-unit-struct-borrow-11267.rs new file mode 100644 index 00000000000..d96c4a4e79b --- /dev/null +++ b/tests/ui/structs/mutable-unit-struct-borrow-11267.rs @@ -0,0 +1,21 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11267 + +//@ run-pass +// Tests that unary structs can be mutably borrowed. + +struct Empty; + +trait T<U> { + fn next(&mut self) -> Option<U>; +} +impl T<isize> for Empty { + fn next(&mut self) -> Option<isize> { None } +} + +fn do_something_with(a : &mut dyn T<isize>) { + println!("{:?}", a.next()) +} + +pub fn main() { + do_something_with(&mut Empty); +} |
