Skip to content

Commit f9bd718

Browse files
authored
Rollup merge of #105895 - oli-obk:tait_coherence, r=lcnr
Test that we don't add a new kind of breaking change with TAITs r? ``@lcnr``
2 parents 6e6ec81 + e62b75e commit f9bd718

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub trait SomeTrait {}
2+
3+
impl SomeTrait for () {}
4+
5+
// Adding this `impl` would cause errors in this crate's dependent,
6+
// so it would be a breaking change. We explicitly don't add this impl,
7+
// as the dependent crate already assumes this impl exists and thus already
8+
// does not compile.
9+
//impl SomeTrait for i32 {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// aux-build: coherence_cross_crate_trait_decl.rs
2+
// This test ensures that adding an `impl SomeTrait for i32` within
3+
// `coherence_cross_crate_trait_decl` is not a breaking change, by
4+
// making sure that even without such an impl this test fails to compile.
5+
6+
#![feature(type_alias_impl_trait)]
7+
8+
extern crate coherence_cross_crate_trait_decl;
9+
10+
use coherence_cross_crate_trait_decl::SomeTrait;
11+
12+
trait OtherTrait {}
13+
14+
type Alias = impl SomeTrait;
15+
16+
fn constrain() -> Alias {
17+
()
18+
}
19+
20+
impl OtherTrait for Alias {}
21+
impl OtherTrait for i32 {}
22+
//~^ ERROR: conflicting implementations of trait `OtherTrait` for type `Alias`
23+
24+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0119]: conflicting implementations of trait `OtherTrait` for type `Alias`
2+
--> $DIR/coherence_cross_crate.rs:21:1
3+
|
4+
LL | impl OtherTrait for Alias {}
5+
| ------------------------- first implementation here
6+
LL | impl OtherTrait for i32 {}
7+
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Alias`
8+
|
9+
= note: upstream crates may add a new impl of trait `coherence_cross_crate_trait_decl::SomeTrait` for type `i32` in future versions
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0119`.

0 commit comments

Comments
 (0)