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

False E0644 closure/generator type that references itself; new in nightly-2022-11-05 #104025

Closed
kpreid opened this issue Nov 5, 2022 · 1 comment · Fixed by #104038
Closed
Assignees
Labels
A-closures Area: Closures (`|…| { … }`) C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.

Comments

@kpreid
Copy link
Contributor

kpreid commented Nov 5, 2022

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

@kpreid kpreid added the C-bug Category: This is a bug. label Nov 5, 2022
@rustbot rustbot added A-closures Area: Closures (`|…| { … }`) regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Nov 5, 2022
@compiler-errors
Copy link
Member

This was introduced by me in #101834 -- I'll put up a fix soon.

@compiler-errors compiler-errors self-assigned this Nov 6, 2022
@bors bors closed this as completed in f0bd2cd Nov 7, 2022
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) C-bug Category: This is a bug. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants