]> git.proxmox.com Git - rustc.git/blame - src/test/ui/issues/issue-18783.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / issues / issue-18783.rs
CommitLineData
1a4d82fc
JJ
1use std::cell::RefCell;
2
3fn main() {
c34b1796 4 let mut y = 1;
1a4d82fc 5 let c = RefCell::new(vec![]);
c34b1796
AL
6 c.push(Box::new(|| y = 0));
7 c.push(Box::new(|| y = 0));
1a4d82fc
JJ
8//~^ ERROR cannot borrow `y` as mutable more than once at a time
9}
10
11fn ufcs() {
c34b1796 12 let mut y = 1;
1a4d82fc 13 let c = RefCell::new(vec![]);
1a4d82fc 14
c34b1796
AL
15 Push::push(&c, Box::new(|| y = 0));
16 Push::push(&c, Box::new(|| y = 0));
85aaf69f 17//~^ ERROR cannot borrow `y` as mutable more than once at a time
1a4d82fc
JJ
18}
19
20trait Push<'c> {
dc9dc135 21 fn push<'f: 'c>(&self, push: Box<dyn FnMut() + 'f>);
1a4d82fc
JJ
22}
23
dc9dc135
XL
24impl<'c> Push<'c> for RefCell<Vec<Box<dyn FnMut() + 'c>>> {
25 fn push<'f: 'c>(&self, fun: Box<dyn FnMut() + 'f>) {
1a4d82fc
JJ
26 self.borrow_mut().push(fun)
27 }
28}