about summary refs log tree commit diff
path: root/tests/ui/span/borrowck-call-method-from-mut-aliasable.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/span/borrowck-call-method-from-mut-aliasable.rs')
-rw-r--r--tests/ui/span/borrowck-call-method-from-mut-aliasable.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/span/borrowck-call-method-from-mut-aliasable.rs b/tests/ui/span/borrowck-call-method-from-mut-aliasable.rs
new file mode 100644
index 00000000000..caf2d2a55fc
--- /dev/null
+++ b/tests/ui/span/borrowck-call-method-from-mut-aliasable.rs
@@ -0,0 +1,21 @@
+struct Foo {
+    x: isize,
+}
+
+impl Foo {
+    pub fn f(&self) {}
+    pub fn h(&mut self) {}
+}
+
+fn a(x: &mut Foo) {
+    x.f();
+    x.h();
+}
+
+fn b(x: &Foo) {
+    x.f();
+    x.h(); //~ ERROR cannot borrow
+}
+
+fn main() {
+}