-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect cycle errors hidden by opaques during monomorphization
- Loading branch information
1 parent
e5fedce
commit 8fbd78c
Showing
7 changed files
with
147 additions
and
1 deletion.
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
38 changes: 38 additions & 0 deletions
38
tests/ui/async-await/in-trait/indirect-recursion-issue-112047.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,38 @@ | ||
// edition: 2021 | ||
// build-fail | ||
//~^^ ERROR overflow evaluating the requirement `<A as Second>::{opaque#0} == _` | ||
|
||
#![feature(async_fn_in_trait)] | ||
|
||
fn main() { | ||
let _ = async { | ||
A.first().await.second().await; | ||
}; | ||
} | ||
|
||
pub trait First { | ||
type Second: Second; | ||
async fn first(self) -> Self::Second; | ||
} | ||
|
||
struct A; | ||
|
||
impl First for A { | ||
type Second = A; | ||
async fn first(self) -> Self::Second { | ||
A | ||
} | ||
} | ||
|
||
pub trait Second { | ||
async fn second(self); | ||
} | ||
|
||
impl<C> Second for C | ||
where | ||
C: First, | ||
{ | ||
async fn second(self) { | ||
self.first().await.second().await; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/ui/async-await/in-trait/indirect-recursion-issue-112047.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,5 @@ | ||
error[E0275]: overflow evaluating the requirement `<A as Second>::{opaque#0} == _` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0275`. |
29 changes: 29 additions & 0 deletions
29
tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.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,29 @@ | ||
// edition: 2021 | ||
// build-fail | ||
//~^^ ERROR overflow evaluating the requirement `<() as Recur>::Recur == _` | ||
|
||
#![feature(impl_trait_in_assoc_type)] | ||
|
||
use core::future::Future; | ||
|
||
trait Recur { | ||
type Recur: Future<Output = ()>; | ||
|
||
fn recur(self) -> Self::Recur; | ||
} | ||
|
||
async fn recur(t: impl Recur) { | ||
t.recur().await; | ||
} | ||
|
||
impl Recur for () { | ||
type Recur = impl Future<Output = ()>; | ||
|
||
fn recur(self) -> Self::Recur { | ||
async move { recur(self).await; } | ||
} | ||
} | ||
|
||
fn main() { | ||
recur(()); | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.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,5 @@ | ||
error[E0275]: overflow evaluating the requirement `<() as Recur>::Recur == _` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0275`. |
40 changes: 40 additions & 0 deletions
40
tests/ui/type-alias-impl-trait/mututally-recursive-overflow.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,40 @@ | ||
// edition: 2021 | ||
// build-fail | ||
//~^^ ERROR overflow evaluating the requirement `<() as B>::Assoc == _` | ||
|
||
#![feature(rustc_attrs)] | ||
#![feature(impl_trait_in_assoc_type)] | ||
|
||
#[rustc_coinductive] | ||
trait A { | ||
type Assoc; | ||
|
||
fn test() -> Self::Assoc; | ||
} | ||
|
||
#[rustc_coinductive] | ||
trait B { | ||
type Assoc; | ||
|
||
fn test() -> Self::Assoc; | ||
} | ||
|
||
impl<T: A> B for T { | ||
type Assoc = impl Sized; | ||
|
||
fn test() -> <Self as B>::Assoc { | ||
<T as A>::test() | ||
} | ||
} | ||
|
||
fn main() { | ||
<() as A>::test(); | ||
} | ||
|
||
impl<T: B> A for T { | ||
type Assoc = impl Sized; | ||
|
||
fn test() -> <Self as A>::Assoc { | ||
<T as B>::test() | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/ui/type-alias-impl-trait/mututally-recursive-overflow.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,5 @@ | ||
error[E0275]: overflow evaluating the requirement `<() as B>::Assoc == _` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0275`. |