Skip to content

Commit 4d503b0

Browse files
qnighynikomatsakis
authored andcommitted
Add downstream tests for intercrate ambiguity hints.
1 parent d153ff3 commit 4d503b0

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even
12+
// though no impls are found.
13+
14+
struct Sweet<X>(X);
15+
pub trait Sugar {}
16+
pub trait Fruit {}
17+
impl<T:Sugar> Sweet<T> { fn dummy(&self) { } }
18+
//~^ ERROR E0592
19+
//~| NOTE duplicate definitions for `dummy`
20+
impl<T:Fruit> Sweet<T> { fn dummy(&self) { } }
21+
//~^ NOTE other definition for `dummy`
22+
23+
trait Bar<X> {}
24+
struct A<T, X>(T, X);
25+
impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
26+
//~^ ERROR E0592
27+
//~| NOTE duplicate definitions for `f`
28+
//~| NOTE downstream crates may implement trait `Bar<_>` for type `i32`
29+
impl<X> A<i32, X> { fn f(&self) {} }
30+
//~^ NOTE other definition for `f`
31+
32+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even
12+
// though no impls are found.
13+
14+
pub trait Sugar {}
15+
pub trait Fruit {}
16+
pub trait Sweet {}
17+
impl<T:Sugar> Sweet for T { }
18+
//~^ NOTE first implementation here
19+
impl<T:Fruit> Sweet for T { }
20+
//~^ ERROR E0119
21+
//~| NOTE conflicting implementation
22+
23+
pub trait Foo<X> {}
24+
pub trait Bar<X> {}
25+
impl<X, T> Foo<X> for T where T: Bar<X> {}
26+
//~^ NOTE first implementation here
27+
impl<X> Foo<X> for i32 {}
28+
//~^ ERROR E0119
29+
//~| NOTE conflicting implementation for `i32`
30+
//~| NOTE downstream crates may implement trait `Bar<_>` for type `i32`
31+
32+
fn main() { }

0 commit comments

Comments
 (0)