File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
src/test/ui/type-alias-impl-trait Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 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 number Diff line number Diff line change 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`.
You can’t perform that action at this time.
0 commit comments