From 387df4e1277ed09002bb050caac5a86d126a1339 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Tue, 23 Jul 2013 13:46:51 -0700 Subject: [PATCH] Fix the issue-3979 tests and add a new test. --- src/test/auxiliary/issue_3979_traits.rs | 7 ++-- src/test/run-pass/issue-3979-2.rs | 2 - src/test/run-pass/issue-3979-generics.rs | 12 +++--- src/test/run-pass/issue-3979-xcrate.rs | 2 +- src/test/run-pass/issue-3979.rs | 2 - .../run-pass/supertrait-default-generics.rs | 42 +++++++++++++++++++ 6 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 src/test/run-pass/supertrait-default-generics.rs diff --git a/src/test/auxiliary/issue_3979_traits.rs b/src/test/auxiliary/issue_3979_traits.rs index 1e56dab1559c..eb10553f19c2 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 9a8b90db185b..39e9f5dcd2d8 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 2a1ded96827d..867301121dae 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 { fn SetX(&mut self, S); fn X(&self) -> S; } -trait Movable: Positioned { - fn translate(&self, dx: T) { - self.SetX(self.X() + dx); +trait Movable>: Positioned { + fn translate(&mut self, dx: S) { + let x = self.X() + dx; + self.SetX(x); } } @@ -31,10 +31,10 @@ impl Positioned for Point { } } -impl Movable for Point; +impl Movable 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 4bde414c4acf..caf6d2023169 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 fe10dd5af53d..2e53fb5d3f92 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 000000000000..ae7e18d532b7 --- /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 or the MIT license +// , 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 { + fn SetX(&mut self, S); + fn X(&self) -> S; +} + +trait Movable>: Positioned { + fn translate(&mut self, dx: S) { + let x = self.X() + dx; + self.SetX(x); + } +} + +struct Point { x: S, y: S } + +impl Positioned for Point { + fn SetX(&mut self, x: S) { + self.x = x; + } + fn X(&self) -> S { + self.x.clone() + } +} + +impl> Movable for Point; + +pub fn main() { + let mut p = Point{ x: 1, y: 2}; + p.translate(3); + assert_eq!(p.X(), 4); +}