From c97c03cd6a5c4ac37f2e68226c9f8ec49c786fcf Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 8 Apr 2013 17:43:55 -0700 Subject: [PATCH] tests: changes in response to #5656 --- src/test/compile-fail/issue-3311.rs | 31 -------------- src/test/compile-fail/issue-3563.rs | 2 +- src/test/compile-fail/issue-3888.rs | 42 ------------------- src/test/compile-fail/issue-3969.rs | 2 +- .../regions-infer-paramd-indirect.rs | 4 +- src/test/compile-fail/staticness-mismatch.rs | 2 +- .../class-impl-very-parameterized-trait.rs | 10 ++--- src/test/run-pass/explicit-self.rs | 2 +- src/test/run-pass/issue-3860.rs | 2 +- ...-parameterization-self-types-issue-5224.rs | 38 ----------------- src/test/run-pass/regions-self-impls.rs | 2 +- src/test/run-pass/regions-trait.rs | 2 +- 12 files changed, 14 insertions(+), 125 deletions(-) delete mode 100644 src/test/compile-fail/issue-3311.rs delete mode 100644 src/test/compile-fail/issue-3888.rs delete mode 100644 src/test/run-pass/regions-parameterization-self-types-issue-5224.rs diff --git a/src/test/compile-fail/issue-3311.rs b/src/test/compile-fail/issue-3311.rs deleted file mode 100644 index 67059e4623e..00000000000 --- a/src/test/compile-fail/issue-3311.rs +++ /dev/null @@ -1,31 +0,0 @@ -// 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. - -#[legacy_mode] -struct Foo<'self> { - s: &'self str, - u: ~() -} - -pub impl<'self> Foo<'self> { - fn get_s(&self) -> &'self str { - self.s - } -} - -fn bar(s: &str, f: &fn(Option)) { - f(Some(Foo {s: s, u: ~()})); -} - -fn main() { - do bar(~"testing") |opt| { - io::println(opt.unwrap().get_s()); //~ ERROR illegal borrow: - }; -} diff --git a/src/test/compile-fail/issue-3563.rs b/src/test/compile-fail/issue-3563.rs index d56cb0d51d2..38f28bd79df 100644 --- a/src/test/compile-fail/issue-3563.rs +++ b/src/test/compile-fail/issue-3563.rs @@ -10,7 +10,7 @@ trait A { fn a(&self) { - || self.b() //~ ERROR type `&'self Self` does not implement any method in scope named `b` + || self.b() //~ ERROR type `&Self` does not implement any method in scope named `b` } } fn main() {} diff --git a/src/test/compile-fail/issue-3888.rs b/src/test/compile-fail/issue-3888.rs deleted file mode 100644 index 35f8557c32b..00000000000 --- a/src/test/compile-fail/issue-3888.rs +++ /dev/null @@ -1,42 +0,0 @@ -// 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. - -// n.b. This should be a run-pass test, but for now I'm testing -// that we don't see an "unknown scope" error. -fn vec_peek<'r, T>(v: &'r [T]) -> Option< (&'r T, &'r [T]) > { - if v.len() == 0 { - None - } else { - let vec_len = v.len(); - let head = &v[0]; - // note: this *shouldn't* be an illegal borrow! See #3888 - let tail = v.slice(1, vec_len); //~ ERROR illegal borrow: borrowed value does not live long enough - Some( (head, tail) ) - } -} - - -fn test_peek_empty_stack() { - let v : &[int] = &[]; - assert!((None == vec_peek(v))); -} - -fn test_peek_empty_unique() { - let v : ~[int] = ~[]; - assert!((None == vec_peek(v))); -} - -fn test_peek_empty_managed() { - let v : @[int] = @[]; - assert!((None == vec_peek(v))); -} - - -fn main() {} diff --git a/src/test/compile-fail/issue-3969.rs b/src/test/compile-fail/issue-3969.rs index 60991d40a54..b60a54a44bb 100644 --- a/src/test/compile-fail/issue-3969.rs +++ b/src/test/compile-fail/issue-3969.rs @@ -18,7 +18,7 @@ trait BikeMethods { impl BikeMethods for Bike { fn woops() -> ~str { ~"foo" } - //~^ ERROR method `woops` is declared as static in its impl, but not in its trait + //~^ ERROR has a `&const self` declaration in the trait, but not in the impl } pub fn main() { diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs index e4ad93bde17..e8d66ab297b 100644 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ b/src/test/compile-fail/regions-infer-paramd-indirect.rs @@ -18,12 +18,12 @@ struct c<'self> { f: @b<'self> } -trait set_f { +trait set_f<'self> { fn set_f_ok(&self, b: @b<'self>); fn set_f_bad(&self, b: @b); } -impl<'self> set_f for c<'self> { +impl<'self> set_f<'self> for c<'self> { fn set_f_ok(&self, b: @b<'self>) { self.f = b; } diff --git a/src/test/compile-fail/staticness-mismatch.rs b/src/test/compile-fail/staticness-mismatch.rs index 719da233335..9bcf0777bbd 100644 --- a/src/test/compile-fail/staticness-mismatch.rs +++ b/src/test/compile-fail/staticness-mismatch.rs @@ -14,7 +14,7 @@ trait foo { } impl foo for int { - fn bar(&self) {} //~ ERROR method `bar` is declared as static in its trait, but not in its impl + fn bar(&self) {} //~ ERROR method `bar` has a `&self` declaration in the impl, but not in the trait } fn main() {} diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index cfde61d74b2..e4374e4d225 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -59,7 +59,7 @@ fn clear(&mut self) {} } impl Map for cat { - fn each(&self, f: &fn(&int, &T) -> bool) { + fn each<'a>(&'a self, f: &fn(&int, &'a T) -> bool) { let mut n = int::abs(self.meows); while n > 0 { if !f(&n, &self.name) { break; } @@ -73,7 +73,7 @@ fn each_key(&self, f: &fn(v: &int) -> bool) { for self.each |k, _| { if !f(k) { break; } loop;}; } - fn each_value(&self, f: &fn(v: &T) -> bool) { + fn each_value<'a>(&'a self, f: &fn(v: &'a T) -> bool) { for self.each |_, v| { if !f(v) { break; } loop;}; } @@ -86,7 +86,7 @@ fn insert(&mut self, k: int, _: T) -> bool { true } - fn find(&self, k: &int) -> Option<&'self T> { + fn find<'a>(&'a self, k: &int) -> Option<&'a T> { if *k <= self.meows { Some(&self.name) } else { @@ -94,7 +94,7 @@ fn find(&self, k: &int) -> Option<&'self T> { } } - fn find_mut(&mut self, _k: &int) -> Option<&'self mut T> { fail!() } + fn find_mut<'a>(&'a mut self, _k: &int) -> Option<&'a mut T> { fail!() } fn remove(&mut self, k: &int) -> bool { if self.find(k).is_some() { @@ -106,7 +106,7 @@ fn remove(&mut self, k: &int) -> bool { } pub impl cat { - fn get(&self, k: &int) -> &'self T { + fn get<'a>(&'a self, k: &int) -> &'a T { match self.find(k) { Some(v) => { v } None => { fail!(~"epic fail"); } diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index c5b5016572c..7e46bf22c4d 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -58,7 +58,7 @@ pub impl thing { fn foo(@self) -> int { *self.x.a } fn bar(~self) -> int { *self.x.a } fn quux(&self) -> int { *self.x.a } - fn baz(&self) -> &'self A { &self.x } + fn baz<'a>(&'a self) -> &'a A { &self.x } fn spam(self) -> int { *self.x.a } } diff --git a/src/test/run-pass/issue-3860.rs b/src/test/run-pass/issue-3860.rs index 18839fa3c7f..46aa7187c9a 100644 --- a/src/test/run-pass/issue-3860.rs +++ b/src/test/run-pass/issue-3860.rs @@ -11,7 +11,7 @@ struct Foo { x: int } pub impl Foo { - fn stuff(&mut self) -> &'self mut Foo { + fn stuff<'a>(&'a mut self) -> &'a mut Foo { return self; } } diff --git a/src/test/run-pass/regions-parameterization-self-types-issue-5224.rs b/src/test/run-pass/regions-parameterization-self-types-issue-5224.rs deleted file mode 100644 index 346a0fcfe07..00000000000 --- a/src/test/run-pass/regions-parameterization-self-types-issue-5224.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2013 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. - -// Test how region-parameterization inference -// interacts with explicit self types. -// -// Issue #5224. - -trait Getter { - // This trait does not need to be - // region-parameterized, because 'self - // is bound in the self type: - fn get(&self) -> &'self int; -} - -struct Foo { - field: int -} - -impl Getter for Foo { - fn get(&self) -> &'self int { &self.field } -} - -fn get_int(g: &G) -> int { - *g.get() -} - -pub fn main() { - let foo = Foo { field: 22 }; - assert!(get_int(&foo) == 22); -} diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs index 16b6364093e..2f4eefe5243 100644 --- a/src/test/run-pass/regions-self-impls.rs +++ b/src/test/run-pass/regions-self-impls.rs @@ -16,7 +16,7 @@ trait get_chowder<'self> { fn get_chowder(&self) -> &'self int; } -impl<'self> get_chowder for Clam<'self> { +impl<'self> get_chowder<'self> for Clam<'self> { fn get_chowder(&self) -> &'self int { return self.chowder; } } diff --git a/src/test/run-pass/regions-trait.rs b/src/test/run-pass/regions-trait.rs index f4532720579..a2ed9da67f2 100644 --- a/src/test/run-pass/regions-trait.rs +++ b/src/test/run-pass/regions-trait.rs @@ -16,7 +16,7 @@ trait get_ctxt<'self> { struct HasCtxt<'self> { c: &'self Ctxt } -impl<'self> get_ctxt for HasCtxt<'self> { +impl<'self> get_ctxt<'self> for HasCtxt<'self> { fn get_ctxt(&self) -> &'self Ctxt { self.c } -- GitLab