summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/issue-111554.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/issue-111554.rs')
-rw-r--r--tests/ui/borrowck/issue-111554.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/borrowck/issue-111554.rs b/tests/ui/borrowck/issue-111554.rs
new file mode 100644
index 000000000..0dad55be3
--- /dev/null
+++ b/tests/ui/borrowck/issue-111554.rs
@@ -0,0 +1,28 @@
+struct Foo {}
+
+impl Foo {
+ pub fn foo(&mut self) {
+ || bar(&mut self);
+ //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable
+ }
+
+ pub fn baz(&self) {
+ || bar(&mut self);
+ //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable
+ //~| ERROR cannot borrow data in a `&` reference as mutable
+ }
+
+ pub fn qux(mut self) {
+ || bar(&mut self);
+ // OK
+ }
+
+ pub fn quux(self) {
+ || bar(&mut self);
+ //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable
+ }
+}
+
+fn bar(_: &mut Foo) {}
+
+fn main() {}