diff options
| -rw-r--r-- | src/test/auxiliary/issue_3979_traits.rs | 7 | ||||
| -rw-r--r-- | src/test/run-pass/issue-3979-2.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/issue-3979-generics.rs | 12 | ||||
| -rw-r--r-- | src/test/run-pass/issue-3979-xcrate.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/issue-3979.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/supertrait-default-generics.rs | 42 |
6 files changed, 53 insertions, 14 deletions
diff --git a/src/test/auxiliary/issue_3979_traits.rs b/src/test/auxiliary/issue_3979_traits.rs index 1e56dab1559..eb10553f19c 100644 --- a/src/test/auxiliary/issue_3979_traits.rs +++ b/src/test/auxiliary/issue_3979_traits.rs @@ -14,12 +14,13 @@ #[crate_type = "lib"]; trait Positioned { - fn SetX(&self, int); + fn SetX(&mut self, int); fn X(&self) -> int; } trait Movable: Positioned { - fn translate(&self, dx: int) { - self.SetX(self.X() + dx); + fn translate(&mut self, dx: int) { + let x = self.X() + dx; + self.SetX(x); } } diff --git a/src/test/run-pass/issue-3979-2.rs b/src/test/run-pass/issue-3979-2.rs index 9a8b90db185..39e9f5dcd2d 100644 --- a/src/test/run-pass/issue-3979-2.rs +++ b/src/test/run-pass/issue-3979-2.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test - trait A { fn a_method(&self); } diff --git a/src/test/run-pass/issue-3979-generics.rs b/src/test/run-pass/issue-3979-generics.rs index 2a1ded96827..867301121da 100644 --- a/src/test/run-pass/issue-3979-generics.rs +++ b/src/test/run-pass/issue-3979-generics.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test FIXME #5946 trait Positioned<S> { fn SetX(&mut self, S); fn X(&self) -> S; } -trait Movable<S, T>: Positioned<T> { - fn translate(&self, dx: T) { - self.SetX(self.X() + dx); +trait Movable<S: Add<S, S>>: Positioned<S> { + fn translate(&mut self, dx: S) { + let x = self.X() + dx; + self.SetX(x); } } @@ -31,10 +31,10 @@ impl Positioned<int> for Point { } } -impl Movable<int, int> for Point; +impl Movable<int> for Point; pub fn main() { - let p = Point{ x: 1, y: 2}; + let mut p = Point{ x: 1, y: 2}; p.translate(3); assert_eq!(p.X(), 4); } diff --git a/src/test/run-pass/issue-3979-xcrate.rs b/src/test/run-pass/issue-3979-xcrate.rs index 4bde414c4ac..caf6d202316 100644 --- a/src/test/run-pass/issue-3979-xcrate.rs +++ b/src/test/run-pass/issue-3979-xcrate.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test // tjc: ??? +// xfail-fast // aux-build:issue_3979_traits.rs extern mod issue_3979_traits; use issue_3979_traits::*; diff --git a/src/test/run-pass/issue-3979.rs b/src/test/run-pass/issue-3979.rs index fe10dd5af53..2e53fb5d3f9 100644 --- a/src/test/run-pass/issue-3979.rs +++ b/src/test/run-pass/issue-3979.rs @@ -1,5 +1,3 @@ -// xfail-test -// Reason: ICE with explicit self // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at diff --git a/src/test/run-pass/supertrait-default-generics.rs b/src/test/run-pass/supertrait-default-generics.rs new file mode 100644 index 00000000000..ae7e18d532b --- /dev/null +++ b/src/test/run-pass/supertrait-default-generics.rs @@ -0,0 +1,42 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// There is some other borrowck bug, so we make the stuff not mut. + +trait Positioned<S> { + fn SetX(&mut self, S); + fn X(&self) -> S; +} + +trait Movable<S: Add<S, S>>: Positioned<S> { + fn translate(&mut self, dx: S) { + let x = self.X() + dx; + self.SetX(x); + } +} + +struct Point<S> { x: S, y: S } + +impl<S: Clone> Positioned<S> for Point<S> { + fn SetX(&mut self, x: S) { + self.x = x; + } + fn X(&self) -> S { + self.x.clone() + } +} + +impl<S: Clone + Add<S, S>> Movable<S> for Point<S>; + +pub fn main() { + let mut p = Point{ x: 1, y: 2}; + p.translate(3); + assert_eq!(p.X(), 4); +} |
