-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #87546 - rusticstuff:issue87450-take-two, r=davidtwco
Bail on any found recursion when expanding opaque types Fixes #87450. More of a bandaid because it does not fix the exponential complexity of the type folding used for opaque type expansion.
- Loading branch information
Showing
3 changed files
with
48 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
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,16 @@ | ||
fn bar() -> impl Fn() { | ||
wrap(wrap(wrap(wrap(foo())))) | ||
} | ||
|
||
fn foo() -> impl Fn() { | ||
//~^ WARNING 5:1: 5:22: function cannot return without recursing [unconditional_recursion] | ||
//~| ERROR 5:13: 5:22: cannot resolve opaque type [E0720] | ||
wrap(wrap(wrap(wrap(wrap(wrap(wrap(foo()))))))) | ||
} | ||
|
||
fn wrap(f: impl Fn()) -> impl Fn() { | ||
move || f() | ||
} | ||
|
||
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,27 @@ | ||
warning: function cannot return without recursing | ||
--> $DIR/issue-87450.rs:5:1 | ||
| | ||
LL | fn foo() -> impl Fn() { | ||
| ^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing | ||
... | ||
LL | wrap(wrap(wrap(wrap(wrap(wrap(wrap(foo()))))))) | ||
| ----- recursive call site | ||
| | ||
= note: `#[warn(unconditional_recursion)]` on by default | ||
= help: a `loop` may express intention better if this is on purpose | ||
|
||
error[E0720]: cannot resolve opaque type | ||
--> $DIR/issue-87450.rs:5:13 | ||
| | ||
LL | fn foo() -> impl Fn() { | ||
| ^^^^^^^^^ recursive opaque type | ||
... | ||
LL | wrap(wrap(wrap(wrap(wrap(wrap(wrap(foo()))))))) | ||
| ----------------------------------------------- returning here with type `impl Fn<()>` | ||
... | ||
LL | fn wrap(f: impl Fn()) -> impl Fn() { | ||
| --------- returning this opaque type `impl Fn<()>` | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0720`. |