- Notifications
You must be signed in to change notification settings - Fork 14.1k
Closed
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.P-criticalCritical priorityCritical priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This code compiles in debug mode, but fails in release mode (playground link):
use std::{future::Future, pin::Pin}; pub async fn foo(count: u32) { if count == 0 { return } else { let fut: Pin<Box<dyn Future<Output = ()>>> = Box::pin(foo(count - 1)); fut.await; } }On release mode, it errors with:
Compiling playground v0.0.1 (/playground) error[E0733]: recursion in an async fn requires boxing --> src/lib.rs:3:1 | 3 | pub async fn foo(count: u32) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: a recursive `async fn` call must introduce indirection such as `Box::pin` to avoid an infinitely sized future For more information about this error, try `rustc --explain E0733`. error: could not compile `playground` (lib) due to 1 previous error I bisected it down to this patch causing the issue: e132cac. cc @cjgillot.
Meta
rustc --version --verbose:
1.78.0-nightly (2024-02-13 a84bb95a1f65bfe25038) Backtrace
Compiling version_check v0.9.4 Compiling typenum v1.17.0 Compiling cfg-if v1.0.0 Compiling cpufeatures v0.2.12 Compiling generic-array v0.14.7 Compiling inout v0.1.3 Compiling crypto-common v0.1.6 Compiling cipher v0.4.4 Compiling aes v0.8.4 Compiling foo v0.1.0 (/usr/local/google/home/etryzelaar/foo) error[E0733]: recursion in an async fn requires boxing --> src/lib.rs:1:1 | 1 | async fn foo(count: u32) { | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: a recursive `async fn` call must introduce indirection such as `Box::pin` to avoid an infinitely sized future Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.P-criticalCritical priorityCritical priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.