diff options
Diffstat (limited to 'tests/ui/borrowck/borrowck-closures-unique-imm.rs')
-rw-r--r-- | tests/ui/borrowck/borrowck-closures-unique-imm.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-closures-unique-imm.rs b/tests/ui/borrowck/borrowck-closures-unique-imm.rs new file mode 100644 index 000000000..0dd004769 --- /dev/null +++ b/tests/ui/borrowck/borrowck-closures-unique-imm.rs @@ -0,0 +1,18 @@ +struct Foo { + x: isize, +} + +pub fn main() { + let mut this = &mut Foo { + x: 1, + }; + let mut r = || { + let p = &this.x; + &mut this.x; //~ ERROR cannot borrow + p.use_ref(); + }; + r() +} + +trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } } +impl<T> Fake for T { } |