Skip to content

cycle detected when optimizing MIR with mir-opt-level=2 #76181

Closed
@tmiasko

Description

@tmiasko
#![crate_type = "lib"]

#[derive(Clone, Debug)]
pub struct S {}

impl S {
    pub async fn g(mut c: Self) {
        Self::h(&mut c);
    }

    pub fn h(c: &mut Self) {
        let _ = S::g(c.clone());
    }
}
$ rustc --edition=2018  -Zmir-opt-level=2 a.rs
error[E0391]: cycle detected when optimizing MIR for `<impl at a.rs:6:1: 14:2>::g::{{closure}}#0`
  --> a.rs:7:33
   |
7  |       pub async fn g(mut c: Self) {
   |  _________________________________^
8  | |         Self::h(&mut c);
9  | |     }
   | |_____^
   |
note: ...which requires optimizing MIR for `<impl at a.rs:6:1: 14:2>::h`...
  --> a.rs:11:5
   |
11 |     pub fn h(c: &mut Self) {
   |     ^^^^^^^^^^^^^^^^^^^^^^
   = note: ...which requires computing layout of `std::future::from_generator::GenFuture<[static [email protected]:7:33: 9:6 __arg0:S {}]>`...
   = note: ...which requires computing layout of `[static [email protected]:7:33: 9:6 __arg0:S {}]`...
   = note: ...which again requires optimizing MIR for `<impl at a.rs:6:1: 14:2>::g::{{closure}}#0`, completing the cycle

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-mir-optArea: MIR optimizationsC-bugCategory: This is a bug.I-cycleIssue: A query cycle occurred while none was expectedT-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

    Issue actions