Skip to content

Cycle detected when optimizing MIR #146998

@FlixCoder

Description

@FlixCoder

Code

I tried this code:
https://github.com/FlixCoder/fhir-sdk

cargo build -p fhir-model --release

(Probably the same as creating a crate with dependency fhir-model from crates.io).

The example crate is huge and difficult to navigate, so I tried to reproduce with a minimal example with the same cycle:

#[derive(Debug, PartialEq)]
pub struct Bundle(pub Box<BundleInner>);

#[derive(Debug, PartialEq)]
pub struct BundleInner {
	pub issues: Option<Resource>,
	pub entry: Vec<Option<BundleEntry>>,
}

#[derive(Debug, PartialEq)]
pub struct BundleEntry {
	pub resource: Option<Resource>,
}

#[derive(Debug, PartialEq)]
pub enum Resource {
	Bundle(Bundle),
}

However, this successfully compiles.. So I don't really know how to proceed from here, I am open to suggestions what we could try to find a better small example.

I expected to see this happen: Code compiles with opt-level > 1

Instead, this happened: Compilation error on opt-level > 1

(See FlixCoder/fhir-sdk#56 )

Version it worked on

It most recently worked on: 1.89

Version with regression

Rust 1.90 does not and rustc 1.92.0-nightly (975e6c8 2025-09-23) also does not work.

rustc --version --verbose:

rustc 1.92.0-nightly (975e6c8fe 2025-09-23)
binary: rustc
commit-hash: 975e6c8fec280816d24fbde6b8dfe19620f2efe6
commit-date: 2025-09-23
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1

Backtrace

Backtrace

No crash, no backtrace.

Metadata

Metadata

Assignees

Labels

A-mir-optArea: MIR optimizationsC-bugCategory: This is a bug.I-cycleIssue: A query cycle occurred while none was expectedP-mediumMedium priorityS-has-bisectionStatus: A bisection has been found for this issueS-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.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

Development

No branches or pull requests

Issue actions