[ICE]: unexpected cyclic definition
Open
Nobody has claimed this yet.
C-bug
F-type_alias_impl_trait
fixed-by-next-solver
I-ICE
needs-triage
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
unlike https://github.com/rust-lang/rust/issues/151301 this one is reachable in the old solver
snippet:
#![feature(type_alias_impl_trait)]
fn spawn<T, F>(future: F) -> impl Sized
where
F: FnOnce() -> T,
{
}
fn spawn_task(sender: &'static ()) -> impl Sized {
type Tait = impl Sized + 'static;
spawn::<Tait, _>(move || {
type Tait = impl Sized + 'static;
spawn::<Tait, _>(move || sender)
})
}
fn main() {}
Version information
rustc 1.97.0-nightly (22cc6747b 2026-04-19)
binary: rustc
commit-hash: 22cc6747b18b3a6738e98b06676fd91f1756b33a
commit-date: 2026-04-19
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.2
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
warning: unused variable: `future`
--> /tmp/icemaker_global_tempdir.Vwse41DR8tSU/rustc_testrunner_tmpdir_reporting.FAkInl67gJSC/mvce.rs:2:16
|
2 | fn spawn<T, F>(future: F) -> impl Sized
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_future`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
warning: function `spawn` is never used
--> /tmp/icemaker_global_tempdir.Vwse41DR8tSU/rustc_testrunner_tmpdir_reporting.FAkInl67gJSC/mvce.rs:2:4
|
2 | fn spawn<T, F>(future: F) -> impl Sized
| ^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
warning: function `spawn_task` is never used
--> /tmp/icemaker_global_tempdir.Vwse41DR8tSU/rustc_testrunner_tmpdir_reporting.FAkInl67gJSC/mvce.rs:7:4
|
7 | fn spawn_task(sender: &'static ()) -> impl Sized {
| ^^^^^^^^^^
warning: 3 warnings emitted
note: no errors encountered even though delayed bugs were created
note: those delayed bugs will now be shown as internal compiler errors
error: internal compiler error: unexpected cyclic definition of `spawn_task::{closure#0}::Tait::{opaque#0}`
--> /tmp/icemaker_global_tempdir.Vwse41DR8tSU/rustc_testrunner_tmpdir_reporting.FAkInl67gJSC/mvce.rs:10:21
|
10 | type Tait = impl Sized + 'static;
| ^^^^^^^^^^^^^^^^^^^^
|
note: delayed at /rustc-dev/22cc6747b18b3a6738e98b06676fd91f1756b33a/compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs:672:21
0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, alloc::string::String>
4: <rustc_borrowck::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
5: rustc_borrowck::mir_borrowck
6: rustc_query_impl::query_impl::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
7: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
8: rustc_query_impl::query_impl::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
9: rustc_hir_analysis::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
10: rustc_hir_analysis::collect::type_of::type_of_opaque
11: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefIdCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
12: rustc_query_impl::query_impl::type_of_opaque::execute_query_non_incr::__rust_end_short_backtrace
13: rustc_hir_analysis::collect::type_of::type_of
14: rustc_query_impl::query_impl::type_of::invoke_provider_fn::__rust_begin_short_backtrace
15: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefIdCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
16: rustc_query_impl::query_impl::type_of::execute_query_non_incr::__rust_end_short_backtrace
17: rustc_hir_analysis::check::check::check_opaque
18: rustc_hir_analysis::check::check::check_item_type
19: rustc_hir_analysis::check::wfcheck::check_well_formed
20: rustc_query_impl::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
21: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 1]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
22: rustc_query_impl::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
23: rustc_hir_analysis::check::wfcheck::check_type_wf
24: rustc_query_impl::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
25: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 1]>>, false>
26: rustc_query_impl::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
27: rustc_hir_analysis::check_crate
28: rustc_interface::passes::analysis
29: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
30: rustc_query_impl::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
31: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
32: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
33: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
34: <std::sys::thread::unix::Thread>::new::thread_start
35: <unknown>
36: <unknown>
--> /tmp/icemaker_global_tempdir.Vwse41DR8tSU/rustc_testrunner_tmpdir_reporting.FAkInl67gJSC/mvce.rs:10:21
|
10 | type Tait = impl Sized + 'static;
| ^^^^^^^^^^^^^^^^^^^^
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: please make sure that you have updated to the latest nightly
note: rustc 1.97.0-nightly (22cc6747b 2026-04-19) running on x86_64-unknown-linux-gnu
query stack during panic:
end of query stack
@rustbot label +F-type_alias_impl_trait
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the provided snippet with the reported nightly rustc to reproduce the ICE. Then inspect compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs around the delayed-bug location and follow the rustc_hir_analysis opaque-type query stack. Done means the reproducer no longer emits an internal compiler error and has appropriate compiler behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100