]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-18783.rs
Enable full revision in const generics ui tests
[rust.git] / src / test / ui / issues / issue-18783.rs
1 use std::cell::RefCell;
2
3 fn main() {
4     let mut y = 1;
5     let c = RefCell::new(vec![]);
6     c.push(Box::new(|| y = 0));
7     c.push(Box::new(|| y = 0));
8 //~^ ERROR cannot borrow `y` as mutable more than once at a time
9 }
10
11 fn ufcs() {
12     let mut y = 1;
13     let c = RefCell::new(vec![]);
14
15     Push::push(&c, Box::new(|| y = 0));
16     Push::push(&c, Box::new(|| y = 0));
17 //~^ ERROR cannot borrow `y` as mutable more than once at a time
18 }
19
20 trait Push<'c> {
21     fn push<'f: 'c>(&self, push: Box<dyn FnMut() + 'f>);
22 }
23
24 impl<'c> Push<'c> for RefCell<Vec<Box<dyn FnMut() + 'c>>> {
25     fn push<'f: 'c>(&self, fun: Box<dyn FnMut() + 'f>) {
26         self.borrow_mut().push(fun)
27     }
28 }