diff options
| author | Kevin Butler <haqkrs@gmail.com> | 2014-04-22 12:20:08 +0100 |
|---|---|---|
| committer | Kevin Butler <haqkrs@gmail.com> | 2014-05-02 22:46:26 +0100 |
| commit | cb08cb8aefa38d082b3f30629e15ff2eb4e61aec (patch) | |
| tree | 918dde117532dd51b84f4d62fc10dcbca2e14823 /src/test | |
| parent | b5d6b07370b665df6b54fa20e971e61041a233b0 (diff) | |
| download | rust-cb08cb8aefa38d082b3f30629e15ff2eb4e61aec.tar.gz rust-cb08cb8aefa38d082b3f30629e15ff2eb4e61aec.zip | |
Provide a note if method lookup fails and there are static definitions with the same name.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/issue-7575.rs | 80 | ||||
| -rw-r--r-- | src/test/run-pass/issue-7575.rs | 24 |
2 files changed, 104 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-7575.rs b/src/test/compile-fail/issue-7575.rs new file mode 100644 index 00000000000..5b03e6fc226 --- /dev/null +++ b/src/test/compile-fail/issue-7575.rs @@ -0,0 +1,80 @@ +// Copyright 2014 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. + +trait CtxtFn { + fn f8(self, uint) -> uint; + fn f9(uint) -> uint; //~ NOTE candidate # +} + +trait OtherTrait { + fn f9(uint) -> uint; //~ NOTE candidate # +} + +trait UnusedTrait { // This should never show up as a candidate + fn f9(uint) -> uint; +} + +impl CtxtFn for uint { + fn f8(self, i: uint) -> uint { + i * 4u + } + + fn f9(i: uint) -> uint { + i * 4u + } +} + +impl OtherTrait for uint { + fn f9(i: uint) -> uint { + i * 8u + } +} + +struct MyInt(int); + +impl MyInt { + fn fff(i: int) -> int { //~ NOTE candidate #1 is `MyInt::fff` + i + } +} + +trait ManyImplTrait { + fn is_str() -> bool { //~ NOTE candidate #1 is + false + } +} + +impl ManyImplTrait for ~str { + fn is_str() -> bool { + true + } +} + +impl ManyImplTrait for uint {} +impl ManyImplTrait for int {} +impl ManyImplTrait for char {} +impl ManyImplTrait for MyInt {} + +fn no_param_bound(u: uint, m: MyInt) -> uint { + u.f8(42) + u.f9(342) + m.fff(42) + //~^ ERROR type `uint` does not implement any method in scope named `f9` + //~^^ NOTE found defined static methods, maybe a `self` is missing? + //~^^^ ERROR type `MyInt` does not implement any method in scope named `fff` + //~^^^^ NOTE found defined static methods, maybe a `self` is missing? +} + +fn param_bound<T: ManyImplTrait>(t: T) -> bool { + t.is_str() + //~^ ERROR type `T` does not implement any method in scope named `is_str` + //~^^ NOTE found defined static methods, maybe a `self` is missing? +} + +fn main() { +} \ No newline at end of file diff --git a/src/test/run-pass/issue-7575.rs b/src/test/run-pass/issue-7575.rs new file mode 100644 index 00000000000..f31fbc0a12e --- /dev/null +++ b/src/test/run-pass/issue-7575.rs @@ -0,0 +1,24 @@ +// Copyright 2014 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. + +trait Foo { + fn new() -> bool { false } +} + +trait Bar { + fn new(&self) -> bool { true } +} + +impl Bar for int {} +impl Foo for int {} + +fn main() { + assert!(1i.new()); +} \ No newline at end of file |
