Closed
Description
I tried this code with cargo +nightly-2022-11-05 check
:
pub trait Fn0: Fn() -> Self::Out {
type Out;
}
impl<F: Fn() -> ()> Fn0 for F {
type Out = ();
}
pub fn closure_typer(_: impl Fn0) {}
fn main() {
closure_typer(move || {});
}
I expected to see this happen: successful compilation
Instead, this happened:
error[E0644]: closure/generator type that references itself
--> src/bin/cyclic-repro.rs:13:19
|
13 | closure_typer(move || {});
| ^^^^^^^^^^ 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
It compiles successfully with the preceding nightly, cargo +nightly-2022-11-04 check
, and stable 1.65.0.
Meta
rustc --version --verbose
:
rustc 1.67.0-nightly (09508489e 2022-11-04)
binary: rustc
commit-hash: 09508489efc223287731fe8abbd2a81bbf7adf8e
commit-date: 2022-11-04
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4
To be clear, this is the nightly I installed with rustup install nightly-2022-11-05
. I assume it's normal for the commit date to be a day earlier, but I haven't specifically noticed that before.
Related
This sounds extremely similar to #97680, but that bug was reported months earlier whereas this one appeared today. My original discovery involved async fn traits too, but I reduced it to an example which contains only a closure.
@rustbot label regression-from-stable-to-nightly A-closures