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

Cycle detected while trying to transmute future #124929

Open
Amulet9 opened this issue May 9, 2024 · 0 comments
Open

Cycle detected while trying to transmute future #124929

Amulet9 opened this issue May 9, 2024 · 0 comments
Labels
C-bug Category: This is a bug. I-cycle Issue: A query cycle occurred while none was expected S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Amulet9
Copy link

Amulet9 commented May 9, 2024

I tried this code:

use std::mem::MaybeUninit;

fn main() {
    let fut = async {};
    let cast: [MaybeUninit<u8>; 1] = unsafe { std::mem::transmute(fut) };
}

I was playing around and expected this to succeed, instead, it resulted in this:

error[E0391]: cycle detected when type-checking `main`
 --> src/main.rs:3:1
  |
3 | fn main() {
  | ^^^^^^^^^
  |
  = note: ...which requires computing layout of `{async block@src/main.rs:4:15: 4:23}`...
note: ...which requires optimizing MIR for `main::{closure#0}`...
 --> src/main.rs:4:15
  |
4 |     let fut = async {};
  |               ^^^^^^^^
note: ...which requires elaborating drops for `main::{closure#0}`...
 --> src/main.rs:4:15
  |
4 |     let fut = async {};
  |               ^^^^^^^^
note: ...which requires coroutine witness types for `main::{closure#0}`...
 --> src/main.rs:4:15
  |
4 |     let fut = async {};
  |               ^^^^^^^^
note: ...which requires promoting constants in MIR for `main::{closure#0}`...
 --> src/main.rs:4:15
  |
4 |     let fut = async {};
  |               ^^^^^^^^
note: ...which requires checking if `main::{closure#0}` contains FFI-unwind calls...
 --> src/main.rs:4:15
  |
4 |     let fut = async {};
  |               ^^^^^^^^
note: ...which requires building MIR for `main::{closure#0}`...
 --> src/main.rs:4:15
  |
4 |     let fut = async {};
  |               ^^^^^^^^
note: ...which requires match-checking `main::{closure#0}`...
 --> src/main.rs:4:15
  |
4 |     let fut = async {};
  |               ^^^^^^^^
note: ...which requires type-checking `main::{closure#0}`...
 --> src/main.rs:4:15
  |
4 |     let fut = async {};
  |               ^^^^^^^^
  = note: ...which again requires type-checking `main`, completing the cycle
  = note: cycle used when running analysis passes on this crate
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (87293c958 2024-05-08)
binary: rustc
commit-hash: 87293c9585a7fb2cc83ca9949ae79661d5d3c31a
commit-date: 2024-05-08
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4

@Amulet9 Amulet9 added the C-bug Category: This is a bug. label May 9, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 9, 2024
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue I-cycle Issue: A query cycle occurred while none was expected and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-cycle Issue: A query cycle occurred while none was expected S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants