Maybe-sized RPIT type is unexpectedly allowed in `async fn`
Open
@Aditya-PS-05 is already working on this.
Since Dec 18, 2025.
A-associated-items
A-async-await
A-DSTs
A-impl-trait
A-trait-system
C-bug
T-types
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code: playground
use std::fmt::Debug;
fn breaks() -> impl Debug + ?Sized {
123
}
//
// error[E0277]: the size for values of type `impl Debug + ?Sized` cannot be known at compilation time
// --> src/lib.rs:3:16
// |
// 3 | fn breaks() -> impl Debug + ?Sized {
// | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
// |
// = help: the trait `Sized` is not implemented for `impl Debug + ?Sized`
// = note: the return type of a function must have a statically known size
async fn works() -> impl Debug + ?Sized {
123
}
// no error!
I expected to see this happen: return types must always be sized, so -> impl Debug + ?Sized is not valid for any function regardless if it's async or not.
Instead, this happened: the compiler unexpectedly accepts it for async functions.
Meta
rustc --version --verbose:
rustc 1.91.1 (ed61e7d7e 2025-11-07)
binary: rustc
commit-hash: ed61e7d7e242494fb7057f2657300d9e77bb4fcb
commit-date: 2025-11-07
host: x86_64-unknown-linux-gnu
release: 1.91.1
LLVM version: 21.1.2
Also happens on the 2025-11-27 nightly on the playground.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.