Repository navigation
Cycle detected when optimizing MIR #146998
Copy link
Copy link
Closed
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.I-cycleIssue: A query cycle occurred while none was expectedIssue: A query cycle occurred while none was expectedP-mediumMedium priorityMedium priorityS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: 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.Relevant 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.Performance or correctness regression from one stable version to another.
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.I-cycleIssue: A query cycle occurred while none was expectedIssue: A query cycle occurred while none was expectedP-mediumMedium priorityMedium priorityS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: 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.Relevant 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.Performance or correctness regression from one stable version to another.
Activity
FlixCoder commentedon Sep 24, 2025
Since I have found it in other issues of this kind, I have run cargo bisect-rustc:
It found the following:
Jules-Bertholet commentedon Sep 24, 2025
#142625 @cjgillot
lqd commentedon Sep 26, 2025
We may need help reducing this 29MB source code 😓
FlixCoder commentedon Sep 27, 2025
cyrgani commentedon Sep 27, 2025
1 remaining item
cyrgani commentedon Sep 28, 2025
Another reduction with expanded derives and simplified output: (requires two library crates
fooandx,foodepends onx)apiraino commentedon Oct 29, 2025
Assigning priority (discussion on Zulip).
@rustbot label -I-prioritize +P-medium
Auto merge of #147361 - saethlin:fallible-cycle-detection, r=oli-obk
cyrgani commentedon Jan 22, 2026
Fixed by #147361.
saethlin commentedon Jan 22, 2026
I am not 100% sure that PR fixed the original issue. Don't hesitate to file a new issue if you run into the problem again.
FlixCoder commentedon Jan 24, 2026
Just tried the current nightly and it succeeds compiling, thank you :)