Skip to content

[ICE]: it should not be possible to encounter unnormalized aliases in borrowck #160652

Closed

Description

@matthiaskrgr

Code

from tests/ui/coroutine/issue-58888.rs

//@ compile-flags: -Znext-solver=globally

#![feature(coroutines, coroutine_trait)]

use std::ops::Coroutine;

struct Database;

impl Database {
    fn get_connection(&self) -> impl Iterator/*<Item = ()>*/ {
        Some(()).into_iter()
    }

    fn check_connection(&self) -> impl Coroutine/*<Yield = (), Return = ()>*/  {
        #[coroutine]
        move || {
            let iter = self.get_connection();
            for i in iter {
                yield i
            }
        }
    }
}

fn main() {
    let _ = Database.check_connection();
}

Meta

rustc --version --verbose:

rustc 1.99.0-nightly (84b36a78a 2026-08-06)
binary: rustc
commit-hash: 84b36a78a28a63f134171c670be1932ffa2485f8
commit-date: 2026-08-06
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 23.1.0

Error output

<output>
Backtrace

error: internal compiler error: /rustc-dev/84b36a78a28a63f134171c670be1932ffa2485f8/compiler/rustc_borrowck/src/type_check/relate_tys.rs:389:17: it should not be possible to encounter unnormalized aliases in borrowck
  --> coroutine/issue-58888.rs:20:17
   |
20 |                 yield i
   |                 ^^^^^^^


