about summary refs log tree commit diff
path: root/tests/ui/self/uniq-self-in-mut-slot.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/self/uniq-self-in-mut-slot.rs')
-rw-r--r--tests/ui/self/uniq-self-in-mut-slot.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/self/uniq-self-in-mut-slot.rs b/tests/ui/self/uniq-self-in-mut-slot.rs
new file mode 100644
index 00000000000..71e57d8c1fa
--- /dev/null
+++ b/tests/ui/self/uniq-self-in-mut-slot.rs
@@ -0,0 +1,22 @@
+// run-pass
+
+struct X {
+    a: isize
+}
+
+trait Changer {
+    fn change(self: Box<Self>) -> Box<Self>;
+}
+
+impl Changer for X {
+    fn change(mut self: Box<X>) -> Box<X> {
+        self.a = 55;
+        self
+    }
+}
+
+pub fn main() {
+    let x: Box<_> = Box::new(X { a: 32 });
+    let new_x = x.change();
+    assert_eq!(new_x.a, 55);
+}