Closed
Description
use core::marker::PhantomData;
fn weird() -> PhantomData<impl Sized> {
PhantomData
}
The above code [playground] fails on stable with the following error, but compiles on nightlies after #94081 . It seems to me it shouldn't, the type is not constrained at all.
error[[E0720]](https://doc.rust-lang.org/nightly/error-index.html#E0720): cannot resolve opaque type
[--> src/lib.rs:3:27
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021#) |
3 | fn weird() -> PhantomData<impl Sized> {
| ^^^^^^^^^^ recursive opaque type
4 | PhantomData
| ----------- returning here with type `PhantomData<impl Sized>`
It seems to be inferring the opaque type to be ()
. For example, if you change it to impl Future
:
error[E0277]: `()` is not a future
--> src/lib.rs:4:27
|
4 | fn weird() -> PhantomData<impl Future> {
| ^^^^^^^^^^^ `()` is not a future