Skip to content

Commit dca631c

Browse files
Add tests
1 parent caeda85 commit dca631c

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Foo: Send {}
2+
3+
trait Bar {}
4+
5+
impl Bar for dyn Foo {}
6+
impl Bar for dyn Foo + Send {}
7+
//~^ ERROR conflicting implementations of trait `Bar` for type `(dyn Foo + 'static)`
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0119]: conflicting implementations of trait `Bar` for type `(dyn Foo + 'static)`
2+
--> $DIR/coherence-with-implied-auto-traits.rs:6:1
3+
|
4+
LL | impl Bar for dyn Foo {}
5+
| -------------------- first implementation here
6+
LL | impl Bar for dyn Foo + Send {}
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Foo + 'static)`
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0119`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// check-pass
2+
// revisions: current next
3+
//[next] compile-flags: -Znext-solver
4+
5+
trait Target {}
6+
trait Source: Send + Target {}
7+
8+
fn upcast(x: &dyn Source) -> &(dyn Target + Send) { x }
9+
10+
fn same(x: &dyn Source) -> &(dyn Source + Send) { x }
11+
// ^ This isn't upcasting, just passing dyn through unchanged.
12+
13+
fn main() {}

0 commit comments

Comments
 (0)