From 6093ea8039d4bf48ef2b34ca0ec1397016bb2b52 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 28 Nov 2015 11:42:25 +0100 Subject: Add more tests --- .../issue-21659-show-relevant-trait-impls-1.rs | 39 ++++++++++++++++++ .../issue-21659-show-relevant-trait-impls-2.rs | 46 ++++++++++++++++++++++ .../issue-21659-show-relevant-trait-impls-3.rs | 34 ++++++++++++++++ .../issue-21659-show-relevant-trait-impls.rs | 39 ------------------ 4 files changed, 119 insertions(+), 39 deletions(-) create mode 100644 src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs create mode 100644 src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs create mode 100644 src/test/compile-fail/issue-21659-show-relevant-trait-impls-3.rs delete mode 100644 src/test/compile-fail/issue-21659-show-relevant-trait-impls.rs (limited to 'src') diff --git a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs new file mode 100644 index 00000000000..416eef4ad25 --- /dev/null +++ b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs @@ -0,0 +1,39 @@ +// Copyright 2015 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. + +trait Foo { + fn foo(&self, a: A) -> A { + a + } +} + +trait NotRelevant { + fn nr(&self, a: A) -> A { + a + } +} + +struct Bar; + +impl Foo for Bar {} + +impl Foo for Bar {} + +impl NotRelevant for Bar {} + +fn main() { + let f1 = Bar; + + f1.foo(1usize); + //~^ error: the trait `Foo` is not implemented for the type `Bar` + // | help: the following implementations were found: + // | help: implementation 1: `Foo` + // | help: implementation 2: `Foo` +} diff --git a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs new file mode 100644 index 00000000000..07a7c98dd7f --- /dev/null +++ b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs @@ -0,0 +1,46 @@ +// Copyright 2015 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. + +trait Foo { + fn foo(&self, a: A) -> A { + a + } +} + +trait NotRelevant { + fn nr(&self, a: A) -> A { + a + } +} + +struct Bar; + +impl Foo for Bar {} +impl Foo for Bar {} +impl Foo for Bar {} + +impl Foo for Bar {} +impl Foo for Bar {} +impl Foo for Bar {} + +impl NotRelevant for Bar {} + +fn main() { + let f1 = Bar; + + f1.foo(1usize); + //~^ error: the trait `Foo` is not implemented for the type `Bar` + // | help: the following implementations were found: + // | help: Foo + // | help: Foo + // | help: Foo + // | help: Foo + // | help: and 2 others +} diff --git a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-3.rs b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-3.rs new file mode 100644 index 00000000000..0bb944edb9d --- /dev/null +++ b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-3.rs @@ -0,0 +1,34 @@ +// Copyright 2015 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. + +trait Foo { + fn foo(&self, a: A) -> A { + a + } +} + +trait NotRelevant { + fn nr(&self, a: A) -> A { + a + } +} + +struct Bar; + +impl NotRelevant for Bar {} + +fn main() { + let f1 = Bar; + + f1.foo(1usize); + //~^ error: method named `foo` found for type `Bar` in the current scope + //~| help: items from traits can only be used if the trait is implemented and in scope + //~| help: candidate #1: `Foo` +} diff --git a/src/test/compile-fail/issue-21659-show-relevant-trait-impls.rs b/src/test/compile-fail/issue-21659-show-relevant-trait-impls.rs deleted file mode 100644 index 416eef4ad25..00000000000 --- a/src/test/compile-fail/issue-21659-show-relevant-trait-impls.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 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. - -trait Foo { - fn foo(&self, a: A) -> A { - a - } -} - -trait NotRelevant { - fn nr(&self, a: A) -> A { - a - } -} - -struct Bar; - -impl Foo for Bar {} - -impl Foo for Bar {} - -impl NotRelevant for Bar {} - -fn main() { - let f1 = Bar; - - f1.foo(1usize); - //~^ error: the trait `Foo` is not implemented for the type `Bar` - // | help: the following implementations were found: - // | help: implementation 1: `Foo` - // | help: implementation 2: `Foo` -} -- cgit 1.4.1-3-g733a5