Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive async functions no longer error in check builds #137

Open
lcnr opened this issue Jan 21, 2025 · 0 comments · Fixed by rust-lang/rust#136073
Open

recursive async functions no longer error in check builds #137

lcnr opened this issue Jan 21, 2025 · 0 comments · Fixed by rust-lang/rust#136073

Comments

@lcnr
Copy link
Contributor

lcnr commented Jan 21, 2025

Affected tests:

  • tests/ui/async-await/recursive-async-impl-trait-type.rs
  • tests/ui/async-await/in-trait/async-recursive.rs
  • tests/ui/async-await/in-trait/async-recursive-generic.rs
//@ edition: 2021

trait MyTrait {
    async fn foo_recursive(&self, n: usize) -> i32;
}

impl MyTrait for i32 {
    async fn foo_recursive(&self, n: usize) -> i32 {
        //~^ ERROR recursion in an async fn requires boxing
        if n > 0 {
            self.foo_recursive(n - 1).await
        } else {
            *self
        }
    }
}

fn main() {}

This error is missing with the new solver

@lcnr lcnr moved this to in progress in -Znext-solver=globally Jan 29, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 3, 2025
…ays, r=oli-obk

Always compute coroutine layout for eagerly emitting recursive layout errors

Detect recursive coroutine layouts even if we don't detect opaque type recursion in the new solver. This is for two reasons:
1. It helps us detect (bad) recursive async function calls in the new solver, which due to its approach to normalization causes us to not detect this via a recursive RPIT (since the opaques are more eagerly revealed in the opaque body).
    * Fixes rust-lang/trait-system-refactor-initiative#137.
2. It helps us detect (bad) recursive async functions behind AFITs. See the AFIT test that changed for the old solver too.
3. It also greatly simplifies the recursive impl trait check, since I can remove some jankness around how it handles coroutines.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 6, 2025
…ays, r=oli-obk

Always compute coroutine layout for eagerly emitting recursive layout errors

Detect recursive coroutine layouts even if we don't detect opaque type recursion in the new solver. This is for two reasons:
1. It helps us detect (bad) recursive async function calls in the new solver, which due to its approach to normalization causes us to not detect this via a recursive RPIT (since the opaques are more eagerly revealed in the opaque body).
    * Fixes rust-lang/trait-system-refactor-initiative#137.
2. It helps us detect (bad) recursive async functions behind AFITs. See the AFIT test that changed for the old solver too.
3. It also greatly simplifies the recursive impl trait check, since I can remove some jankness around how it handles coroutines.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 6, 2025
Rollup merge of rust-lang#136073 - compiler-errors:recursive-coro-always, r=oli-obk

Always compute coroutine layout for eagerly emitting recursive layout errors

Detect recursive coroutine layouts even if we don't detect opaque type recursion in the new solver. This is for two reasons:
1. It helps us detect (bad) recursive async function calls in the new solver, which due to its approach to normalization causes us to not detect this via a recursive RPIT (since the opaques are more eagerly revealed in the opaque body).
    * Fixes rust-lang/trait-system-refactor-initiative#137.
2. It helps us detect (bad) recursive async functions behind AFITs. See the AFIT test that changed for the old solver too.
3. It also greatly simplifies the recursive impl trait check, since I can remove some jankness around how it handles coroutines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: in progress
Development

Successfully merging a pull request may close this issue.

1 participant