-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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``
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/test/ui/type-alias-impl-trait/auxiliary/coherence_cross_crate_trait_decl.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pub trait SomeTrait {} | ||
|
||
impl SomeTrait for () {} | ||
|
||
// Adding this `impl` would cause errors in this crate's dependent, | ||
// so it would be a breaking change. We explicitly don't add this impl, | ||
// as the dependent crate already assumes this impl exists and thus already | ||
// does not compile. | ||
//impl SomeTrait for i32 {} |
24 changes: 24 additions & 0 deletions
24
src/test/ui/type-alias-impl-trait/coherence_cross_crate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// aux-build: coherence_cross_crate_trait_decl.rs | ||
// This test ensures that adding an `impl SomeTrait for i32` within | ||
// `coherence_cross_crate_trait_decl` is not a breaking change, by | ||
// making sure that even without such an impl this test fails to compile. | ||
|
||
#![feature(type_alias_impl_trait)] | ||
|
||
extern crate coherence_cross_crate_trait_decl; | ||
|
||
use coherence_cross_crate_trait_decl::SomeTrait; | ||
|
||
trait OtherTrait {} | ||
|
||
type Alias = impl SomeTrait; | ||
|
||
fn constrain() -> Alias { | ||
() | ||
} | ||
|
||
impl OtherTrait for Alias {} | ||
impl OtherTrait for i32 {} | ||
//~^ ERROR: conflicting implementations of trait `OtherTrait` for type `Alias` | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
src/test/ui/type-alias-impl-trait/coherence_cross_crate.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0119]: conflicting implementations of trait `OtherTrait` for type `Alias` | ||
--> $DIR/coherence_cross_crate.rs:21:1 | ||
| | ||
LL | impl OtherTrait for Alias {} | ||
| ------------------------- first implementation here | ||
LL | impl OtherTrait for i32 {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Alias` | ||
| | ||
= note: upstream crates may add a new impl of trait `coherence_cross_crate_trait_decl::SomeTrait` for type `i32` in future versions | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0119`. |