From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/issues/issue-18783.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/ui/issues/issue-18783.rs (limited to 'tests/ui/issues/issue-18783.rs') diff --git a/tests/ui/issues/issue-18783.rs b/tests/ui/issues/issue-18783.rs new file mode 100644 index 000000000..d4851ac14 --- /dev/null +++ b/tests/ui/issues/issue-18783.rs @@ -0,0 +1,28 @@ +use std::cell::RefCell; + +fn main() { + let mut y = 1; + let c = RefCell::new(vec![]); + c.push(Box::new(|| y = 0)); + c.push(Box::new(|| y = 0)); +//~^ ERROR cannot borrow `y` as mutable more than once at a time +} + +fn ufcs() { + let mut y = 1; + let c = RefCell::new(vec![]); + + Push::push(&c, Box::new(|| y = 0)); + Push::push(&c, Box::new(|| y = 0)); +//~^ ERROR cannot borrow `y` as mutable more than once at a time +} + +trait Push<'c> { + fn push<'f: 'c>(&self, push: Box); +} + +impl<'c> Push<'c> for RefCell>> { + fn push<'f: 'c>(&self, fun: Box) { + self.borrow_mut().push(fun) + } +} -- cgit v1.2.3