thread 'rustc' (2706795) panicked at /rustc-dev/84b36a78a28a63f134171c670be1932ffa2485f8/compiler/rustc_borrowck/src/type_check/relate_tys.rs:389:17:
Box<dyn Any>
stack backtrace:
   0:     0x7fa1a52f2956 - <<std[6cb999a3dbb652d9]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[cdb7ffe4be53d62]::fmt::Display>::fmt
   1:     0x7fa1a5a1118f - core[cdb7ffe4be53d62]::fmt::write
   2:     0x7fa1a530787c - <std[6cb999a3dbb652d9]::sys::stdio::unix::Stderr as core[cdb7ffe4be53d62]::io::write::Write>::write_fmt
   3:     0x7fa1a52c573a - std[6cb999a3dbb652d9]::panicking::default_hook::{closure#0}
   4:     0x7fa1a52e64d3 - std[6cb999a3dbb652d9]::panicking::default_hook
   5:     0x7fa1a4241caa - std[6cb999a3dbb652d9]::panicking::update_hook::<alloc[1d52d4102791da9a]::boxed::Box<rustc_driver_impl[3bc4d727b6aa2dc4]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fa1a52e6972 - std[6cb999a3dbb652d9]::panicking::panic_with_hook
   7:     0x7fa1a426f804 - std[6cb999a3dbb652d9]::panicking::begin_panic::<rustc_errors[ff393dc04c4b72ae]::ExplicitBug>::{closure#0}
   8:     0x7fa1a42683e6 - std[6cb999a3dbb652d9]::sys::backtrace::__rust_end_short_backtrace::<std[6cb999a3dbb652d9]::panicking::begin_panic<rustc_errors[ff393dc04c4b72ae]::ExplicitBug>::{closure#0}, !>
   9:     0x7fa1a426828b - std[6cb999a3dbb652d9]::panicking::begin_panic::<rustc_errors[ff393dc04c4b72ae]::ExplicitBug>
  10:     0x7fa1a427b0f1 - <rustc_errors[ff393dc04c4b72ae]::diagnostic::BugAbort as rustc_errors[ff393dc04c4b72ae]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fa1a47f8cac - <rustc_errors[ff393dc04c4b72ae]::DiagCtxtHandle>::span_bug::<rustc_span[78ea2eb5514a41c4]::span_encoding::Span, alloc[1d52d4102791da9a]::string::String>
  12:     0x7fa1a48295c6 - rustc_middle[72de90f4b57d7b8b]::util::bug::opt_span_bug_fmt::<rustc_span[78ea2eb5514a41c4]::span_encoding::Span>::{closure#0}
  13:     0x7fa1a48299e2 - rustc_middle[72de90f4b57d7b8b]::ty::context::tls::with_opt::<rustc_middle[72de90f4b57d7b8b]::util::bug::opt_span_bug_fmt<rustc_span[78ea2eb5514a41c4]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7fa1a4814330 - rustc_middle[72de90f4b57d7b8b]::ty::context::tls::with_context_opt::<rustc_middle[72de90f4b57d7b8b]::ty::context::tls::with_opt<rustc_middle[72de90f4b57d7b8b]::util::bug::opt_span_bug_fmt<rustc_span[78ea2eb5514a41c4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7fa1a20b6278 - rustc_middle[72de90f4b57d7b8b]::util::bug::span_bug_fmt::<rustc_span[78ea2eb5514a41c4]::span_encoding::Span>
  16:     0x7fa1a5f082a5 - <rustc_borrowck[de8aafb42a22f6c5]::type_check::TypeChecker>::relate_types
  17:     0x7fa1a714cca8 - <rustc_borrowck[de8aafb42a22f6c5]::type_check::TypeChecker as rustc_middle[72de90f4b57d7b8b]::mir::visit::Visitor>::visit_body
  18:     0x7fa1a1c573cb - rustc_borrowck[de8aafb42a22f6c5]::type_check::type_check
  19:     0x7fa1a6789f9b - <rustc_borrowck[de8aafb42a22f6c5]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  20:     0x7fa1a67822d5 - rustc_borrowck[de8aafb42a22f6c5]::mir_borrowck
  21:     0x7fa1a6781fe5 - rustc_query_impl[528f4f3081ff05f8]::query_impl::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
  22:     0x7fa1a5f86eb5 - rustc_query_impl[528f4f3081ff05f8]::execution::try_execute_query::<rustc_data_structures[1c35ab8e0d4fbb02]::vec_cache::VecCache<rustc_span[78ea2eb5514a41c4]::def_id::LocalDefId, rustc_middle[72de90f4b57d7b8b]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[72de90f4b57d7b8b]::dep_graph::graph::DepNodeIndex>, false>
  23:     0x7fa1a5f893c3 - rustc_query_impl[528f4f3081ff05f8]::query_impl::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7fa1a6919cbd - rustc_hir_analysis[18be3156a7e28758]::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
  25:     0x7fa1a6919986 - rustc_hir_analysis[18be3156a7e28758]::collect::type_of::type_of_opaque
  26:     0x7fa1a5a2713d - rustc_query_impl[528f4f3081ff05f8]::execution::try_execute_query::<rustc_middle[72de90f4b57d7b8b]::query::caches::DefIdCache<rustc_middle[72de90f4b57d7b8b]::query::erase::ErasedData<[u8; 8usize]>>, false>
  27:     0x7fa1a6cae7d0 - rustc_query_impl[528f4f3081ff05f8]::query_impl::type_of_opaque::execute_query_non_incr::__rust_end_short_backtrace
  28:     0x7fa1a5e5e83c - rustc_hir_analysis[18be3156a7e28758]::collect::type_of::type_of
  29:     0x7fa1a5e64c66 - rustc_query_impl[528f4f3081ff05f8]::query_impl::type_of::invoke_provider_fn::__rust_begin_short_backtrace
  30:     0x7fa1a5a2713d - rustc_query_impl[528f4f3081ff05f8]::execution::try_execute_query::<rustc_middle[72de90f4b57d7b8b]::query::caches::DefIdCache<rustc_middle[72de90f4b57d7b8b]::query::erase::ErasedData<[u8; 8usize]>>, false>
  31:     0x7fa1a5a26cd0 - rustc_query_impl[528f4f3081ff05f8]::query_impl::type_of::execute_query_non_incr::__rust_end_short_backtrace
  32:     0x7fa1a691a1a9 - rustc_hir_analysis[18be3156a7e28758]::check::check::check_opaque
  33:     0x7fa1a67625ed - rustc_hir_analysis[18be3156a7e28758]::check::check::check_item_type
  34:     0x7fa1a675926e - rustc_hir_analysis[18be3156a7e28758]::check::wfcheck::check_well_formed
  35:     0x7fa1a675924f - rustc_query_impl[528f4f3081ff05f8]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  36:     0x7fa1a67588bd - rustc_query_impl[528f4f3081ff05f8]::execution::try_execute_query::<rustc_data_structures[1c35ab8e0d4fbb02]::vec_cache::VecCache<rustc_span[78ea2eb5514a41c4]::def_id::LocalDefId, rustc_middle[72de90f4b57d7b8b]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[72de90f4b57d7b8b]::dep_graph::graph::DepNodeIndex>, false>
  37:     0x7fa1a6758647 - rustc_query_impl[528f4f3081ff05f8]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  38:     0x7fa1a674e166 - <rustc_middle[72de90f4b57d7b8b]::hir::ModuleItems>::par_opaques::<rustc_hir_analysis[18be3156a7e28758]::check::wfcheck::check_type_wf::{closure#5}>
  39:     0x7fa1a6755bb1 - rustc_hir_analysis[18be3156a7e28758]::check::wfcheck::check_type_wf
  40:     0x7fa1a6755757 - rustc_query_impl[528f4f3081ff05f8]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  41:     0x7fa1a6c481c9 - rustc_query_impl[528f4f3081ff05f8]::execution::try_execute_query::<rustc_middle[72de90f4b57d7b8b]::query::caches::SingleCache<rustc_middle[72de90f4b57d7b8b]::query::erase::ErasedData<[u8; 1usize]>>, false>
  42:     0x7fa1a6c47fa9 - rustc_query_impl[528f4f3081ff05f8]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  43:     0x7fa1a625e0e4 - rustc_hir_analysis[18be3156a7e28758]::check_crate
  44:     0x7fa1a5f883ba - rustc_interface[1b7d442e2e02cb08]::passes::analysis
  45:     0x7fa1a6c4668a - rustc_query_impl[528f4f3081ff05f8]::execution::try_execute_query::<rustc_middle[72de90f4b57d7b8b]::query::caches::SingleCache<rustc_middle[72de90f4b57d7b8b]::query::erase::ErasedData<[u8; 0usize]>>, false>
  46:     0x7fa1a6c462e9 - rustc_query_impl[528f4f3081ff05f8]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  47:     0x7fa1a6cf4777 - rustc_interface[1b7d442e2e02cb08]::interface::run_compiler::<(), rustc_driver_impl[3bc4d727b6aa2dc4]::run_compiler::{closure#0}>::{closure#2}
  48:     0x7fa1a6d1b424 - std[6cb999a3dbb652d9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1b7d442e2e02cb08]::util::run_in_thread_with_globals<rustc_interface[1b7d442e2e02cb08]::util::run_in_thread_pool_with_globals<rustc_interface[1b7d442e2e02cb08]::interface::run_compiler<(), rustc_driver_impl[3bc4d727b6aa2dc4]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  49:     0x7fa1a6d1b1ed - <std[6cb999a3dbb652d9]::thread::lifecycle::spawn_unchecked<rustc_interface[1b7d442e2e02cb08]::util::run_in_thread_with_globals<rustc_interface[1b7d442e2e02cb08]::util::run_in_thread_pool_with_globals<rustc_interface[1b7d442e2e02cb08]::interface::run_compiler<(), rustc_driver_impl[3bc4d727b6aa2dc4]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[cdb7ffe4be53d62]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  50:     0x7fa1a6d237c0 - <std[6cb999a3dbb652d9]::sys::thread::unix::Thread>::new::thread_start
  51:     0x7fa1a0097739 - <unknown>
  52:     0x7fa1a011bedc - <unknown>
  53:                0x0 - <unknown>

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: please attach the file at `/home/matthias/vcs/github/rust_misc_stuff/tests/ui/rustc-ice-2026-08-06T18_06_35-2706793.txt` to your bug report

note: rustc 1.99.0-nightly (84b36a78a 2026-08-06) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally

query stack during panic:
#0 [mir_borrowck] borrow-checking `<impl at coroutine/issue-58888.rs:10:1: 10:14>::check_connection`
#1 [type_of_opaque] computing type of opaque `<impl at coroutine/issue-58888.rs:10:1: 10:14>::check_connection::{opaque#0}`
#2 [type_of] computing type of `<impl at coroutine/issue-58888.rs:10:1: 10:14>::check_connection::{opaque#0}`
#3 [check_well_formed] checking that `<impl at coroutine/issue-58888.rs:10:1: 10:14>::check_connection::{opaque#0}` is well-formed
#4 [check_type_wf] checking that types are well-formed
#5 [analysis] running analysis passes on crate `issue_58888`
end of query stack
error: aborting due to 1 previous error

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Aug 6, 2026
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 6, 2026
  3. added 3 commits that reference this issue on Aug 27, 2026
    bbe8829
    c4bcc88
    04eae11
  4. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 27, 2026
  5. added a commit that references this issue on Aug 27, 2026
    3725ece
  6. added a commit that references this issue on Aug 28, 2026
    2816795
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-coroutines`#![feature(coroutines)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions