librustc: Make overloaded operators with explicit self translate correctly
This commit is contained in:
parent
082a88e42c
commit
ca6970a65e
5 changed files with 56 additions and 2 deletions
16
src/test/run-pass/operator-overloading-explicit-self.rs
Normal file
16
src/test/run-pass/operator-overloading-explicit-self.rs
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue