diff options
| author | bors <bors@rust-lang.org> | 2023-01-05 03:59:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-01-05 03:59:31 +0000 |
| commit | 03b9e1d154ecf8e04656fdf0179a28cd8ef333c5 (patch) | |
| tree | 8c1b70fb5f8b03c7d47813924f1f0ca8c09438f0 /src/test/ui/issues | |
| parent | d26242d35faf50aa9c873fa3c7c15e5564384baa (diff) | |
| parent | fa2f31b97178c3a66d6e5f91fa597711f585fd3b (diff) | |
Auto merge of #105409 - compiler-errors:closure-infer-cycle, r=jackh726
Don't deduce a signature that makes a closure cyclic
Sometimes when elaborating supertrait bounds for closure signature inference, we end up deducing a closure signature that is cyclical because either a parameter or the return type references a projection mentioning `Self` that also has escaping bound vars, which means that it's not eagerly replaced with an inference variable.
Interestingly, this is not *just* related to my PR that elaborates supertrait bounds for closure signature deduction. The committed test `supertrait-hint-cycle-3.rs` shows **stable** code that is fixed by this PR:
```rust
trait Foo<'a> {
type Input;
}
impl<F: Fn(u32)> Foo<'_> for F {
type Input = u32;
}
fn needs_super<F: for<'a> Fn(<F as Foo<'a>>::Input) + for<'a> Foo<'a>>(_: F) {}
fn main() {
needs_super(|_: u32| {});
}
```
Fixes #105401
Fixes #105396
r? types
Diffstat (limited to 'src/test/ui/issues')
| -rw-r--r-- | src/test/ui/issues/issue-25439.stderr | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/test/ui/issues/issue-25439.stderr b/src/test/ui/issues/issue-25439.stderr index 325c28c15e2..dadae23fdf3 100644 --- a/src/test/ui/issues/issue-25439.stderr +++ b/src/test/ui/issues/issue-25439.stderr @@ -2,12 +2,17 @@ error[E0644]: closure/generator type that references itself --> $DIR/issue-25439.rs:8:9 | LL | fix(|_, x| x); - | ^^^^^^^^ cyclic type of infinite size + | ^^^^^^ cyclic type of infinite size | = note: closures cannot capture themselves or take themselves as argument; this error may be the result of a recent compiler bug-fix, see issue #46062 <https://github.com/rust-lang/rust/issues/46062> for more information +note: required by a bound in `fix` + --> $DIR/issue-25439.rs:3:33 + | +LL | fn fix<F>(f: F) -> i32 where F: Fn(Helper<F>, i32) -> i32 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `fix` error: aborting due to previous error |
