summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/issue-105761-suggest-self-for-closure.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/suggestions/issue-105761-suggest-self-for-closure.rs')
-rw-r--r--tests/ui/suggestions/issue-105761-suggest-self-for-closure.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/ui/suggestions/issue-105761-suggest-self-for-closure.rs b/tests/ui/suggestions/issue-105761-suggest-self-for-closure.rs
new file mode 100644
index 000000000..6d8a9ffc1
--- /dev/null
+++ b/tests/ui/suggestions/issue-105761-suggest-self-for-closure.rs
@@ -0,0 +1,28 @@
+//run-rustfix
+#![allow(unused)]
+
+struct S;
+impl S {
+ fn foo(&mut self) {
+ let x = |v: i32| {
+ self.bar();
+ self.hel();
+ };
+ self.qux(); //~ ERROR cannot borrow `*self` as mutable because it is also borrowed as immutable
+ x(1);
+ x(3);
+ }
+ fn bar(&self) {}
+ fn hel(&self) {}
+ fn qux(&mut self) {}
+
+ fn hello(&mut self) {
+ let y = || {
+ self.bar();
+ };
+ self.qux(); //~ ERROR cannot borrow `*self` as mutable because it is also borrowed as immutable
+ y();
+ }
+}
+
+fn main() {}