summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-11-27 14:12:33 -0800
committerPatrick Walton <pcwalton@mimiga.net>2012-11-28 11:01:14 -0800
commitca6970a65ebdc153d53e9b6c2ccb224ee705ac94 (patch)
tree883d7bd463736587a47d4d86a559180960521c1c /src/test
parent082a88e42cdefce78a8f1f869971bbabd74ebca2 (diff)
downloadrust-ca6970a65ebdc153d53e9b6c2ccb224ee705ac94.tar.gz
rust-ca6970a65ebdc153d53e9b6c2ccb224ee705ac94.zip
librustc: Make overloaded operators with explicit self translate correctly
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/operator-overloading-explicit-self.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/run-pass/operator-overloading-explicit-self.rs b/src/test/run-pass/operator-overloading-explicit-self.rs
new file mode 100644
index 00000000000..3b198078cf8
--- /dev/null
+++ b/src/test/run-pass/operator-overloading-explicit-self.rs
@@ -0,0 +1,16 @@
+struct S {
+    x: int
+}
+
+impl S {
+    pure fn add(&self, other: &S) -> S {
+        S { x: self.x + other.x }
+    }
+}
+
+fn main() {
+    let mut s = S { x: 1 };
+    s += S { x: 2 };
+    assert s.x == 3;
+}
+