From e09fc0370188eff0bd3e6f27f72ba4de0d1a6c24 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 17 Oct 2014 09:12:25 -0400 Subject: [PATCH] Various minor cases where errors are reported in slightly different ways. --- src/test/compile-fail/issue-7575.rs | 19 +++++++++++++------ src/test/compile-fail/selftype-traittype.rs | 2 +- src/test/compile-fail/unique-pinned-nocopy.rs | 2 +- src/test/compile-fail/unique-vec-res.rs | 4 ++-- src/test/compile-fail/vec-res-add.rs | 4 ++-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/test/compile-fail/issue-7575.rs b/src/test/compile-fail/issue-7575.rs index 768177785cf..d5a1040d4b4 100644 --- a/src/test/compile-fail/issue-7575.rs +++ b/src/test/compile-fail/issue-7575.rs @@ -8,17 +8,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Test the mechanism for warning about possible missing `self` declarations. + trait CtxtFn { fn f8(self, uint) -> uint; - fn f9(uint) -> uint; //~ NOTE candidate # + fn f9(uint) -> uint; //~ NOTE candidate } trait OtherTrait { - fn f9(uint) -> uint; //~ NOTE candidate # + fn f9(uint) -> uint; //~ NOTE candidate } -trait UnusedTrait { // This should never show up as a candidate - fn f9(uint) -> uint; +// Note: this trait is not implemented, but we can't really tell +// whether or not an impl would match anyhow without a self +// declaration to match against, so we wind up printing it as a +// candidate. This seems not unreasonable -- perhaps the user meant to +// implement it, after all. +trait UnusedTrait { + fn f9(uint) -> uint; //~ NOTE candidate } impl CtxtFn for uint { @@ -40,13 +47,13 @@ impl OtherTrait for uint { struct MyInt(int); impl MyInt { - fn fff(i: int) -> int { //~ NOTE candidate #1 is `MyInt::fff` + fn fff(i: int) -> int { //~ NOTE candidate i } } trait ManyImplTrait { - fn is_str() -> bool { //~ NOTE candidate #1 is + fn is_str() -> bool { //~ NOTE candidate false } } diff --git a/src/test/compile-fail/selftype-traittype.rs b/src/test/compile-fail/selftype-traittype.rs index bf7c3b261fd..44ee5002dce 100644 --- a/src/test/compile-fail/selftype-traittype.rs +++ b/src/test/compile-fail/selftype-traittype.rs @@ -14,7 +14,7 @@ trait add { } fn do_add(x: Box, y: Box) -> Box { - x.plus(y) //~ ERROR cannot call a method whose type contains a self-type through an object + x.plus(y) //~ ERROR E0038 } fn main() {} diff --git a/src/test/compile-fail/unique-pinned-nocopy.rs b/src/test/compile-fail/unique-pinned-nocopy.rs index c812b0d96a2..0e1e66b40ce 100644 --- a/src/test/compile-fail/unique-pinned-nocopy.rs +++ b/src/test/compile-fail/unique-pinned-nocopy.rs @@ -19,6 +19,6 @@ impl Drop for r { fn main() { let i = box r { b: true }; - let _j = i.clone(); //~ ERROR not implemented + let _j = i.clone(); //~ ERROR not implement println!("{}", i); } diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs index 79f29c6b359..62fabc0b33f 100644 --- a/src/test/compile-fail/unique-vec-res.rs +++ b/src/test/compile-fail/unique-vec-res.rs @@ -35,8 +35,8 @@ fn main() { let r1 = vec!(box r { i: i1 }); let r2 = vec!(box r { i: i2 }); f(r1.clone(), r2.clone()); - //~^ ERROR the trait `core::clone::Clone` is not implemented - //~^^ ERROR the trait `core::clone::Clone` is not implemented + //~^ ERROR does not implement any method in scope named `clone` + //~^^ ERROR does not implement any method in scope named `clone` println!("{}", (r2, i1.get())); println!("{}", (r1, i2.get())); } diff --git a/src/test/compile-fail/vec-res-add.rs b/src/test/compile-fail/vec-res-add.rs index bfd52d69cb2..6221806642c 100644 --- a/src/test/compile-fail/vec-res-add.rs +++ b/src/test/compile-fail/vec-res-add.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[deriving(Show)] struct r { i:int } @@ -23,7 +24,6 @@ fn main() { let i = vec!(r(0)); let j = vec!(r(1)); let k = i + j; - //~^ ERROR not implemented + //~^ ERROR binary operation `+` cannot be applied to type println!("{}", j); - //~^ ERROR not implemented }