diff --git a/src/test/compile-fail/coherence-overlap-downstream-inherent.rs b/src/test/compile-fail/coherence-overlap-downstream-inherent.rs new file mode 100644 index 000000000000..66068b535556 --- /dev/null +++ b/src/test/compile-fail/coherence-overlap-downstream-inherent.rs @@ -0,0 +1,32 @@ +// Copyright 2017 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. + +// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even +// though no impls are found. + +struct Sweet(X); +pub trait Sugar {} +pub trait Fruit {} +impl Sweet { fn dummy(&self) { } } +//~^ ERROR E0592 +//~| NOTE duplicate definitions for `dummy` +impl Sweet { fn dummy(&self) { } } +//~^ NOTE other definition for `dummy` + +trait Bar {} +struct A(T, X); +impl A where T: Bar { fn f(&self) {} } +//~^ ERROR E0592 +//~| NOTE duplicate definitions for `f` +//~| NOTE downstream crates may implement trait `Bar<_>` for type `i32` +impl A { fn f(&self) {} } +//~^ NOTE other definition for `f` + +fn main() {} diff --git a/src/test/compile-fail/coherence-overlap-downstream.rs b/src/test/compile-fail/coherence-overlap-downstream.rs new file mode 100644 index 000000000000..1df02737dec5 --- /dev/null +++ b/src/test/compile-fail/coherence-overlap-downstream.rs @@ -0,0 +1,32 @@ +// Copyright 2017 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. + +// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even +// though no impls are found. + +pub trait Sugar {} +pub trait Fruit {} +pub trait Sweet {} +impl Sweet for T { } +//~^ NOTE first implementation here +impl Sweet for T { } +//~^ ERROR E0119 +//~| NOTE conflicting implementation + +pub trait Foo {} +pub trait Bar {} +impl Foo for T where T: Bar {} +//~^ NOTE first implementation here +impl Foo for i32 {} +//~^ ERROR E0119 +//~| NOTE conflicting implementation for `i32` +//~| NOTE downstream crates may implement trait `Bar<_>` for type `i32` + +fn main() { }