From ca6970a65ebdc153d53e9b6c2ccb224ee705ac94 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 27 Nov 2012 14:12:33 -0800 Subject: librustc: Make overloaded operators with explicit self translate correctly --- src/test/run-pass/operator-overloading-explicit-self.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test/run-pass/operator-overloading-explicit-self.rs (limited to 'src/test') 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; +} + -- cgit 1.4.1-3-g733a5