Closed
Description
Summary
Error error[E0391] cycle detected when computing when
occursBar
has a significant destructor
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