Skip to content

regression/1.93: async closures - error[E0391]: cycle detected when evaluating type-level constant #152497

@petiaccja

Description

@petiaccja

Source code to reproduce

The source code is available here. Unfortunately I don't have minimal repro as the error is involving a large part of my application.

The application must be built using cargo build --release.

Description of the issue

I expected to see this happen: application compiles successfully

Instead, this happened: compilation fails with error[E0391]: cycle detected when evaluating type-level constant

The compilation failure occurs on rustc version 1.93, but not on 1.92 and earlier, which suggests it's possible to compile the code and this might be a regression. I've had similar issues with async closures before, but I managed to work around them. You can see the exact rustc version in the section down below.

The error only occurs when using a release build, not on dev builds.

Complete error message:

error[E0391]: cycle detected when evaluating type-level constant                                                                                                                                                                                                           
  --> sed_manager\src\spec\column_types\reference_types.rs:19:28
   |
19 | pub type SPRef = ObjectUID<{ SP.mask() }>;
   |                            ^^^^^^^^^^^^^
   |
note: ...which requires const-evaluating + checking `spec::column_types::reference_types::SPRef::{constant#0}`...
  --> sed_manager\src\spec\column_types\reference_types.rs:19:30
   |
19 | pub type SPRef = ObjectUID<{ SP.mask() }>;
   |                              ^^
note: ...which requires simplifying constant for the type system `spec::generated::core::all::table_id::SP`...
  --> D:\Programming\sed-manager-rs\target\release\build\sed_manager-3a9768ca6fc6b2ba\out/spec.rs:1:48923
   |
 1 | ...ol" ; pub const METHOD_ID : ThisUID = ThisUID :: new (25769803776u64) ; const NAME_METHOD_ID : & str = "MethodID" ; pub const SP : ThisUID = ThisUID :: new (2220498092032u64) ; const NAME_SP : & str = "SP" ; pub const SP_INFO : ThisUID = ThisUID :: new (8... 
   |                                                                                                                        ^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `spec::generated::core::all::table_id::SP`...
  --> D:\Programming\sed-manager-rs\target\release\build\sed_manager-3a9768ca6fc6b2ba\out/spec.rs:1:48923
   |
 1 | ...ol" ; pub const METHOD_ID : ThisUID = ThisUID :: new (25769803776u64) ; const NAME_METHOD_ID : & str = "MethodID" ; pub const SP : ThisUID = ThisUID :: new (2220498092032u64) ; const NAME_SP : & str = "SP" ; pub const SP_INFO : ThisUID = ThisUID :: new (8... 
   |                                                                                                                        ^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires computing call ABI of `messaging::uid::<impl at sed_manager\src\messaging\uid.rs:78:1: 78:14>::new`...
  --> sed_manager\src\messaging\uid.rs:84:5
   |
84 |     pub const fn new(value: u64) -> Self {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires deducing parameter attributes for messaging::uid::<impl at sed_manager\src\messaging\uid.rs:78:1: 78:14>::new...
  --> sed_manager\src\messaging\uid.rs:84:5
   |
84 |     pub const fn new(value: u64) -> Self {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires checking if item has MIR available: `messaging::uid::<impl at sed_manager\src\messaging\uid.rs:78:1: 78:14>::new`...
  --> sed_manager\src\messaging\uid.rs:84:5
   |
84 |     pub const fn new(value: u64) -> Self {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: ...which requires getting a list of all mir_keys...
note: ...which requires computing type of `applications::activate_locking::activate_locking::{closure#0}::{closure#0}::{closure#0}`...
  --> sed_manager\src\applications\activate_locking.rs:33:31
   |
33 |           .with(async |session| {
   |  _______________________________^
34 | |             let life_cycle_state: LifeCycleState = session.get(locking_sp.as_uid(), SP::LIFE_CYCLE_STATE).await?;
35 | |             if life_cycle_state != LifeCycleState::ManufacturedInactive {
36 | |                 return Err(Error::AlreadyActivated);
...  |
39 | |             Ok::<(), Error>(())
40 | |         })
   | |_________^
note: ...which requires type-checking `applications::activate_locking::activate_locking::{closure#0}::{closure#0}::{closure#0}`...
  --> sed_manager\src\applications\activate_locking.rs:33:31
   |
33 |           .with(async |session| {
   |  _______________________________^
34 | |             let life_cycle_state: LifeCycleState = session.get(locking_sp.as_uid(), SP::LIFE_CYCLE_STATE).await?;
35 | |             if life_cycle_state != LifeCycleState::ManufacturedInactive {
36 | |                 return Err(Error::AlreadyActivated);
...  |
39 | |             Ok::<(), Error>(())
40 | |         })
   | |_________^
note: ...which requires type-checking `applications::activate_locking::activate_locking`...
  --> sed_manager\src\spec\column_types\reference_types.rs:19:28
   |
19 | pub type SPRef = ObjectUID<{ SP.mask() }>;
   |                            ^^^^^^^^^^^^^
   = note: ...which again requires evaluating type-level constant, completing the cycle
note: cycle used when checking that `applications::change_password::change_password` is well-formed
  --> sed_manager\src\spec\column_types\reference_types.rs:19:28
   |
19 | pub type SPRef = ObjectUID<{ SP.mask() }>;
   |                            ^^^^^^^^^^^^^
   = 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

Rustc versions

The following compiler version produces the error:

rustc 1.93.0 (254b59607 2026-01-19)
binary: rustc
commit-hash: 254b59607d4417e9dffbc307138ae5c86280fe4c
commit-date: 2026-01-19
host: x86_64-pc-windows-msvc
release: 1.93.0
LLVM version: 21.1.8

The following compiler version produces compiles successfully:

rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: x86_64-pc-windows-msvc
release: 1.92.0
LLVM version: 21.1.3

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-highHigh priorityS-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.T-typesRelevant to the types 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
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions