Skip to content

error[E0391] cycle detected when computing when using rust_2021_incompatible_closure_captures  #92725

Closed
@zheland

Description

@zheland

Summary

Error error[E0391] cycle detected when computing when Bar has a significant destructor occurs
when warn/deny rust_2021_incompatible_closure_captures lint on rust beta and nightly with a certain code snippet.
On rust stable, it compiles without any issues. Looks like an issue of rustc (rust-lang/rust-clippy#8258 (comment)).

Code

I tried this code:

#![warn(rust_2021_incompatible_closure_captures)]
pub struct Foo(Bar);
pub struct Bar(Vec<Foo>);

impl Foo {
    pub fn bar(self, v: Bar) -> Bar {
        (|| v)()
    }
}

It compiles successfully on stable or with #![allow(rust_2021_incompatible_closure_captures)]:

    Finished dev [optimized + debuginfo] target(s)

But with this lint warned (or denied) it does not compile on rust beta and on rust nightly with error:

error[E0391]: cycle detected when computing when `Bar` has a significant destructor
 --> src/lib.rs:3:1
  |
3 | pub struct Bar(Vec<Foo>);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: ...which immediately requires computing when `Bar` has a significant destructor again
  = note: cycle used when computing whether `Bar` has a significant drop

Version it worked on

rustc +stable -vV:

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0

Version with regression

rustc +beta --version --verbose:

rustc 1.58.0-beta.3 (4aa9d237c 2022-01-08)
binary: rustc
commit-hash: 4aa9d237c7254fc4829cfea2a27d9896b18cdbc1
commit-date: 2022-01-08
host: x86_64-unknown-linux-gnu
release: 1.58.0-beta.3
LLVM version: 13.0.0

rustc +nightly --version --verbose

rustc 1.60.0-nightly (092e1c9d2 2022-01-09)
binary: rustc
commit-hash: 092e1c9d23158d81be27bb6f71bdd0c6282478fb
commit-date: 2022-01-09
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0

Activity

added
C-bugCategory: This is a bug.
regression-untriagedUntriaged performance or correctness regression.
on Jan 10, 2022
added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Jan 10, 2022
inquisitivecrystal

inquisitivecrystal commented on Jan 11, 2022

@inquisitivecrystal
Contributor

Bisects to #90845, CC @JakobDegen.

Although this is a regression from stable to beta, there's not enough time for it to get fixed before release.

added and removed
regression-untriagedUntriaged performance or correctness regression.
on Jan 11, 2022
JakobDegen

JakobDegen commented on Jan 11, 2022

@JakobDegen
Contributor

Oops. Yeah, i read the error message and immediately knew what was going on. I can hopefully get a patch up for this tomorrow.

@rustbot claim

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Jan 13, 2022
added and removed
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Jan 13, 2022
added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
and removed on Jan 13, 2022

12 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @steffahn@zheland@apiraino@inquisitivecrystal@rustbot

    Issue actions

      `error[E0391] cycle detected when computing` when using `rust_2021_incompatible_closure_captures ` · Issue #92725 · rust-lang/rust