forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#95979 - lcnr:coherence-docs, r=compiler-errors
update coherence docs, fix generator + opaque type ICE the world is confusing, this makes it slightly less so
- Loading branch information
Showing
7 changed files
with
120 additions
and
22 deletions.
There are no files selected for viewing
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
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,15 @@ | ||
// Test that encountering closures during coherence does not cause issues. | ||
#![feature(type_alias_impl_trait)] | ||
type OpaqueClosure = impl Sized; | ||
fn defining_use() -> OpaqueClosure { | ||
|| () | ||
} | ||
|
||
struct Wrapper<T>(T); | ||
trait Trait {} | ||
impl Trait for Wrapper<OpaqueClosure> {} | ||
//~^ ERROR cannot implement trait on type alias impl trait | ||
impl<T: Sync> Trait for Wrapper<T> {} | ||
//~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueClosure>` | ||
|
||
fn main() {} |
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 @@ | ||
error: cannot implement trait on type alias impl trait | ||
--> $DIR/coherence-with-closure.rs:10:24 | ||
| | ||
LL | impl Trait for Wrapper<OpaqueClosure> {} | ||
| ^^^^^^^^^^^^^ | ||
| | ||
note: type alias impl trait defined here | ||
--> $DIR/coherence-with-closure.rs:3:22 | ||
| | ||
LL | type OpaqueClosure = impl Sized; | ||
| ^^^^^^^^^^ | ||
|
||
error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueClosure>` | ||
--> $DIR/coherence-with-closure.rs:12:1 | ||
| | ||
LL | impl Trait for Wrapper<OpaqueClosure> {} | ||
| ------------------------------------- first implementation here | ||
LL | | ||
LL | impl<T: Sync> Trait for Wrapper<T> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueClosure>` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Test that encountering closures during coherence does not cause issues. | ||
#![feature(type_alias_impl_trait, generators)] | ||
type OpaqueGenerator = impl Sized; | ||
fn defining_use() -> OpaqueGenerator { | ||
|| { | ||
for i in 0..10 { | ||
yield i; | ||
} | ||
} | ||
} | ||
|
||
struct Wrapper<T>(T); | ||
trait Trait {} | ||
impl Trait for Wrapper<OpaqueGenerator> {} | ||
//~^ ERROR cannot implement trait on type alias impl trait | ||
impl<T: Sync> Trait for Wrapper<T> {} | ||
//~^ ERROR conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>` | ||
|
||
fn main() {} |
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 @@ | ||
error: cannot implement trait on type alias impl trait | ||
--> $DIR/coherence-with-generator.rs:14:24 | ||
| | ||
LL | impl Trait for Wrapper<OpaqueGenerator> {} | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
note: type alias impl trait defined here | ||
--> $DIR/coherence-with-generator.rs:3:24 | ||
| | ||
LL | type OpaqueGenerator = impl Sized; | ||
| ^^^^^^^^^^ | ||
|
||
error[E0119]: conflicting implementations of trait `Trait` for type `Wrapper<OpaqueGenerator>` | ||
--> $DIR/coherence-with-generator.rs:16:1 | ||
| | ||
LL | impl Trait for Wrapper<OpaqueGenerator> {} | ||
| --------------------------------------- first implementation here | ||
LL | | ||
LL | impl<T: Sync> Trait for Wrapper<T> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Wrapper<OpaqueGenerator>` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0119`. |