Skip to content

Cycle detected while trying to transmute future #124929

@Amulet9

Description

@Amulet9

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

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on May 9, 2024
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
I-cycleIssue: A query cycle occurred while none was expected
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-cycleIssue: A query cycle occurred while none was expectedS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jieyouxu@rustbot@Amulet9

        Issue actions

          Cycle detected while trying to transmute future · Issue #124929 · rust-lang/rust