Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new coherence tests and update the documentation
- Loading branch information
1 parent
be0d10f
commit 93e2982
Showing
5 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/test/ui/coherence/coherence-fn-covariant-bound-vs-static.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,26 @@ | ||
// Test that impls for these two types are considered ovelapping: | ||
// | ||
// * `for<'r> fn(fn(&'r u32))` | ||
// * `fn(fn(&'a u32)` where `'a` is free | ||
// | ||
// This is because, for `'a = 'static`, the two types overlap. | ||
// Effectively for them to be equal to you get: | ||
// | ||
// * `for<'r> fn(fn(&'r u32)) <: fn(fn(&'static u32))` | ||
// * true if `exists<'r> { 'r: 'static }` (obviously true) | ||
// * `fn(fn(&'static u32)) <: for<'r> fn(fn(&'r u32))` | ||
// * true if `forall<'r> { 'static: 'r }` (also true) | ||
|
||
trait Trait {} | ||
|
||
impl Trait for for<'r> fn(fn(&'r ())) {} | ||
impl<'a> Trait for fn(fn(&'a ())) {} | ||
//~^ ERROR conflicting implementations | ||
// | ||
// Note in particular that we do NOT get a future-compatibility warning | ||
// here. This is because the new leak-check proposed in [MCP 295] does not | ||
// "error" when these two types are equated. | ||
// | ||
// [MCP 295]: https://github.com/rust-lang/compiler-team/issues/295 | ||
|
||
fn main() {} |
13 changes: 13 additions & 0 deletions
13
src/test/ui/coherence/coherence-fn-covariant-bound-vs-static.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 `Trait` for type `for<'r> fn(fn(&'r ()))`: | ||
--> $DIR/coherence-fn-covariant-bound-vs-static.rs:14:1 | ||
| | ||
LL | impl Trait for for<'r> fn(fn(&'r ())) {} | ||
| ------------------------------------- first implementation here | ||
LL | impl<'a> Trait for fn(fn(&'a ())) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'r> fn(fn(&'r ()))` | ||
| | ||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0119`. |
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
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
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